From 7c0703067345921ee59244fc68f15cc62a6c187f Mon Sep 17 00:00:00 2001 From: sen Date: Tue, 19 Jul 2022 21:12:59 -0700 Subject: [PATCH] UIButton scale to it's font --- .../ui/component/type/input/button/UIButton.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/kotlin/net/prismclient/aether/ui/component/type/input/button/UIButton.kt b/src/main/kotlin/net/prismclient/aether/ui/component/type/input/button/UIButton.kt index 26fcf0f..452391b 100644 --- a/src/main/kotlin/net/prismclient/aether/ui/component/type/input/button/UIButton.kt +++ b/src/main/kotlin/net/prismclient/aether/ui/component/type/input/button/UIButton.kt @@ -14,16 +14,28 @@ open class UIButton(text: String) : UIComponent() { set(value) { field = value style.font?.actualText = text + updateFont() } override fun update() { super.update() style.font?.actualText = text + updateFont() } override fun renderComponent() { style.font?.render() } + fun updateFont() { + width = width.coerceAtLeast(style.font?.cachedWidth ?: 0f) + height = height.coerceAtLeast(style.font?.cachedHeight ?: 0f) + updateAnchorPoint() + updatePosition() + updateBounds() + updateStyle() + style.font?.updateFont() + } + override fun createsStyle(): UIStyleSheet = UIStyleSheet() } \ No newline at end of file