Fix enum button label width not updating
This commit is contained in:
parent
f792513151
commit
f56ab5dc7e
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue