Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differing horizontal alignment for drag widget #7736

Open
Rageking8 opened this issue Jun 25, 2024 · 0 comments
Open

Differing horizontal alignment for drag widget #7736

Rageking8 opened this issue Jun 25, 2024 · 0 comments

Comments

@Rageking8
Copy link

Rageking8 commented Jun 25, 2024

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:

RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f));

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants