diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt index d11bf08a7..ff66c9979 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DynamicLabel.kt @@ -22,4 +22,13 @@ open class DynamicLabel( super.tickInner() text = textSupplier.get() } + + // reserve some extra space for text + override val textSizeDeterminationPadding: Float + get() = 14f + + override fun sizeToContents() { + text = textSupplier.get() + super.sizeToContents() + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt index 67cd388a6..b0d99bba3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Label.kt @@ -60,11 +60,14 @@ open class Label( } } + protected open val textSizeDeterminationPadding: Float + get() = 0f + override fun sizeToContents() { - val w = font.width(text) + val w = font.width(text) + textSizeDeterminationPadding val h = font.lineHeight + 2 - width = width.coerceAtLeast(w.toFloat()) + width = width.coerceAtLeast(w) height = height.coerceAtLeast(h.toFloat()) } }