summaryrefslogtreecommitdiff
path: root/src/widget.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-19 22:49:04 +0000
committerrubidium <rubidium@openttd.org>2009-11-19 22:49:04 +0000
commitda25f121ac8cfda351cade27380a9a96b774debc (patch)
tree549c3bbec8a247ecdd146a5ae6727f403181168d /src/widget.cpp
parente43659440e2653e0fe7acd29025063389cefacc6 (diff)
downloadopenttd-da25f121ac8cfda351cade27380a9a96b774debc.tar.xz
(svn r18195) -Codechange: move the child padding calculation/handling to WWT_FRAME
-Fix (r18168): crash when switching languages when a non-standard font height is used
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 82fecbfea..fe13d0bd5 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1461,16 +1461,16 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
/* Account for the size of the frame's text if that exists */
if (w != NULL && this->type == WWT_FRAME) {
+ this->child->padding_left = WD_FRAMETEXT_LEFT;
+ this->child->padding_right = WD_FRAMETEXT_RIGHT;
+ this->child->padding_top = max((int)WD_FRAMETEXT_TOP, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP / 2 : 0);
+ this->child->padding_bottom = WD_FRAMETEXT_BOTTOM;
+
+ this->smallest_x += this->child->padding_left + this->child->padding_right;
+ this->smallest_y += this->child->padding_top + this->child->padding_bottom;
+
if (this->index >= 0) w->SetStringParameters(this->index);
this->smallest_x = max(this->smallest_x, GetStringBoundingBox(this->widget_data).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
- if (this->widget_data != STR_NULL) {
- /* Adjust child's padding to fit text. We assume that the
- * original padding is designed around the 10 pixel high
- * sprite font. */
- int y = FONT_HEIGHT_NORMAL - 10;
- this->child->padding_top += y;
- this->smallest_y += y;
- }
}
} else {
Dimension d = {this->min_x, this->min_y};