summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-01-09 15:34:00 +0000
committeralberth <alberth@openttd.org>2011-01-09 15:34:00 +0000
commit9d8496e65e84d47fd46980d04325cfbc04036b29 (patch)
tree24615f251c83b100d10b72b2d2b9582f3dfb3b96 /src
parent3281b91c48e088a28da942881eb8a3cdc61a3426 (diff)
downloadopenttd-9d8496e65e84d47fd46980d04325cfbc04036b29.tar.xz
(svn r21758) -Add: Allow vertical resizing of the stationpicker window.
Diffstat (limited to 'src')
-rw-r--r--src/rail_gui.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index c39fd66c1..223c60073 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -957,10 +957,10 @@ public:
BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(parent)
{
this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WD_PAR_VSEP_NORMAL;
+ this->vscroll = NULL;
_railstation.newstations = newstation;
this->CreateNestedTree(desc);
- this->vscroll = this->GetScrollbar(BRSW_NEWST_SCROLL);
NWidgetStacked *newst_additions = this->GetWidget<NWidgetStacked>(BRSW_SHOW_NEWST_ADDITIONS);
newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
newst_additions = this->GetWidget<NWidgetStacked>(BRSW_SHOW_NEWST_MATRIX);
@@ -995,6 +995,7 @@ public:
if (i == STAT_CLASS_WAYP) continue;
count++;
}
+ this->vscroll = this->GetScrollbar(BRSW_NEWST_SCROLL);
this->vscroll->SetCount(count);
this->vscroll->SetCapacity(GB(this->GetWidget<NWidgetCore>(BRSW_NEWST_LIST)->widget_data, MAT_ROW_START, MAT_ROW_BITS));
this->vscroll->SetPosition(Clamp(_railstation.station_class - 2, 0, max(this->vscroll->GetCount() - this->vscroll->GetCapacity(), 0)));
@@ -1073,6 +1074,7 @@ public:
size->width = max(size->width, d.width + padding.width);
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
size->height = GB(this->GetWidget<NWidgetCore>(widget)->widget_data, MAT_ROW_START, MAT_ROW_BITS) * this->line_height;
+ resize->height = this->line_height;
break;
}
@@ -1178,6 +1180,14 @@ public:
}
}
+ virtual void OnResize()
+ {
+ if (this->vscroll != NULL) { // New stations available.
+ this->vscroll->SetCapacityFromWidget(this, BRSW_NEWST_LIST);
+ this->GetWidget<NWidgetCore>(BRSW_NEWST_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
+ }
+ }
+
virtual void SetStringParameters(int widget) const
{
if (widget == BRSW_SHOW_NEWST_TYPE) {