Fix enum button label width not updating

This commit is contained in:
Shadowfacts 2021-03-12 17:15:36 -05:00
parent f792513151
commit f56ab5dc7e
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 3 deletions

View File

@ -80,11 +80,12 @@ class Label(
updateIntrinsicContentSize(false)
}
private fun updateIntrinsicContentSize(canWrap: Boolean): Boolean {
private fun updateIntrinsicContentSize(canWrap: Boolean, isFromDidLayout: Boolean = false): Boolean {
if (RenderHelper.disabled) return false
val oldSize = intrinsicContentSize
if (wrappingMode == WrappingMode.WRAP && canWrap && hasSolver) {
// don't wrap until we've laid out without wrapping to ensure the current bounds reflect the maximum available space
if (wrappingMode == WrappingMode.WRAP && canWrap && hasSolver && isFromDidLayout) {
val lines = textRenderer.wrapLines(text, bounds.width.toInt())
val height = (if (maxLines == 0) lines.size else min(lines.size, maxLines)) * textRenderer.fontHeight
intrinsicContentSize = Size(bounds.width, height.toDouble())
@ -120,7 +121,7 @@ class Label(
super.didLayout()
computeLines()
if (updateIntrinsicContentSize(true)) {
if (updateIntrinsicContentSize(true, true)) {
// if the intrinsic content size changes, relayout
window!!.layout()
}