summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-13 20:23:48 +0000
committerrubidium <rubidium@openttd.org>2009-11-13 20:23:48 +0000
commit2b5154f0a23d59a856a001895f90c621c2152f5a (patch)
treed6f3b83a39121561ab71621d69a69294c47d50a0 /src
parent7288ef506e35fd20f1485ebd10c96f3476f58f39 (diff)
downloadopenttd-2b5154f0a23d59a856a001895f90c621c2152f5a.tar.xz
(svn r18065) -Codechange/Fix: account for the text in WWT_FRAMEs when determining the minimum width
Diffstat (limited to 'src')
-rw-r--r--src/widget.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index c069970fb..21a3fc1f8 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1722,13 +1722,21 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
this->fill_y = this->child->fill_y;
this->resize_x = this->child->resize_x;
this->resize_y = this->child->resize_y;
+
+ /* Account for the size of the frame's text if that exists */
+ if (w != NULL && this->type == WWT_FRAME) {
+ 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);
+ }
} else {
Dimension d = {this->min_x, this->min_y};
Dimension resize = {this->resize_x, this->resize_y};
if (w != NULL) { // A non-NULL window pointer acts as switch to turn dynamic widget size on.
if (this->type == WWT_FRAME || this->type == WWT_INSET) {
if (this->index >= 0) w->SetStringParameters(this->index);
- d = maxdim(d, GetStringBoundingBox(this->widget_data));
+ Dimension background = GetStringBoundingBox(this->widget_data);
+ background.width += (this->type == WWT_FRAME) ? (WD_FRAMETEXT_LEFT + WD_FRAMERECT_RIGHT) : (WD_INSET_LEFT + WD_INSET_RIGHT);
+ d = maxdim(d, background);
}
if (this->index >= 0) {
static const Dimension padding = {0, 0};