From 4203e641f8a507c017d10bf40f2c3882ce596da5 Mon Sep 17 00:00:00 2001 From: alberth Date: Mon, 26 Jul 2010 13:08:48 +0000 Subject: (svn r20223) -Codechange: Replace scrolled row calculations by a call to GetScrolledRowFromWidget(). --- src/vehicle_gui.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/vehicle_gui.cpp') 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(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(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]; -- cgit v1.2.3-54-g00ecf