Skip to content

Commit

Permalink
Bump version to 1.0.48;
Browse files Browse the repository at this point in the history
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;
  • Loading branch information
onepiecefreak3 committed Dec 17, 2023
1 parent ef7194c commit a28d180
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
14 changes: 8 additions & 6 deletions ImGui.Forms/Controls/ArrowButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -48,7 +50,7 @@ protected override void UpdateInternal(Rectangle contentRect)

private void OnClicked()
{
Clicked?.Invoke(this, new EventArgs());
Clicked?.Invoke(this, EventArgs.Empty);
}
}
}
6 changes: 3 additions & 3 deletions ImGui.Forms/Controls/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions ImGui.Forms/Controls/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
6 changes: 3 additions & 3 deletions ImGui.Forms/Controls/ImageButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions ImGui.Forms/Controls/MultiLineTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions ImGui.Forms/Controls/TextBox.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion ImGui.Forms/Controls/Tree/TreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TreeNode<TNodeData>

public LocalizedString Text { get; set; } = string.Empty;

public Color TextColor { get; set; }
public Color TextColor { get; set; } = Color.Empty;

public FontResource Font { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions ImGui.Forms/Controls/Tree/TreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void UpdateNodes(IList<TreeNode<TNodeData>> 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)
Expand All @@ -95,7 +95,7 @@ private void UpdateNodes(IList<TreeNode<TNodeData>> 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();
Expand Down
2 changes: 1 addition & 1 deletion ImGui.Forms/ImGui.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Imgui.Forms</id>
<version>1.0.47</version>
<version>1.0.48</version>
<description>A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui)</description>

<authors>onepiecefreak</authors>
Expand Down

0 comments on commit a28d180

Please sign in to comment.