mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Selectable: add support for specifying text alignment on selectables (#2347)
Adds a style variable to Selectable that allows clients to specify the text alignment within Selectables, adds a section in the demo to demonstrate selectable text alignment, and a pair of sliders in the style editor to change selectable alignment on the fly. In terms of implementation, this one is extremely simple: Selectable was already calling an API that supports text alignment, but had hard-coded it to top-left. This changes that to just pass the style variable straight through to RenderTextClipped. Backwards-compatibility is preserved by defaulting the text_align parameter to (0, 0), i.e., top-left. This also fixes a bug with selectable text rendering that caused right-aligned text in a selectable to be clipped incorrectly, because the wrong clipping rectangle was being used.
This commit is contained in:
2
imgui.h
2
imgui.h
@ -1082,6 +1082,7 @@ enum ImGuiStyleVar_
|
||||
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
||||
ImGuiStyleVar_TabRounding, // float TabRounding
|
||||
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
|
||||
ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign
|
||||
ImGuiStyleVar_COUNT
|
||||
|
||||
// Obsolete names (will be removed)
|
||||
@ -1263,6 +1264,7 @@ struct ImGuiStyle
|
||||
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
|
||||
bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
ImVec2 SelectableTextAlign; // Alignment of selectable text when selectable is larger than text. Defaults to (0,0) for top-left alignment.
|
||||
ImVec4 Colors[ImGuiCol_COUNT];
|
||||
|
||||
IMGUI_API ImGuiStyle();
|
||||
|
Reference in New Issue
Block a user