changeset 15556:fd595e1074a2 draft

(svn r20216) -Fix: Increase scrolling speed of industry cargoes window, enlarge height slightly so small chains fit by default.
author alberth <alberth@openttd.org>
date Sun, 25 Jul 2010 12:38:06 +0000
parents c1c03be628a3
children 14828f61eda6
files src/industry_gui.cpp
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -1290,7 +1290,7 @@
 		NWidget(WWT_STICKYBOX, COLOUR_BROWN),
 	EndContainer(),
 	NWidget(NWID_HORIZONTAL),
-		NWidget(WWT_PANEL, COLOUR_BROWN, ICW_PANEL), SetResize(1, 1), SetMinimalSize(200, 90), EndContainer(),
+		NWidget(WWT_PANEL, COLOUR_BROWN, ICW_PANEL), SetResize(1, 10), SetMinimalSize(200, 90), EndContainer(),
 		NWidget(NWID_VERTICAL),
 			NWidget(WWT_SCROLLBAR, COLOUR_BROWN, ICW_SCROLLBAR),
 			NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
@@ -1300,7 +1300,7 @@
 
 /** Window description for the industry cargoes window. */
 static const WindowDesc _industry_cargoes_desc(
-	WDP_AUTO, 300, 200,
+	WDP_AUTO, 300, 210,
 	WC_INDUSTRY_CARGOES, WC_NONE,
 	0,
 	_nested_industry_cargoes_widgets, lengthof(_nested_industry_cargoes_widgets)
@@ -2147,7 +2147,8 @@
 
 		this->ShortenCargoColumn(1, 1, num_indrows);
 		this->ShortenCargoColumn(3, 1, num_indrows);
-		this->vscroll.SetCount(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height);
+		const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
+		this->vscroll.SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
 		this->SetDirty();
 	}
 
@@ -2210,7 +2211,8 @@
 		}
 
 		this->ShortenCargoColumn(1, 1, num_indrows);
-		this->vscroll.SetCount(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height);
+		const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
+		this->vscroll.SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
 		this->SetDirty();
 	}
 
@@ -2239,7 +2241,8 @@
 		if (this->ind_cargo >= NUM_INDUSTRYTYPES) left_pos += (CargoesField::industry_width + CargoesField::CARGO_FIELD_WIDTH) / 2;
 		int last_column = (this->ind_cargo < NUM_INDUSTRYTYPES) ? 4 : 2;
 
-		int vpos = -this->vscroll.GetPosition();
+		const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
+		int vpos = -this->vscroll.GetPosition() * nwp->resize_y;
 		for (uint i = 0; i < this->fields.Length(); i++) {
 			int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height;
 			if (vpos + row_height >= 0) {
@@ -2274,11 +2277,11 @@
 	 */
 	bool CalculatePositionInWidget(Point pt, Point *fieldxy, Point *xy)
 	{
-		NWidgetBase *nw = this->GetWidget<NWidgetBase>(ICW_PANEL);
+		const NWidgetBase *nw = this->GetWidget<NWidgetBase>(ICW_PANEL);
 		pt.x -= nw->pos_x;
 		pt.y -= nw->pos_y;
 
-		int vpos = WD_FRAMERECT_TOP + CargoesField::small_height - this->vscroll.GetPosition();
+		int vpos = WD_FRAMERECT_TOP + CargoesField::small_height - this->vscroll.GetPosition() * nw->resize_y;
 		if (pt.y < vpos) return false;
 
 		int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.