Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
itamago opened this issue Nov 16, 2017 · 4 comments
Closed

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

itamago opened this issue Nov 16, 2017 · 4 comments

Comments

@itamago
Copy link

itamago commented Nov 16, 2017

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,

@ocornut
Copy link
Owner

ocornut commented Nov 16, 2017

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 1c83b07

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?

@ocornut ocornut changed the title Migration from 1.51 to 1.53 : regression in Tooltip (sub-window) with AlwaysAutoResize Regression with Columns() + AlwaysAutoResize between 1.51 and 1.53 Nov 16, 2017
@itamago
Copy link
Author

itamago commented Nov 16, 2017

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

@ocornut
Copy link
Owner

ocornut commented Nov 16, 2017

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();

@ocornut ocornut closed this as completed Nov 16, 2017
ocornut added a commit that referenced this issue Nov 16, 2017
@itamago
Copy link
Author

itamago commented Nov 17, 2017

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

ocornut added a commit that referenced this issue Dec 10, 2017
…tSize(). Kept redirection function (will obsolete). (#246, #519, #1444)
ocornut added a commit that referenced this issue Nov 18, 2020
…ColumnFlags_*. (#125, #513, #913, #1204, #1444, #2142, #2707)

Affected: ImGuiColumnsFlags_None, ImGuiColumnsFlags_NoBorder, ImGuiColumnsFlags_NoResize, ImGuiColumnsFlags_NoPreserveWidths, ImGuiColumnsFlags_NoForceWithinWindow, ImGuiColumnsFlags_GrowParentContentsSize. Added redirection enums. Did not add redirection type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants