Use font.Size for totalHeight, update default style in TestGame, add Pressed virtual method to Button.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
[Button]
|
[Button]
|
||||||
BackgroundColor = "#0f62fe"
|
BackgroundColor = "#0f62fe"
|
||||||
TextColor = "#ffffff"
|
TextColor = "#ffffff"
|
||||||
# Padding = [0.0, 12.0, 8.0, 0.0]
|
|
||||||
Padding = 16.0
|
Padding = 16.0
|
||||||
|
|
||||||
# Creates an empty rule for Button.Normal.
|
# Creates an empty rule for Button.Normal.
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class Font : Resource, IUpdatableResource, IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float totalHeight = maxAscent + maxDescent;
|
float totalHeight = Size;
|
||||||
return new Rect(totalWidth, totalHeight);
|
return new Rect(totalWidth, totalHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public class Button : Widget
|
|||||||
renderer.DrawText(_suitableFont, _text, textColor);
|
renderer.DrawText(_suitableFont, _text, textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Pressed() { }
|
||||||
|
|
||||||
protected override void OnInput(UIInputContext action)
|
protected override void OnInput(UIInputContext action)
|
||||||
{
|
{
|
||||||
bool isHovering = ContainsPoint(action.MousePosition);
|
bool isHovering = ContainsPoint(action.MousePosition);
|
||||||
@@ -115,6 +117,7 @@ public class Button : Widget
|
|||||||
if (_isHeldDown && isHovering)
|
if (_isHeldDown && isHovering)
|
||||||
{
|
{
|
||||||
_pressedAction?.Invoke();
|
_pressedAction?.Invoke();
|
||||||
|
Pressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
_isHeldDown = false;
|
_isHeldDown = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user