changeset 17021:e3cc32cde2f8 draft

(svn r21758) -Add: Allow vertical resizing of the stationpicker window.
author alberth <alberth@openttd.org>
date Sun, 09 Jan 2011 15:34:00 +0000
parents 4cd0eec88007
children 9ffd66619632
files src/rail_gui.cpp
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -957,10 +957,10 @@
 	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 @@
 				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 @@
 				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 @@
 		}
 	}
 
+	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) {