mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58: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:
@ -5100,7 +5100,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
}
|
||||
|
||||
if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
|
||||
RenderTextClipped(bb_inner.Min, bb.Max, label, NULL, &label_size, ImVec2(0.0f,0.0f));
|
||||
RenderTextClipped(bb_inner.Min, bb_inner.Max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
|
||||
if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
|
||||
|
||||
// Automatically close popups
|
||||
|
Reference in New Issue
Block a user