Regression with Columns() + AlwaysAutoResize between 1.51 and 1.53 #1444

Closed
opened 2017-11-16 14:57:09 +00:00 by itamago · 4 comments
itamago commented 2017-11-16 14:57:09 +00:00 (Migrated from github.com)

Hello,

I migrated some applications using ImGui from version 1.51 to latest 1.53, and I am facing a little bug related to tooltips using ImGuiWindowFlags_AlwaysAutoResize flag when drawing columns inside.

In the latest version 1.53, the tooltips are truncated, as if they were considering only the first row and not the 3 columns which inside :

screen shot 2017-11-16 at 15 54 31

Here is a source code to repro :

ImGui::Begin("tooltip_window", NULL, ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize);
{
	ImGui::Text("Row 0");
	ImGui::Separator();
	ImGui::Columns(3, "columns", false);
	ImGui::SetColumnOffset(0, 0.0f);
	ImGui::SetColumnOffset(1, 30.0f);
	ImGui::SetColumnOffset(2, 95.0f);
	ImGui::Text("AAAA");
	ImGui::NextColumn();
	ImGui::Text("BBBB");
	ImGui::NextColumn();
	ImGui::Text("Row 1 Some long text");
	ImGui::NextColumn();
	ImGui::Columns(1);
}
ImGui::End();

In version 1.51, it was working well.

Best regards,

Hello, I migrated some applications using ImGui from version 1.51 to latest 1.53, and I am facing a little bug related to tooltips using `ImGuiWindowFlags_AlwaysAutoResize` flag when drawing columns inside. In the latest version 1.53, the tooltips are truncated, as if they were considering only the first row and not the 3 columns which inside : <img width="220" alt="screen shot 2017-11-16 at 15 54 31" src="https://user-images.githubusercontent.com/16628136/32897635-77bfabf0-cae6-11e7-84bd-c65fb83db832.png"> Here is a source code to repro : ``` ImGui::Begin("tooltip_window", NULL, ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize); { ImGui::Text("Row 0"); ImGui::Separator(); ImGui::Columns(3, "columns", false); ImGui::SetColumnOffset(0, 0.0f); ImGui::SetColumnOffset(1, 30.0f); ImGui::SetColumnOffset(2, 95.0f); ImGui::Text("AAAA"); ImGui::NextColumn(); ImGui::Text("BBBB"); ImGui::NextColumn(); ImGui::Text("Row 1 Some long text"); ImGui::NextColumn(); ImGui::Columns(1); } ImGui::End(); ``` In version 1.51, it was working well. Best regards,
ocornut commented 2017-11-16 16:12:02 +00:00 (Migrated from github.com)

The problem relates to that change:

"Columns: Fixed the right-most column from registering its content width to the parent window, which led to various issues when using auto-resizing window or e.g. horizonal scrolling. (#519, #125, #913)"
Commit ocornut/imgui@1c83b073c6

The old logic was unfortunately causing way too much trouble, e.g. moving the right column would tend to lead into into a feedback loop, and it was actually related to a bug which would perform nicely in your use case (only the right-most column was extending the contents sizes, and since you are positioning all other offsets this is all you need. But if you don't set the offset it wouldn't make much sense).

Right now one workaround is to do:
ImGui::SetNextWindowContentWidth(300)
But it is a regression since you don't get automatic resizing.

I'm not sure what to do about it right now. I can expose something similar to the old behavior in the imgui_internal.h BeginColumns() API if that would help you in the meanwhile?

The problem relates to that change: "Columns: Fixed the right-most column from registering its content width to the parent window, which led to various issues when using auto-resizing window or e.g. horizonal scrolling. (#519, #125, #913)" Commit https://github.com/ocornut/imgui/commit/1c83b073c66341ea7b22d7dd42916094c9a0fdeb The old logic was unfortunately causing way too much trouble, e.g. moving the right column would tend to lead into into a feedback loop, and it was actually related to a bug which would perform nicely in your use case (only the right-most column was extending the contents sizes, and since you are positioning all other offsets this is all you need. But if you don't set the offset it wouldn't make much sense). Right now one workaround is to do: `ImGui::SetNextWindowContentWidth(300)` But it is a regression since you don't get automatic resizing. I'm not sure what to do about it right now. I can expose something similar to the old behavior in the `imgui_internal.h` `BeginColumns()` API if that would help you in the meanwhile?
itamago commented 2017-11-16 16:27:52 +00:00 (Migrated from github.com)

Thanks for your quick reply.
I am interested in internal API exposing the old behaviour. Thanks !

Thanks for your quick reply. I am interested in internal API exposing the old behaviour. Thanks !
ocornut commented 2017-11-16 16:33:58 +00:00 (Migrated from github.com)

As discussed, I'm adding a temporary internal.h flag ImGuiColumnsFlags_GrowParentContentsSize that you can use with the BeginColumns/EndColumns. This API is not publicly exposed yet because I'm waiting until we add new features to columns before, but it should become the columns 2.0 api eventually.

The behavior is really odd because the "maximum cursor X position" bleeds outside of columns, affecting the parent window resize behavior, but the columns themselves aren't resized. It worked in a few very specific cases like yours. You may also use SetNextWindowContentWidth() if needed.

I'll keep all of this in mind when redesigning the Columns (#125) in the future.

Test code:

ImGui::Begin("Bug #1444");
ImGui::Text("Hover me");
if (ImGui::IsItemHovered())
{
    ImGui::BeginTooltip();
    {
        ImGui::Text("Row 0");
        ImGui::Separator();
        ImGui::BeginColumns("columns", 3, ImGuiColumnsFlags_GrowParentContentsSize);//false);
        ImGui::SetColumnOffset(0, 0.0f);
        ImGui::SetColumnOffset(1, 30.0f);
        ImGui::SetColumnOffset(2, 95.0f);
        ImGui::Text("AAAA");
        ImGui::NextColumn();
        ImGui::Text("BBBB");
        ImGui::NextColumn();
        ImGui::Text("Row 1 Some long text");
        ImGui::NextColumn();
        ImGui::EndColumns();
    }
    ImGui::EndTooltip();
}
ImGui::End();
As discussed, I'm adding a temporary internal.h flag `ImGuiColumnsFlags_GrowParentContentsSize` that you can use with the `BeginColumns/EndColumns`. This API is not publicly exposed yet because I'm waiting until we add new features to columns before, but it should become the columns 2.0 api eventually. The behavior is really odd because the "maximum cursor X position" bleeds outside of columns, affecting the parent window resize behavior, but the columns themselves aren't resized. It worked in a few very specific cases like yours. You may also use `SetNextWindowContentWidth()` if needed. I'll keep all of this in mind when redesigning the Columns (#125) in the future. Test code: ``` ImGui::Begin("Bug #1444"); ImGui::Text("Hover me"); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); { ImGui::Text("Row 0"); ImGui::Separator(); ImGui::BeginColumns("columns", 3, ImGuiColumnsFlags_GrowParentContentsSize);//false); ImGui::SetColumnOffset(0, 0.0f); ImGui::SetColumnOffset(1, 30.0f); ImGui::SetColumnOffset(2, 95.0f); ImGui::Text("AAAA"); ImGui::NextColumn(); ImGui::Text("BBBB"); ImGui::NextColumn(); ImGui::Text("Row 1 Some long text"); ImGui::NextColumn(); ImGui::EndColumns(); } ImGui::EndTooltip(); } ImGui::End(); ```
itamago commented 2017-11-17 09:52:49 +00:00 (Migrated from github.com)

It works like a charm with 2 lines modified, thanks !

It works like a charm with 2 lines modified, thanks !
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#1444
No description provided.