Use font.Size for totalHeight, update default style in TestGame, add Pressed virtual method to Button.

This commit is contained in:
2025-06-29 23:35:08 +02:00
parent c6e1bf7f41
commit 6c0e6707ee
3 changed files with 4 additions and 2 deletions

View File

@@ -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.

View File

@@ -104,7 +104,7 @@ public class Font : Resource, IUpdatableResource, IDisposable
}
}
float totalHeight = maxAscent + maxDescent;
float totalHeight = Size;
return new Rect(totalWidth, totalHeight);
}

View File

@@ -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;