Comments (6)
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 ImGui::Dummy()
) for that purpose.
from imgui.
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.
from imgui.
True!
Removing the child and adding ImGuiWindowFlags_HorizontalScrollbar to the parent window did the trick, thanks!
Btw, what I've used as a workaround is to use ImGui::SetCursorPos({20000.0,20000.0}); - Which also solved the problem, but I'm not sure whether the position of the cursor is expressed in pixels, or as a caret position within the window.
In any case, my mistake, after the clarification things work as expected and the issue may be closed.
Thanks everyone!
from imgui.
Interestingly enough, if I change the window and child creation part to the following:
ImGui::SetNextWindowContentSize(ImVec2(25000.0f, 0.0f));
ImGui::Begin("Scroll Window", NULL);
ImGui::BeginChild("Child",
ImVec2(ImGui::GetContentRegionAvail().x,
ImGui::GetContentRegionAvail().y),
false, ImGuiWindowFlags_AlwaysHorizontalScrollbar);
The horizontal scroll bar does appear, but still doesn't behave the same as the vertical scroller - It will just be non-functional.
Hope that would help identifying the root cause of the issue
from imgui.
Btw, what I've used as a workaround is to use ImGui::SetCursorPos({20000.0,20000.0}); - Which also solved the problem, but I'm not sure whether the position of the cursor is expressed in pixels, or as a caret position within the window.
Positions with SetCursorPos()
are relatives to upper-left position of window, aka this is a pretty rubbish scheme which I would like to get rid of in v2.0, but nevertheless it is almost never a good idea to use SetCursorPos() with a constant/absolute value.
By calling Dummy({20000,20000})
after Begin()
you would state the window has that much of contents and its scrollbar needs to take account of that + padding, which should be the same as calling SetNextWindowContentSize({20000.0f,20000.0f})
before Begin()
. All values are currently in pixels.
Quite importantly, however, since 1.89 it is technically obsolete to use SetCursorPos()
without an item to extent windows boundaries. See the Breaking Changes explanation of v1.89, but ErrorCheckUsingSetCursorPosToExtendParentBoundaries()
if IMGUI_DISABLE_OBSOLETE_FUNCTIONS
is not set currently emulate the old behavior.
from imgui.
Quite importantly, however, since 1.89 it is technically obsolete to use SetCursorPos() without an item to extent windows boundaries. See the Breaking Changes explanation of v1.89, but ErrorCheckUsingSetCursorPosToExtendParentBoundaries() if IMGUI_DISABLE_OBSOLETE_FUNCTIONS is not set currently emulate the old behavior.
For reference, pasting the contents of ErrorCheckUsingSetCursorPosToExtendParentBoundaries()
here:
// 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 #else
block is removed and replaced by the other block.
from imgui.
Related Issues (20)
- Child windows and docking + IsWindowFocused HOT 3
- Table Not Automatically Adjusting Column width to contained controls. HOT 4
- Automatic button color change on hover HOT 2
- SDL_SetTextInputArea (in ImGui 1.90.9) no longer available >>> SDL_SetTextInputRect HOT 3
- Is Carriage Return usable is window label? HOT 1
- [Bug?] Large (font size) merged fonts leading to blocky, fat text HOT 1
- How to never steal keyboard/window focus but process mouse and keyboard keys ? HOT 3
- Trying to get ImGui to work in high dpi mode with sdl3 renderer backend but its not actually drawing in high dpi.
- I think it's a very old bug in the tables. HOT 1
- Scroll (SetScrollHereY) precision issue with messy font size float (and solution) HOT 3
- FullScreen Mode Issue on MacBook Air M3: Toolbar Buttons Misaligned and Unresponsive Due to Notch HOT 3
- Window goes blank on AMD GPU (driver issue) HOT 8
- Transparent windows in a secondary viewport HOT 3
- Sub sub-menu fail to display using ImGuiConfigFlags_ViewportsEnable HOT 3
- Unmapped Memory Access
- Style color for active input field (feature request) HOT 2
- Frame rate control for individual windows HOT 1
- DirectX12 'ft2build.h' : No such file or directory
- SetNextWindowRefreshPolicy issues HOT 3
- ListClipper jumps back when scrolls down to bottom HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.