-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
No horizontal scrollbar in a window when calling SetNextWindowContentSize with size larger than the screen #7604
Comments
Interestingly enough, if I change the window and child creation part to the following:
The horizontal scroll bar does appear, but still doesn't behave the same as the vertical scroller - It will just be non-functional. |
You set the content size for the parent window, but give the horizontal scroll bar to the child window which doesn't have a content size specified. Even though the child is embedded into the parent, that are two different windows that you are mixing up. Btw, just drawing through a draw list doesn't add "content" of which the window logic is aware of. You could also submit a dummy item (f.e. with |
Daniel is right, but it is also confusing why the only contents of your window is a child window and nothing else (maybe it's due to stripping down the code to reproduce the repro?). If the only content is another window it seems like the nested child may be extraneous. |
True! |
Positions with Quite importantly, however, since 1.89 it is technically obsolete to use |
For reference, pasting the contents of // Until 1.89 (IMGUI_VERSION_NUM < 18814) it was legal to use SetCursorPos() to extend the boundary of a parent (e.g. window or table cell)
// This is causing issues and ambiguity and we need to retire that.
// See https://github.com/ocornut/imgui/issues/5548 for more details.
// [Scenario 1]
// Previously this would make the window content size ~200x200:
// Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + End(); // NOT OK
// Instead, please submit an item:
// Begin(...) + SetCursorScreenPos(GetCursorScreenPos() + ImVec2(200,200)) + Dummy(ImVec2(0,0)) + End(); // OK
// Alternative:
// Begin(...) + Dummy(ImVec2(200,200)) + End(); // OK
// [Scenario 2]
// For reference this is one of the issue what we aim to fix with this change:
// BeginGroup() + SomeItem("foobar") + SetCursorScreenPos(GetCursorScreenPos()) + EndGroup()
// The previous logic made SetCursorScreenPos(GetCursorScreenPos()) have a side-effect! It would erroneously incorporate ItemSpacing.y after the item into content size, making the group taller!
// While this code is a little twisted, no-one would expect SetXXX(GetXXX()) to have a side-effect. Using vertical alignment patterns could trigger this issue.
void ImGui::ErrorCheckUsingSetCursorPosToExtendParentBoundaries()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT(window->DC.IsSetPos);
window->DC.IsSetPos = false;
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if (window->DC.CursorPos.x <= window->DC.CursorMaxPos.x && window->DC.CursorPos.y <= window->DC.CursorMaxPos.y)
return;
if (window->SkipItems)
return;
IM_ASSERT(0 && "Code uses SetCursorPos()/SetCursorScreenPos() to extend window/parent boundaries. Please submit an item e.g. Dummy() to validate extent.");
#else
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
#endif
} It is expected that near the end of this year (two years after 1.89.0) the |
Version/Branch of Dear ImGui:
Version 1.89.9, Branch: docking
Back-ends:
imgui_impl_sdl2cpp + imgui_imp_sdlrenderer2cpp
Compiler, OS:
Windows 11 + MSVC 19.39.33521.0
Full config/build information:
Details:
I am trying to specify a window client area which is certainly larger than the display, and to enable scrolling through it.
To test that, I am drawing a line, and test the scroll behavior visually.
My brief version of the code is:
The vertical scrolling works just as expected - The scroll bar appears in the window and the line portion is displayed relative to the viewed area.
However, the horizontal scroll bar is not being displayed despite specifying the ImGuiWindowFlags_HorizontalScrollbar flag for the child. Specifying the ImGuiWindowFlags_AlwaysHorizontalScrollbar doesn't help either.
Am I missing something?
Thanks,
Tim
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: