You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Child window with no border seems to be ignoring WindowPadding #462
I've created a "tool panel" style child window that is aligned with the left of the parent window. When I set it's border to 'false', all window padding seems to be ignored. I tried setting the default padding to something large like 20. When BeginChild is called with border=true, the padding shows like usual. When I pass false, the padding is ignored. I'm not sure if this is intended or not. I made a simple example to test this out:
(We have to make sure the childBG has a valid color)
Please let me know if this is something I'm doing wrong, working as intended, or if it's a bug. I can easily work around it for now, but it's just one of those annoying things :)
It sort of made sense because if you don't see a border then the spacing would be odd. But probably it'd be more consistent to not do that and let the user set the WindowPadding to 0.0 if they need it. I'll need to think about it a little more and see the side-effect it could have to change that.
Ok, I get what you're saying. I guess in this specific case allowing the user to control the padding makes more sense to me, but I know that child windows are used for a lot of different things in the framework and could affect a lot. A simple workaround was to just set the border color to the childBG color and not worry about it.
Came back to that, initially decided to remove the inconsistency and require the user to set the padding to 0.0f. I then went and looked at merely the demo.cpp code and it became apparent that it would be an annoyance and break many people code (even if the breakage is so slight).
In addition, it is a rather common pattern to create a "header" full of widget followed by a child filling the rest of the window, and that looks weirder with padding.
So we can either:
A. Enforce consistent padding usage, break some people code and require use of PushStyleVar in more cases.
B. Add a rarely used flag to handle your situation, e.g. ImGuiWindowFlags_ChildWindowUsesWindowPadding.
C. Or document your workaround as the right way to do it.
I think I want to actually go for C there.
I am going to think about it a little more, also because I am thinking that Border information should be explicitly declared in ImGuiStyle for consistency, so that might affect something here.
Alright, I went for B seeing even C looked tedious from user's point of view, and added a flag ImGuiWindowFlags_AlwaysUseWindowPadding.
Also fixed bug with ListBox(), InputTextMultiline() where the content would be misplaced when border was enabled on widgets, because of that same thing.
Activity
ocornut commentedon Dec 30, 2015
The code in Begin() is intentionally doing that:
window->WindowPadding = ((flags & ImGuiWindowFlags_ChildWindow) && (flags & (ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_ComboBox | ImGuiWindowFlags_Popup)) == 0) ? ImVec2(0,0) : style.WindowPadding;It sort of made sense because if you don't see a border then the spacing would be odd. But probably it'd be more consistent to not do that and let the user set the WindowPadding to 0.0 if they need it. I'll need to think about it a little more and see the side-effect it could have to change that.
dsusini commentedon Dec 30, 2015
Ok, I get what you're saying. I guess in this specific case allowing the user to control the padding makes more sense to me, but I know that child windows are used for a lot of different things in the framework and could affect a lot. A simple workaround was to just set the border color to the childBG color and not worry about it.
ocornut commentedon Apr 3, 2016
Came back to that, initially decided to remove the inconsistency and require the user to set the padding to 0.0f. I then went and looked at merely the demo.cpp code and it became apparent that it would be an annoyance and break many people code (even if the breakage is so slight).
In addition, it is a rather common pattern to create a "header" full of widget followed by a child filling the rest of the window, and that looks weirder with padding.
So we can either:
PushStyleVarin more cases.ImGuiWindowFlags_ChildWindowUsesWindowPadding.I think I want to actually go for C there.
I am going to think about it a little more, also because I am thinking that Border information should be explicitly declared in ImGuiStyle for consistency, so that might affect something here.
Added ImGuiWindowFlags_AlwaysUseWindowPadding flag to ensure non-bord…
Fixed InputTextMultiLine(), ListBox(), BeginChildFrame(): outer frame…
ocornut commentedon Apr 3, 2016
Alright, I went for B seeing even C looked tedious from user's point of view, and added a flag
ImGuiWindowFlags_AlwaysUseWindowPadding.Also fixed bug with ListBox(), InputTextMultiline() where the content would be misplaced when border was enabled on widgets, because of that same thing.
BeginChild: Added ImGuiChildFlags_AlwaysUseWindowPadding, obsoleted I…
BeginChild(): Added ImGuiChildFlags_FrameStyle as a replacement for B…
(Breaking) Commented out legacy ImGuiChildFlags_Border (#462), ImGuiW…
(Breaking) Commented out legacy ImGuiChildFlags_Border (ocornut#462),…