feat(style): add the collapsible section header widget
Replaces ImGui.CollapsingHeader, whose framed bar is the single most ImGui-looking element in the settings window -- 25 of them across nine files. State lives in the widget, not in ImGui's per-window storage. ImGui keys that off the label, so once the section titles are localised the open/closed state would reset on every language switch, and two titles that translate to the same string would share one state. Callers pass a stable key built from an ASCII literal instead. The disabled parameter is not optional decoration. BeginDisabled pushes an alpha that only reaches ImGui's own widgets, so a draw-list header would sit at full opacity while everything around it fades -- and ThemePicker wraps two of its headers in exactly that. Cursor advance goes through ImGuiP.ItemSize like SettingRow, so the scrollbar sees the full height. The gallery shows all three states, including the disabled one inside a real ImRaii.Disabled scope, which is where the alpha problem would otherwise only surface in the theme picker.
This commit is contained in:
@@ -45,6 +45,7 @@ internal sealed class WidgetGalleryWindow : Window
|
||||
);
|
||||
ImGui.Separator();
|
||||
|
||||
DrawSectionHeaderSection(c);
|
||||
DrawRowSection(c);
|
||||
DrawToggleSection(c);
|
||||
DrawSettingRowSection(c);
|
||||
@@ -101,6 +102,54 @@ internal sealed class WidgetGalleryWindow : Window
|
||||
ImGui.Spacing();
|
||||
}
|
||||
|
||||
private void DrawSectionHeaderSection(ThemeColors c)
|
||||
{
|
||||
var colors = new SectionHeaderColors
|
||||
{
|
||||
TitleAbgr = _palette.Abgr(Token.Text, c),
|
||||
DescriptionAbgr = _palette.Abgr(Token.TextMuted, c),
|
||||
AccentAbgr = _palette.Abgr(Token.AccentPrimary, c),
|
||||
BorderAbgr = _palette.Abgr(Token.Border, c),
|
||||
HoverAbgr = _palette.Abgr(Token.SurfaceHover, c),
|
||||
};
|
||||
|
||||
if (
|
||||
SectionHeader.Draw(
|
||||
ImGui.GetID("gallery.section.open"u8),
|
||||
"Open by default",
|
||||
null,
|
||||
colors,
|
||||
defaultOpen: true
|
||||
)
|
||||
)
|
||||
ImGui.TextDisabled(" content of the open section");
|
||||
|
||||
if (
|
||||
SectionHeader.Draw(
|
||||
ImGui.GetID("gallery.section.described"u8),
|
||||
"With a description",
|
||||
"Explains what the section groups, wrapped to the available width.",
|
||||
colors
|
||||
)
|
||||
)
|
||||
ImGui.TextDisabled(" content of the described section");
|
||||
|
||||
// Disabled: BeginDisabled only dims ImGui's own widgets, so a draw-list
|
||||
// header has to fade itself.
|
||||
using (ImRaii.Disabled())
|
||||
{
|
||||
SectionHeader.Draw(
|
||||
ImGui.GetID("gallery.section.disabled"u8),
|
||||
"Disabled",
|
||||
null,
|
||||
colors,
|
||||
disabled: true
|
||||
);
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
}
|
||||
|
||||
private void DrawToggleSection(ThemeColors c)
|
||||
{
|
||||
ImGui.TextUnformatted("Toggle");
|
||||
|
||||
Reference in New Issue
Block a user