From 4862921b039f0acb754b4097bafae96569d4567f Mon Sep 17 00:00:00 2001 From: choco Date: Fri, 3 Oct 2025 09:50:37 +0200 Subject: [PATCH] table layout for color settings --- LightlessSync/UI/SettingsUi.cs | 75 ++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 2047fa0..95292de 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -978,45 +978,66 @@ public class SettingsUi : WindowMediatorSubscriberBase var colorNames = new[] { - ("LightlessPurple", "Lightless Purple", "Primary colors"), - ("LightlessPurpleActive", "Lightless Purple Active", "Primary colors"), - ("LightlessPurpleDefault", "Lightless Purple Inactive", "Primary colors"), - ("LightlessBlue", "Lightless Blue", "Secondary colors"), + ("LightlessPurple", "Lightless Purple", "Section titles and dividers"), + ("LightlessPurpleActive", "Lightless Purple Active", "Active tabs and hover highlights"), + ("LightlessPurpleDefault", "Lightless Purple Inactive", "Inactive tabs and default dividers"), + ("LightlessBlue", "Lightless Blue", "On/true toggles and 'Upload complete' status"), - ("LightlessGreen", "Lightless Green", "Active elements"), + ("LightlessGreen", "Lightless Green", "Join buttons and success messages"), ("LightlessYellow", "Lightless Yellow", "Warning colors"), ("LightlessYellow2", "Lightless Yellow 2", "Warning colors"), - ("PairBlue", "Pair Blue", "Pair UI elements"), + ("PairBlue", "Pair Blue", "Syncshell headers, toggle highlights, and moderator actions"), - ("DimRed", "Dim Red", "Error and offline") + ("DimRed", "Dim Red", "Error and offline colors") }; - - foreach (var (colorKey, displayName, description) in colorNames) + if (ImGui.BeginTable("##ColorTable", 3, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit)) { - var currentColor = UIColors.Get(colorKey); - var colorToEdit = currentColor; + ImGui.TableSetupColumn("Color", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("Description", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("Reset", ImGuiTableColumnFlags.WidthFixed, 40); + ImGui.TableHeadersRow(); - ImGui.AlignTextToFramePadding(); - - if (ImGui.ColorEdit4($"##color_{colorKey}", ref colorToEdit, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.AlphaPreviewHalf)) + foreach (var (colorKey, displayName, description) in colorNames) { - UIColors.Set(colorKey, colorToEdit); - } - - ImGui.SameLine(); - ImGui.TextUnformatted($"{displayName} - {description}"); - - if (UIColors.IsCustom(colorKey)) - { - ImGui.SameLine(); - if (_uiShared.IconTextButton(FontAwesomeIcon.Undo, $"Reset {colorKey}")) + ImGui.TableNextRow(); + + // olor column + ImGui.TableSetColumnIndex(0); + var currentColor = UIColors.Get(colorKey); + var colorToEdit = currentColor; + if (ImGui.ColorEdit4($"##color_{colorKey}", ref colorToEdit, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.AlphaPreviewHalf)) { - UIColors.Reset(colorKey); + UIColors.Set(colorKey, colorToEdit); + } + ImGui.SameLine(); + ImGui.AlignTextToFramePadding(); + ImGui.TextUnformatted(displayName); + + // description column + ImGui.TableSetColumnIndex(1); + ImGui.AlignTextToFramePadding(); + ImGui.TextUnformatted(description); + + // actions column + ImGui.TableSetColumnIndex(2); + if (UIColors.IsCustom(colorKey)) + { + using var resetId = ImRaii.PushId($"Reset_{colorKey}"); + var availableWidth = ImGui.GetContentRegionAvail().X; + using (ImRaii.PushFont(UiBuilder.IconFont)) + { + if (ImGui.Button(FontAwesomeIcon.Undo.ToIconString(), new Vector2(availableWidth, 0))) + { + UIColors.Reset(colorKey); + } + } + UiSharedService.AttachToolTip("Reset this color to default"); } - UiSharedService.AttachToolTip("Reset this color to default"); } + + ImGui.EndTable(); } ImGui.Spacing(); @@ -2263,4 +2284,4 @@ public class SettingsUi : WindowMediatorSubscriberBase _wasOpen = IsOpen; IsOpen = false; } -} \ No newline at end of file +}