From 6c0e6707ee16fb62765e856800cf5dd1c3bf5353 Mon Sep 17 00:00:00 2001 From: dnesov Date: Sun, 29 Jun 2025 23:35:08 +0200 Subject: [PATCH] Use font.Size for totalHeight, update default style in TestGame, add Pressed virtual method to Button. --- TestGame/Resources/default.style.toml | 1 - Voile/Source/Resources/Font.cs | 2 +- Voile/Source/UI/Widgets/Button.cs | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TestGame/Resources/default.style.toml b/TestGame/Resources/default.style.toml index 18d0bb7..cb4c8f8 100644 --- a/TestGame/Resources/default.style.toml +++ b/TestGame/Resources/default.style.toml @@ -1,7 +1,6 @@ [Button] BackgroundColor = "#0f62fe" TextColor = "#ffffff" -# Padding = [0.0, 12.0, 8.0, 0.0] Padding = 16.0 # Creates an empty rule for Button.Normal. diff --git a/Voile/Source/Resources/Font.cs b/Voile/Source/Resources/Font.cs index 7793df6..8747f20 100644 --- a/Voile/Source/Resources/Font.cs +++ b/Voile/Source/Resources/Font.cs @@ -104,7 +104,7 @@ public class Font : Resource, IUpdatableResource, IDisposable } } - float totalHeight = maxAscent + maxDescent; + float totalHeight = Size; return new Rect(totalWidth, totalHeight); } diff --git a/Voile/Source/UI/Widgets/Button.cs b/Voile/Source/UI/Widgets/Button.cs index 417bea3..c31b12f 100644 --- a/Voile/Source/UI/Widgets/Button.cs +++ b/Voile/Source/UI/Widgets/Button.cs @@ -101,6 +101,8 @@ public class Button : Widget renderer.DrawText(_suitableFont, _text, textColor); } + protected virtual void Pressed() { } + protected override void OnInput(UIInputContext action) { bool isHovering = ContainsPoint(action.MousePosition); @@ -115,6 +117,7 @@ public class Button : Widget if (_isHeldDown && isHovering) { _pressedAction?.Invoke(); + Pressed(); } _isHeldDown = false;