Fix: Don't include height of blank text in frame and inset widgets.

This commit is contained in:
Peter Nelson 2025-06-16 18:30:47 +01:00 committed by Peter Nelson
parent dd826ea49c
commit 7ec78e94db

View File

@ -2264,10 +2264,12 @@ void NWidgetBackground::SetupSmallestSize(Window *w)
if (w != nullptr) { // A non-nullptr window pointer acts as switch to turn dynamic widget size on. if (w != nullptr) { // A non-nullptr window pointer acts as switch to turn dynamic widget size on.
if (this->type == WWT_FRAME || this->type == WWT_INSET) { if (this->type == WWT_FRAME || this->type == WWT_INSET) {
std::string text = GetStringForWidget(w, this); std::string text = GetStringForWidget(w, this);
if (!text.empty()) {
Dimension background = GetStringBoundingBox(text, this->text_size); Dimension background = GetStringBoundingBox(text, this->text_size);
background.width += (this->type == WWT_FRAME) ? (WidgetDimensions::scaled.frametext.Horizontal()) : (WidgetDimensions::scaled.inset.Horizontal()); background.width += (this->type == WWT_FRAME) ? (WidgetDimensions::scaled.frametext.Horizontal()) : (WidgetDimensions::scaled.inset.Horizontal());
d = maxdim(d, background); d = maxdim(d, background);
} }
}
if (this->index >= 0) { if (this->index >= 0) {
Dimension padding; Dimension padding;
switch (this->type) { switch (this->type) {