From e1e965796b883f4223d47400e54d54a21da1338c Mon Sep 17 00:00:00 2001 From: dnesov Date: Sun, 29 Jun 2025 22:24:54 +0200 Subject: [PATCH] Add proper inheritance for TextColor. --- TestGame/Resources/default.style.toml | 3 +-- Voile/Source/UI/Style.cs | 2 +- Voile/Source/UI/Widgets/Button.cs | 2 +- Voile/Source/UI/Widgets/Label.cs | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/TestGame/Resources/default.style.toml b/TestGame/Resources/default.style.toml index 97873f4..dc3fdc9 100644 --- a/TestGame/Resources/default.style.toml +++ b/TestGame/Resources/default.style.toml @@ -1,6 +1,6 @@ [Button] BackgroundColor = "#0f62fe" -TextColor = "#37eb34" +TextColor = "#ffffff" Padding = 16.0 # Creates an empty rule for Button.Normal. @@ -29,7 +29,6 @@ BackgroundColor = "#750e13" BackgroundColor = [0, 0, 0, 0] BorderSize = 1.0 BorderColor = "#0f62fe" -TextColor = "#0353e9" [Button.Outline.Normal] TextColor = "#0353e9" diff --git a/Voile/Source/UI/Style.cs b/Voile/Source/UI/Style.cs index 73c1b8c..a84e450 100644 --- a/Voile/Source/UI/Style.cs +++ b/Voile/Source/UI/Style.cs @@ -19,7 +19,7 @@ public class Style public Size BorderSize { get; set; } public Color? BorderColor { get; set; } public float CornerRadius { get; set; } - public Color TextColor { get; set; } = Color.White; + public Color? TextColor { get; set; } } public class StyleSheetLoader : ResourceLoader diff --git a/Voile/Source/UI/Widgets/Button.cs b/Voile/Source/UI/Widgets/Button.cs index 08c6230..d0f03a8 100644 --- a/Voile/Source/UI/Widgets/Button.cs +++ b/Voile/Source/UI/Widgets/Button.cs @@ -89,7 +89,7 @@ public class Button : Widget } _padding = style.Padding; - var textColor = style.TextColor; + var textColor = style.TextColor ?? Color.Black; // renderer.SetTransform(GlobalPosition, Vector2.Zero); // renderer.DrawRectangle(new Vector2(Size.Width, Size.Height), backgroundColor); diff --git a/Voile/Source/UI/Widgets/Label.cs b/Voile/Source/UI/Widgets/Label.cs index e834ff9..60f6872 100644 --- a/Voile/Source/UI/Widgets/Label.cs +++ b/Voile/Source/UI/Widgets/Label.cs @@ -55,7 +55,7 @@ public class Label : Widget RenderStyleBox(renderer, style); renderer.SetTransform(GlobalPosition, Vector2.Zero); - renderer.DrawText(_suitableFont, _text, style.TextColor); + renderer.DrawText(_suitableFont, _text, style.TextColor ?? Color.Black); } protected override void OnUpdate()