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)
- TabBar - Common Style
- WebGPU backend causes crash after window resize HOT 2
- Table drawing Horizontal Scrollbar too far below HOT 3
- Vertical Misalignment when using different size fonts with AlignTextToFramePadding HOT 3
- ImDrawList's PushClipRect not inherited by child window HOT 3
- How can I set FULL window transparency HOT 1
- Detecting a mouse click HOT 7
- How to get resizable child in window? HOT 8
- CMake Support HOT 1
- I want know where is ImGuiLayout HOT 3
- Question: How to load state of docked windows HOT 11
- Locked on 62 / 63 fps in dx11 without Vsync HOT 1
- Change cursor when hand whenTextLink is hovered - Common Style HOT 1
- Touchpad tap to click not captured when io.ConfigInputTrickleEventQueue is false HOT 5
- Position inside child window when border width changes HOT 7
- Left upper corner coordinates and child window dimensions for different border thicknesses HOT 3
- InputText display latency when trickling events HOT 4
- ImGui::Image tint_col doesn't allow amplifying texture color intensity HOT 1
- ImGuiListClipper for horizontal lists HOT 2
- 10 years of Dear ImGui (long post) HOT 37
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.