summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2021-04-22 02:13:55 +0100
committerPeterN <peter@fuzzle.org>2021-04-30 17:08:15 +0100
commit6fe5353da2a0d3d60f8375b28536213e67cd869c (patch)
treefa9d6c634c6bdfee3c4fb2e56f985a35d93ad99b /src
parent03a43b824711898fe2c9f401a48fe2420d0abc28 (diff)
downloadopenttd-6fe5353da2a0d3d60f8375b28536213e67cd869c.tar.xz
Cleanup: Set unchanging scrollbar properties in constructor.
Diffstat (limited to 'src')
-rw-r--r--src/widget.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 931b525d4..aae1a5165 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -2108,6 +2108,22 @@ NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : N
{
assert(tp == NWID_HSCROLLBAR || tp == NWID_VSCROLLBAR);
this->SetIndex(index);
+
+ switch (this->type) {
+ case NWID_HSCROLLBAR:
+ this->SetResize(1, 0);
+ this->SetFill(1, 0);
+ this->SetDataTip(0x0, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST);
+ break;
+
+ case NWID_VSCROLLBAR:
+ this->SetResize(0, 1);
+ this->SetFill(0, 1);
+ this->SetDataTip(0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST);
+ break;
+
+ default: NOT_REACHED();
+ }
}
void NWidgetScrollbar::SetupSmallestSize(Window *w, bool init_array)
@@ -2122,16 +2138,10 @@ void NWidgetScrollbar::SetupSmallestSize(Window *w, bool init_array)
switch (this->type) {
case NWID_HSCROLLBAR:
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, NWidgetScrollbar::GetVerticalDimension().height * 3);
- this->SetResize(0, 1);
- this->SetFill(0, 1);
- this->SetDataTip(0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST);
break;
default: NOT_REACHED();