summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2014-10-05 16:43:44 +0000
committerpeter1138 <peter1138@openttd.org>2014-10-05 16:43:44 +0000
commitad287d2a2cfefef74e03ab841f9bccd6d2c95422 (patch)
tree8baf87a3f153a1efabce7795b59bfc2e2c57fbe9
parenta573b9486748c676eb58c58fb8c1408c8691afc2 (diff)
downloadopenttd-ad287d2a2cfefef74e03ab841f9bccd6d2c95422.tar.xz
(svn r26962) -Fix: Set up scrollbar size at the correct time (where it can be changed). Also ensure scrollbar is long enough to at least contain its buttons.
-rw-r--r--src/widget.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 2bd060535..5556756bb 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1989,17 +1989,27 @@ NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : N
{
assert(tp == NWID_HSCROLLBAR || tp == NWID_VSCROLLBAR);
this->SetIndex(index);
+}
+
+void NWidgetScrollbar::SetupSmallestSize(Window *w, bool init_array)
+{
+ if (init_array && this->index >= 0) {
+ assert(w->nested_array_size > (uint)this->index);
+ w->nested_array[this->index] = this;
+ }
+ this->min_x = 0;
+ this->min_y = 0;
switch (this->type) {
case NWID_HSCROLLBAR:
- this->SetMinimalSize(0, NWidgetScrollbar::GetHorizontalDimension().height);
+ this->SetMinimalSize(NWidgetScrollbar::GetHorizontalDimension().width * 3, NWidgetScrollbar::GetHorizontalDimension().height);
this->SetResize(1, 0);
this->SetFill(1, 0);
this->SetDataTip(0x0, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
break;
case NWID_VSCROLLBAR:
- this->SetMinimalSize(NWidgetScrollbar::GetVerticalDimension().width, 0);
+ this->SetMinimalSize(NWidgetScrollbar::GetVerticalDimension().width, NWidgetScrollbar::GetVerticalDimension().height * 3);
this->SetResize(0, 1);
this->SetFill(0, 1);
this->SetDataTip(0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST);
@@ -2007,14 +2017,7 @@ NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : N
default: NOT_REACHED();
}
-}
-void NWidgetScrollbar::SetupSmallestSize(Window *w, bool init_array)
-{
- if (init_array && this->index >= 0) {
- assert(w->nested_array_size > (uint)this->index);
- w->nested_array[this->index] = this;
- }
this->smallest_x = this->min_x;
this->smallest_y = this->min_y;
}