diff options
author | alberth <alberth@openttd.org> | 2010-07-26 13:08:48 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-07-26 13:08:48 +0000 |
commit | 4203e641f8a507c017d10bf40f2c3882ce596da5 (patch) | |
tree | 883a2b182b8594de0b2048900956281c4efff861 /src/vehicle_gui.cpp | |
parent | 97f85f7bfba286bf9a7c692b390eec8231cac9ae (diff) | |
download | openttd-4203e641f8a507c017d10bf40f2c3882ce596da5.tar.xz |
(svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget().
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r-- | src/vehicle_gui.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 3650bd9a3..527068da1 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -528,11 +528,8 @@ struct RefitWindow : public Window { { switch (widget) { case VRW_MATRIX: { // listbox - int y = pt.y - this->GetWidget<NWidgetBase>(VRW_MATRIX)->pos_y; - if (y >= 0) { - this->sel = (y / (int)this->resize.step_height) + this->vscroll.GetPosition(); - this->InvalidateData(1); - } + this->sel = this->vscroll.GetScrolledRowFromWidget(pt.y, this, VRW_MATRIX); + this->InvalidateData(1); if (click_count == 1) break; } @@ -1213,13 +1210,8 @@ public: return; case VLW_WIDGET_LIST: { // Matrix to show vehicles - uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(VLW_WIDGET_LIST)->pos_y) / this->resize.step_height; const Vehicle *v; - - if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds - - id_v += this->vscroll.GetPosition(); - + uint id_v = this->vscroll.GetScrolledRowFromWidget(pt.y, this, VLW_WIDGET_LIST); if (id_v >= this->vehicles.Length()) return; // click out of list bound v = this->vehicles[id_v]; |