From a28d180bd5cb6cb6b53a1f260d5155b5f7ac54c4 Mon Sep 17 00:00:00 2001 From: onepiecefreak3 Date: Sun, 17 Dec 2023 18:05:54 +0100 Subject: [PATCH] Bump version to 1.0.48; TreeNode text color switches with theme, if set by the framework; Put ImGuiCol's as disabled colors for components (TextDisabled for consistency); Fix size calculation for ArrowButtons; --- ImGui.Forms/Controls/ArrowButton.cs | 14 ++++++++------ ImGui.Forms/Controls/Button.cs | 6 +++--- ImGui.Forms/Controls/CheckBox.cs | 8 ++++---- ImGui.Forms/Controls/ImageButton.cs | 6 +++--- ImGui.Forms/Controls/MultiLineTextBox.cs | 6 +++--- ImGui.Forms/Controls/TextBox.cs | 10 +++++----- ImGui.Forms/Controls/Tree/TreeNode.cs | 2 +- ImGui.Forms/Controls/Tree/TreeView.cs | 4 ++-- ImGui.Forms/ImGui.Forms.nuspec | 2 +- 9 files changed, 30 insertions(+), 28 deletions(-) diff --git a/ImGui.Forms/Controls/ArrowButton.cs b/ImGui.Forms/Controls/ArrowButton.cs index ed4d63f..95dcd4a 100644 --- a/ImGui.Forms/Controls/ArrowButton.cs +++ b/ImGui.Forms/Controls/ArrowButton.cs @@ -10,6 +10,9 @@ namespace ImGui.Forms.Controls { public class ArrowButton : Component { + private const int ButtonSizeX_ = 11; + private const int ButtonSizeY_ = 13; + public KeyCommand KeyAction { get; set; } public ImGuiDir Direction { get; set; } = ImGuiDir.None; @@ -22,10 +25,9 @@ public class ArrowButton : Component public override Size GetSize() { - var height = FontResource.GetCurrentLineHeight(); var padding = ImGuiNET.ImGui.GetStyle().FramePadding; - return new Size((int)Math.Ceiling(height + padding.X * 2), (int)Math.Ceiling(height + padding.Y * 2)); + return new Size((int)Math.Ceiling(ButtonSizeX_ + padding.X * 2), (int)Math.Ceiling(ButtonSizeY_ + padding.Y * 2)); } protected override void UpdateInternal(Rectangle contentRect) @@ -34,9 +36,9 @@ protected override void UpdateInternal(Rectangle contentRect) if (!enabled) { - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF666666); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); } if ((ImGuiNET.ImGui.ArrowButton($"##{Id}", Direction) || IsKeyDown(KeyAction)) && Enabled) @@ -48,7 +50,7 @@ protected override void UpdateInternal(Rectangle contentRect) private void OnClicked() { - Clicked?.Invoke(this, new EventArgs()); + Clicked?.Invoke(this, EventArgs.Empty); } } } diff --git a/ImGui.Forms/Controls/Button.cs b/ImGui.Forms/Controls/Button.cs index 8a9dac8..9216e6a 100644 --- a/ImGui.Forms/Controls/Button.cs +++ b/ImGui.Forms/Controls/Button.cs @@ -70,9 +70,9 @@ private void ApplyStyles(bool enabled, FontResource font) { if (!enabled) { - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF666666); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); } if (font != null) diff --git a/ImGui.Forms/Controls/CheckBox.cs b/ImGui.Forms/Controls/CheckBox.cs index 37ac3e5..d905712 100644 --- a/ImGui.Forms/Controls/CheckBox.cs +++ b/ImGui.Forms/Controls/CheckBox.cs @@ -54,10 +54,10 @@ private void ApplyStyles(bool enabled) { if (!enabled) { - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.CheckMark, 0xFF999999); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, 0xFF666666); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.CheckMark, ImGuiNET.ImGui.GetColorU32(ImGuiCol.Text)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); } } diff --git a/ImGui.Forms/Controls/ImageButton.cs b/ImGui.Forms/Controls/ImageButton.cs index c8c3b84..1a1364a 100644 --- a/ImGui.Forms/Controls/ImageButton.cs +++ b/ImGui.Forms/Controls/ImageButton.cs @@ -73,9 +73,9 @@ private void ApplyStyles(bool enabled) { if (!enabled) { - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xFF666666); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ButtonActive, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); } ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Padding); diff --git a/ImGui.Forms/Controls/MultiLineTextBox.cs b/ImGui.Forms/Controls/MultiLineTextBox.cs index 1a60c60..ce13cbb 100644 --- a/ImGui.Forms/Controls/MultiLineTextBox.cs +++ b/ImGui.Forms/Controls/MultiLineTextBox.cs @@ -55,9 +55,9 @@ protected override void UpdateInternal(Rectangle contentRect) if (isReadonly || !enabled) { - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, 0xFF666666); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); } if (ImGuiNET.ImGui.InputTextMultiline($"##{Id}", ref _text, MaxCharacters, contentRect.Size, flags)) diff --git a/ImGui.Forms/Controls/TextBox.cs b/ImGui.Forms/Controls/TextBox.cs index 3cb0bc3..b947fd4 100644 --- a/ImGui.Forms/Controls/TextBox.cs +++ b/ImGui.Forms/Controls/TextBox.cs @@ -1,12 +1,12 @@ using System; -using System.Diagnostics; using System.Numerics; using ImGui.Forms.Controls.Base; using ImGui.Forms.Localization; using ImGui.Forms.Models; using ImGui.Forms.Resources; using ImGuiNET; -using Veldrid; +using Rectangle = Veldrid.Rectangle; +using Size = ImGui.Forms.Models.Size; namespace ImGui.Forms.Controls { @@ -113,9 +113,9 @@ protected override void UpdateInternal(Rectangle contentRect) if (isReadonly || !enabled) { - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, 0xFF666666); - ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, 0xFF666666); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, ImGuiNET.ImGui.GetColorU32(ImGuiCol.TextDisabled)); } if (!string.IsNullOrEmpty(Placeholder)) diff --git a/ImGui.Forms/Controls/Tree/TreeNode.cs b/ImGui.Forms/Controls/Tree/TreeNode.cs index 52413cb..787185c 100644 --- a/ImGui.Forms/Controls/Tree/TreeNode.cs +++ b/ImGui.Forms/Controls/Tree/TreeNode.cs @@ -15,7 +15,7 @@ public class TreeNode public LocalizedString Text { get; set; } = string.Empty; - public Color TextColor { get; set; } + public Color TextColor { get; set; } = Color.Empty; public FontResource Font { get; set; } diff --git a/ImGui.Forms/Controls/Tree/TreeView.cs b/ImGui.Forms/Controls/Tree/TreeView.cs index ae390fa..4ce8afa 100644 --- a/ImGui.Forms/Controls/Tree/TreeView.cs +++ b/ImGui.Forms/Controls/Tree/TreeView.cs @@ -81,7 +81,7 @@ private void UpdateNodes(IList> nodes, ref bool nodeHovered) ImGuiNET.ImGui.PushID(nodeId); ImGuiNET.ImGui.SetNextItemOpen(node.IsExpanded); - if (node.TextColor != Color.Empty) + if (node.TextColor.IsEmpty) ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, node.TextColor.ToUInt32()); if (node.Font != null) @@ -95,7 +95,7 @@ private void UpdateNodes(IList> nodes, ref bool nodeHovered) if (node.Font != null) ImGuiNET.ImGui.PopFont(); - if (node.TextColor != Color.Empty) + if (node.TextColor.IsEmpty) ImGuiNET.ImGui.PopStyleColor(); ImGuiNET.ImGui.PopID(); diff --git a/ImGui.Forms/ImGui.Forms.nuspec b/ImGui.Forms/ImGui.Forms.nuspec index d4b9319..8b67975 100644 --- a/ImGui.Forms/ImGui.Forms.nuspec +++ b/ImGui.Forms/ImGui.Forms.nuspec @@ -2,7 +2,7 @@ Imgui.Forms - 1.0.47 + 1.0.48 A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui) onepiecefreak