From b59a6a53de8b5d15666e63ddd863d49984eebf2f Mon Sep 17 00:00:00 2001 From: alberth Date: Sun, 25 Jul 2010 12:38:06 +0000 Subject: (svn r20216) -Fix: Increase scrolling speed of industry cargoes window, enlarge height slightly so small chains fit by default. --- src/industry_gui.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index db3ad4071..50e6b8be4 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1290,7 +1290,7 @@ static const NWidgetPart _nested_industry_cargoes_widgets[] = { 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 @@ static const NWidgetPart _nested_industry_cargoes_widgets[] = { /** 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 @@ struct IndustryCargoesWindow : public Window { 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(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 @@ struct IndustryCargoesWindow : public Window { } 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(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 @@ struct IndustryCargoesWindow : public Window { 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(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 @@ struct IndustryCargoesWindow : public Window { */ bool CalculatePositionInWidget(Point pt, Point *fieldxy, Point *xy) { - NWidgetBase *nw = this->GetWidget(ICW_PANEL); + const NWidgetBase *nw = this->GetWidget(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. -- cgit v1.2.3-54-g00ecf