imgui
imgui copied to clipboard
Differing horizontal alignment for drag widget
Version/Branch of Dear ImGui:
Version 1.90.6, Branch: docking
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Windows 11 + VS2022
Full config/build information:
No response
Details:
My Issue:
When using a DragFloat
(or DragFloatN
) widget, the horizontal text alignment when not editing is in the center. However, when the user clicks to edit the drag widget, it aligns to the left (which I presume is due to input fields with center alignment not being supported). The "snapping" of alignment from center to left (and vice-versa) is personally undesirable.
The 2 possible ways to alleviate the "snapping" is to either horizontally align the text when not editing to the left (same as when editing) or changing the alignment of the input text to be centered (same as when not editing).
The first way does not seem to be supported out of the box and can only be done by modifying the imgui source code (to the best of my knowledge) at this location:
https://github.com/ocornut/imgui/blob/a18fb406ace8163309a27f948acb85309dfbd312/imgui_widgets.cpp#L2539
By changing the last argument passed in to RenderTextClipped
function, the alignment can be changed. Hence, maybe this can somehow be exposed to the end user such that they can make their drag widgets default to horizontal left alignment (even in non-editing state).
The second way should be harder as imgui does not have support for center alignment of input text. However, I personally prefer the look of this method where both states have text horizontally centered.
Screenshots/Video:
No response