Skip to content

Commit

Permalink
UIButton scale to it's font
Browse files Browse the repository at this point in the history
  • Loading branch information
senxd committed Jul 20, 2022
1 parent 168b4c3 commit 7c07030
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,28 @@ open class UIButton(text: String) : UIComponent<UIStyleSheet>() {
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()
}

0 comments on commit 7c07030

Please sign in to comment.