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
Scroll bar flicker for child windows #7252
Comments
Hello, Thanks for the detailed report. This is indeed tricky, I have sort of an answer for the test case but I'd be interested to see a shot or pseudo-code for the your fuller case. First of all - as you maybe found out, calling For the specific of your test case, setting I started thinking we could safely set |
Added a WIP test for this, The part that pertain to this specific case being: // Verify reaction to altered size and contents size (#7252)
// FIXME-TESTS: We should/could cover more cases by tracking bugs corrected related to the setup of ScrollbarY flag.
vars.InSize = ImVec2(100, 100);
vars.InDeclaredContentSize = ImVec2(100.0f, 100.0f - style.WindowPadding.y * 2.0f);
vars.InSubmittedContentSize = ImVec2(100.0f, 100.0f - style.WindowPadding.y * 2.0f);
ctx->Yield();
IM_CHECK_EQ(vars.OutWindow->ScrollbarY, false);
ctx->Yield();
IM_CHECK_EQ(vars.OutWindow->ScrollbarY, false);
// ...increase contents
vars.InSize.y += 50.0f;
vars.InDeclaredContentSize.y += 50.0f;
vars.InSubmittedContentSize.y += 50.0f;
ctx->Yield();
#if IMGUI_BROKEN_TESTS
IM_CHECK_EQ(vars.OutWindow->ScrollbarY, false); // Expected/ideal
#else
IM_CHECK_EQ(vars.OutWindow->ScrollbarY, true); // Current as of 1.90.4
#endif
ctx->Yield();
IM_CHECK_EQ(vars.OutWindow->ScrollbarY, false); |
Writing this down because it's a typical case where test suite helps understanding side-effects. I changed the code in bool use_current_size_for_scrollbar_x = window_just_created || window_size_x_set_by_api;
bool use_current_size_for_scrollbar_y = window_just_created || window_size_y_set_by_api; And ran all tests, and noticed "table_synced_2" is failing. So I amended the first test: if (vars.InSubmittedContentAuto)
ImGui::Dummy(ImGui::GetContentRegionAvail()); // submit a Dummy() filling all available space
vars.InSize = ImVec2(100, 100);
vars.InDeclaredContentSize = ImVec2(-1.f, -1.f);
vars.InSubmittedContentSize = ImVec2(-1.f, -1.f);
vars.InSubmittedContentAuto = true;
ctx->Yield(2);
IM_CHECK_EQ(vars.OutWindow->ScrollbarY, false);
vars.OutScrollbarYOred = false;
ctx->WindowResize("//Test Window", ImVec2(50, 50));
IM_CHECK_EQ(vars.OutScrollbarYOred, false); // Verify that scrollbar never shown
|
…ze and contents size are submitted by API. (#7252)
I went with 0573513 for now, which seem reasonable and fixed some of my own tests. |
I will update our library versions as soon as I get around to it (likely today, otherwise tomorrow), remove the workaround and test it. Update: |
Version/Branch of Dear ImGui:
Version 1.90.2 WIP (19014), Branch: master/docking
Back-ends:
imgui_impl_win32.cpp + imgui_impl_dx11/dx12.cpp
Compiler, OS:
Windows 10/11 + MSVC 2019/2022
Full config/build information:
Details:
Some background information about the actual application (test case is much simpler):
For a somewhat complex dialog, I have a variable amount of filters at the top in a child of a resizeable child. Whenever I add a filter, if the current height of the outer resizeable child is at its full height, I make it bigger (by setting size constraints accordingly for a single frame) to remain at full height. For the inner child, I set the window height (to the height of the outer child), content height and scroll position in advance to avoid flickering, but the scroll bar still flickers for one frame. Not a high priority since it doesn't impact functionality, but looks a bit annoying.
The test case is reduced to just a toggle changing the size of a single child window. Size and content size get set in advance, still the child window scroll bar flickers when it is toggled bigger. To capture the GIF, I limited the frame rate to 10.
The problem seems to be in
ImGui::Begin()
. There,use_current_size_for_scrollbar_y
(and..._x
as well) will be false for the child. This results in the last size being used to calculate if a scroll bar is needed, despite the current size being available and accurate.Screenshots/Video:
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: