diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index c39fd66c12..223c60073c 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(BRSW_SHOW_NEWST_ADDITIONS); newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE); newst_additions = this->GetWidget(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(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(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(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) {