Closed matthewcrews closed 4 months ago
The default value for ItemWidth for each column is about two-third of a column. In general SetNextItemWidth(-FLT_MIN); makes the frames items align to the right edge of available space, but in this case it won’t work: you cannot simultaneously request columns to measure the width of their contents and request contents to match the columns width. You probably need to either give a size to your columns, or use SetNextItemWidth() to size your input fields.
PS: you can surround your row with PushID(i)/PopID() and them you won’t have to include i as part of each of your field names, they can become simpler literals.
I want the Input to size to the content and the column to size to the Max Input size. For example, if I have an InputDouble
with a format of %.2f
that is right-aligned, I would want the InputDouble
to be at least wide enough to show the entire number (the content), including the two decimal places, and I would then want the column to be as wide as the widest InputDouble
in that column.
The widest double value is probably DBL_MAX and may not be what you want to use as a width reference. Why not use SetNextItemWidth() with a reasonable amount eg CalcTextSize(“999.99”).x ?
Perfect! Thank you!
Version/Branch of Dear ImGui:
Version 1.90.1, Branch: docking
Back-ends:
imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Windows 11 MSVC 2022
Full config/build information:
Dear Imgui -> Dear Bindings -> Odin Imgui
dear_bindings: https://github.com/dearimgui/dear_bindings Odin Imgui: https://gitlab.com/L-4/odin-imgui
Details:
My Issue/Question:
I am trying to create a table where the columns automatically adjust their width to fit the contents and creates a horizontal scroll bar when it is larger than the window. Right now, the columns are being sized to just the headers, and not to the controls in the rows. You can see in the
Name
column that theInputText
is being cut off.I'm also finding that the
InputDouble
columns are reserving space to the right of the control instead of filling the entire columnScreenshots/Video:
Minimal, Complete and Verifiable Example code: