diff options
-rw-r--r-- | src/ai/ai_gui.cpp | 5 | ||||
-rw-r--r-- | src/company_gui.cpp | 2 | ||||
-rw-r--r-- | src/framerate_gui.cpp | 2 | ||||
-rw-r--r-- | src/graph_gui.cpp | 2 | ||||
-rw-r--r-- | src/group_gui.cpp | 8 | ||||
-rw-r--r-- | src/news_gui.cpp | 2 | ||||
-rw-r--r-- | src/rail_gui.cpp | 2 | ||||
-rw-r--r-- | src/station_gui.cpp | 4 | ||||
-rw-r--r-- | src/widget.cpp | 5 | ||||
-rw-r--r-- | src/widget_type.h | 2 |
10 files changed, 17 insertions, 17 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 14fc65cc8..49e37621e 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -190,7 +190,7 @@ struct AIListWindow : public Window { { switch (widget) { case WID_AIL_LIST: { // Select one of the AIs - int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_AIL_LIST, 0, this->line_height) - 1; + int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_AIL_LIST) - 1; if (sel < (int)this->info_list->size()) { this->selected = sel; this->SetDirty(); @@ -784,6 +784,7 @@ struct AIConfigWindow : public Window { case WID_AIC_LIST: this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; + resize->height = this->line_height; size->height = 8 * this->line_height; break; @@ -895,7 +896,7 @@ struct AIConfigWindow : public Window { } case WID_AIC_LIST: { // Select a slot - this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height); + this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget); this->InvalidateData(); if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot); break; diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 29701b514..2fe20d135 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -956,7 +956,7 @@ public: break; case WID_SCL_MATRIX: { - uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCL_MATRIX, 0, this->line_height); + uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCL_MATRIX); if (row >= this->rows) return; if (this->livery_class < LC_GROUP_RAIL) { diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 9ac78dc68..a2fd03044 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -683,7 +683,7 @@ struct FramerateWindow : Window { case WID_FRW_TIMES_AVERAGE: { /* Open time graph windows when clicking detail measurement lines */ const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR); - int line = sb->GetScrolledRowFromWidget(pt.y - FONT_HEIGHT_NORMAL - VSPACING, this, widget, VSPACING, FONT_HEIGHT_NORMAL); + int line = sb->GetScrolledRowFromWidget(pt.y, this, widget, VSPACING + FONT_HEIGHT_NORMAL); if (line != INT_MAX) { line++; /* Find the visible line that was clicked */ diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 5b04592bf..67399c327 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -992,7 +992,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } case WID_CPR_MATRIX: { - uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CPR_MATRIX, 0, this->line_height); + uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CPR_MATRIX); if (row >= this->vscroll->GetCount()) return; const CargoSpec *cs; diff --git a/src/group_gui.cpp b/src/group_gui.cpp index a8b4c5f17..372053304 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -676,7 +676,7 @@ public: break; case WID_GL_LIST_GROUP: { // Matrix Group - uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); + uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP); if (id_g >= this->groups.size()) return; if (groups[id_g]->folded || (id_g + 1 < this->groups.size() && this->indents[id_g + 1] > this->indents[id_g])) { @@ -822,7 +822,7 @@ public: break; case WID_GL_LIST_GROUP: { // Matrix group - uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); + uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP); GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index; if (this->group_sel != new_g && g->parent != new_g) { @@ -855,7 +855,7 @@ public: this->group_over = INVALID_GROUP; this->SetDirty(); - uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); + uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP); GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index; DoCommandP(0, new_g, vindex | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr); @@ -996,7 +996,7 @@ public: break; case WID_GL_LIST_GROUP: { // ... the list of custom groups. - uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height); + uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP); new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index; break; } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 74c9bbbec..fdcb56a37 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -1205,7 +1205,7 @@ struct MessageHistoryWindow : Window { NewsItem *ni = _latest_news; if (ni == nullptr) return; - for (int n = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_MH_BACKGROUND, WD_FRAMERECT_TOP, this->line_height); n > 0; n--) { + for (int n = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_MH_BACKGROUND, WD_FRAMERECT_TOP); n > 0; n--) { ni = ni->prev; if (ni == nullptr) return; } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 6956d0e04..f0f5becca 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1464,7 +1464,7 @@ public: break; case WID_BRAS_NEWST_LIST: { - int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST, 0, this->line_height); + int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST); if (y >= (int)this->station_classes.size()) return; StationClassID station_class_id = this->station_classes[y]; if (_railstation.station_class != station_class_id) { diff --git a/src/station_gui.cpp b/src/station_gui.cpp index b4156261b..d21ba5f73 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -529,7 +529,7 @@ public: { switch (widget) { case WID_STL_LIST: { - uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL); + uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST); if (id_v >= this->stations.size()) return; // click out of list bound const Station *st = this->stations[id_v]; @@ -1906,7 +1906,7 @@ struct StationViewWindow : public Window { { switch (widget) { case WID_SV_WAITING: - this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL) - this->vscroll->GetPosition()); + this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WD_FRAMERECT_TOP) - this->vscroll->GetPosition()); break; case WID_SV_CATCHMENT: diff --git a/src/widget.cpp b/src/widget.cpp index 4be4cf331..123e8a2f9 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1964,12 +1964,11 @@ void NWidgetViewport::UpdateViewportCoordinates(Window *w) * @param w The window the click was in. * @param widget Widget number of the widget clicked in. * @param padding Amount of empty space between the widget edge and the top of the first row. Default value is \c 0. - * @param line_height Height of a single row. A negative value means using the vertical resize step of the widget. * @return Row number clicked at. If clicked at a wrong position, #INT_MAX is returned. */ -int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding, int line_height) const +int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding) const { - uint pos = w->GetRowFromWidget(clickpos, widget, padding, line_height); + uint pos = w->GetRowFromWidget(clickpos, widget, padding, -1); if (pos != INT_MAX) pos += this->GetPosition(); return (pos >= this->GetCount()) ? INT_MAX : pos; } diff --git a/src/widget_type.h b/src/widget_type.h index c88727a2f..a5b323b87 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -748,7 +748,7 @@ public: } } - int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const; + int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0) const; EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const; }; |