mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 19:03:30 +00:00
Odd animation-like autoresizing with Columns using ImGuiColumnsFlags_GrowParentContentsSize #2707
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#2707
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)
Version/Branch of Dear ImGui:
Version: 1.72
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: CLang
Operating System: Arch Linux 64 Bit
My Issue/Question:
Having a window with an optional horizontal scrollbar, using the new columns-api with the
GrowParentContentsSizeflag causes a very odd behaviour.Here's code that reproduces it on my system:
Removing either the horizontal scrollbar from the window, or the flag from the columns fixes the issue.
and here's a video to show what it looks like:

That's a side effect of the change in 1.71:
It's not however incorrect (actually more correct than it used to be, just more strange). Combining both flags without setting a known contents size is kinda contradictory and creates a feedback loop. Columns use all the available width, and
ImGuiColumnsFlags_GrowParentContentsSizeis growing/requesting more width since that is permitted by the presence of the horizontal scrollbar.If you use
ImGuiWindowFlags_HorizontalScrollbaryou need to either callImGui::SetNextWindowContentSize(width, 0.0f)to decide of known width, or not exclusively use widgets that try to use whatever width is available while trying to grow that width.Those problems will be much more naturally/easily solved with the upcoming Tables (~Columns V2) api.
(EDIT Please use github attachment for gif files and not external host, as requested by the contributing guidelines and issue template. If you use an external host you are actively preventing future users from understanding the context of your issue. Thank you!)
Sorry, I must've missed the embed in the contributing guideline!
And yeah, that actually does make a lot more sense 🤔
I don't know how many columns or the width of their content in advance, so I suspect I'll have to make an educated guess or precalculate using some measurements.
Thanks for the quick response!
Generally if you enable horizontal scrolling the columns need to have a fixed (non-proportionally-stretching sizes) width. The column system currently only have "proportionally-stretching" columns.
Then your problem is to get a decent initial width for alll or individual columns. The Table system will handle that for you as well as offer manual options such as "fit all columns to contents".
I'm hoping the new table api will make it in a test branch in August and hopefully in master before end of September.
I figured out a good hack for my usecase: I calculate the size the item requires myself, and if it's larger than the current column's width, I reset the width to the item's value.
This looks almost flawless, though it needs to be wrapped into a separate class since the draw call has to be done after the calculation, otherwise things will be clipped through columns.
And I'm definitely looking forward to it! Though don't stress yourself, you've done amazing work on this project and enabled me and others to work on their dream-projects!
Closing this as Columns are a legacy features and Tables now handle this better.