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

Child window (auto-fit) scrollbar appearing when it should not #7063

Closed
Devyre opened this issue Nov 26, 2023 · 1 comment
Closed

Child window (auto-fit) scrollbar appearing when it should not #7063

Devyre opened this issue Nov 26, 2023 · 1 comment

Comments

@Devyre
Copy link

Devyre commented Nov 26, 2023

Hello,

I have been using ImGui (docking) for an editor of my game engine and updated to 1.90 for the content auto-fit of child windows.

It seems to work great but I noticed an issue where a scrollbar appeared in both child window and main window, when the child is supposed to grow within the main window.

I made sure to pass ImGuiChildFlags_AutoResizeY.
I actually stepped through it all and narrowed down the reason why the scrollbar appeared.

While debugging I noticed that window->Size/SizeFull were always 2 pixels lower than the content size.
It seems that child windows use the CalcWindowAutoFitSize function, which makes use of style.DisplaySafeAreaPadding.
I assume this style variable is only meant to be applied when it is a real window and not a child window.

Once I set style.DisplaySafeAreaPadding to 0 the scrollbar of the child disappeared.

The specific line of code causing this problem:

imgui/imgui.cpp

Line 5792 in bce4db0

ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, avail_size - style.DisplaySafeAreaPadding * 2.0f));

@ocornut
Copy link
Owner

ocornut commented Nov 27, 2023

Thank you, I confirmed this and pushed a fix f37f6f6

Repro was:

ImGui::Begin("Bug #7063");
ImGui::BeginChild("blah", ImVec2(0, 0), ImGuiChildFlags_AutoResizeY);
for (int n = 0; n < 1000; n++)
    ImGui::Text("...");
ImGui::EndChild();
ImGui::End();

@ocornut ocornut closed this as completed Nov 27, 2023
ocornut added a commit that referenced this issue Nov 27, 2023
ocornut added a commit that referenced this issue Feb 12, 2024
…sly not displaying a scrollbar when contents is over parent viewport size. (#7287, #7063)

Amend f37f6f6
ocornut added a commit that referenced this issue Feb 20, 2024
…ld erroneously close the window. (#7325, #7287, #7063)

Amend 76e09c4. Initial call to ClosePopupToLevel d31fe97 (#2880).
See "widgets_menu_reopen_2" in TestSuite.
ocornut added a commit that referenced this issue Feb 27, 2024
… successive frames would erroneously close the window. (#7325, #7287, #7063)

Amend 014e0ac
ocornut added a commit that referenced this issue Jun 27, 2024
…n viewport would be erroneously clamped to the size of main viewport. (#7730)

Amend #7287, #7063
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