diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index b78c4c0e95..561c390111 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1836,8 +1836,8 @@ public: void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); - this->hscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); + this->vscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST, WidgetDimensions::scaled.framerect.Vertical()); + this->hscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST, WidgetDimensions::scaled.framerect.Horizontal()); } void OnEditboxChanged(WidgetID wid) override @@ -3178,7 +3178,7 @@ struct IndustryCargoesWindow : public Window { void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL, WidgetDimensions::scaled.framerect.top + CargoesField::small_height); + this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL, WidgetDimensions::scaled.framerect.Vertical() + CargoesField::small_height); } }; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 10bc174323..854e32ae44 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -796,8 +796,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_NS_FILE_LIST); - this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST); + this->vscroll->SetCapacityFromWidget(this, WID_NS_FILE_LIST, WidgetDimensions::scaled.framerect.Vertical()); + this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST, WidgetDimensions::scaled.framerect.Vertical()); } void SetStringParameters(WidgetID widget) const override @@ -1027,7 +1027,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_FILE_LIST: { // Select an active GRF. ResetObjectToPlace(); - uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST); + uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST, WidgetDimensions::scaled.framerect.top); GRFConfig *c; for (c = this->actives; c != nullptr && i > 0; c = c->next, i--) {} @@ -1090,7 +1090,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { case WID_NS_AVAIL_LIST: { // Select a non-active GRF. ResetObjectToPlace(); - auto it = this->vscroll2->GetScrolledItemFromWidget(this->avails, pt.y, this, WID_NS_AVAIL_LIST); + auto it = this->vscroll2->GetScrolledItemFromWidget(this->avails, pt.y, this, WID_NS_AVAIL_LIST, WidgetDimensions::scaled.framerect.top); this->active_sel = nullptr; CloseWindowByClass(WC_GRF_PARAMETERS); if (it != this->avails.end()) { @@ -1385,7 +1385,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { for (from_prev = &this->actives; *from_prev != this->active_sel; from_prev = &(*from_prev)->next, from_pos++) {} /* Gets the drag-and-drop destination offset. Ignore the last dummy line. */ - int to_pos = std::min(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST), this->vscroll->GetCount() - 2); + int to_pos = std::min(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST, WidgetDimensions::scaled.framerect.top), this->vscroll->GetCount() - 2); if (to_pos != from_pos) { // Don't move NewGRF file over itself. /* Get pointer to destination position. */ GRFConfig **to_prev = &this->actives; @@ -1403,7 +1403,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->InvalidateData(); } } else if (this->avail_sel != nullptr) { - int to_pos = std::min(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST), this->vscroll->GetCount() - 1); + int to_pos = std::min(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST, WidgetDimensions::scaled.framerect.top), this->vscroll->GetCount() - 1); this->AddGRFToActive(to_pos); } } else if (widget == WID_NS_AVAIL_LIST && this->active_sel != nullptr) { @@ -1427,7 +1427,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { if (widget == WID_NS_FILE_LIST && (this->active_sel != nullptr || this->avail_sel != nullptr)) { /* An NewGRF file is dragged over the active list. */ - int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST); + int to_pos = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NS_FILE_LIST, WidgetDimensions::scaled.framerect.top); /* Skip the last dummy line if the source is from the active list. */ to_pos = std::min(to_pos, this->vscroll->GetCount() - (this->active_sel != nullptr ? 2 : 1)); @@ -2167,7 +2167,7 @@ struct SavePresetWindow : public Window { void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_SVP_PRESET_LIST); + this->vscroll->SetCapacityFromWidget(this, WID_SVP_PRESET_LIST, WidgetDimensions::scaled.framerect.Vertical()); } }; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 172e0a1847..c5aedecbf6 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -1165,7 +1165,7 @@ struct MessageHistoryWindow : Window { * could be invalid, so ensure it's correct now. Potentially this means that item clicked on might be * different as well. */ this->vscroll->SetCount(std::size(_news)); - auto ni = this->vscroll->GetScrolledItemFromWidget(_news, pt.y, this, widget); + auto ni = this->vscroll->GetScrolledItemFromWidget(_news, pt.y, this, widget, WidgetDimensions::scaled.framerect.top); if (ni == std::end(_news)) return; ShowNewsMessage(ni); @@ -1174,7 +1174,7 @@ struct MessageHistoryWindow : Window { void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_MH_BACKGROUND); + this->vscroll->SetCapacityFromWidget(this, WID_MH_BACKGROUND, WidgetDimensions::scaled.framerect.Vertical()); } }; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index e83847811e..bc914f029c 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1586,7 +1586,7 @@ public: void OnResize() override { /* Update the scroll bar */ - this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST); + this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST, WidgetDimensions::scaled.framerect.Vertical()); } static inline HotkeyList hotkeys{"order", { diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 88da1556b8..a4ee798adf 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -1192,7 +1192,7 @@ struct ScriptDebugWindow : public Window { void OnResize() override { this->vscroll->SetCapacityFromWidget(this, WID_SCRD_LOG_PANEL, WidgetDimensions::scaled.framerect.Vertical()); - this->hscroll->SetCapacityFromWidget(this, WID_SCRD_LOG_PANEL); + this->hscroll->SetCapacityFromWidget(this, WID_SCRD_LOG_PANEL, WidgetDimensions::scaled.framerect.Horizontal()); } /** diff --git a/src/station_gui.cpp b/src/station_gui.cpp index c719dbfbb6..ffd2e31eef 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -581,7 +581,7 @@ public: { switch (widget) { case WID_STL_LIST: { - auto it = this->vscroll->GetScrolledItemFromWidget(this->stations, pt.y, this, WID_STL_LIST); + auto it = this->vscroll->GetScrolledItemFromWidget(this->stations, pt.y, this, WID_STL_LIST, WidgetDimensions::scaled.framerect.top); if (it == this->stations.end()) return; // click out of list bound const Station *st = *it; diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index a7975f84bd..07ca2ad7b4 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -235,7 +235,7 @@ struct SubsidyListWindow : Window { void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_SUL_PANEL); + this->vscroll->SetCapacityFromWidget(this, WID_SUL_PANEL, WidgetDimensions::scaled.framerect.Vertical()); } /** diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index d827578dc8..3fca83d0f0 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -587,7 +587,7 @@ void TextfileWindow::AfterLoadMarkdown() /* virtual */ void TextfileWindow::OnResize() { this->vscroll->SetCapacityFromWidget(this, WID_TF_BACKGROUND, WidgetDimensions::scaled.frametext.Vertical()); - this->hscroll->SetCapacityFromWidget(this, WID_TF_BACKGROUND); + this->hscroll->SetCapacityFromWidget(this, WID_TF_BACKGROUND, WidgetDimensions::scaled.framerect.Horizontal()); this->SetupScrollbars(false); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index b46b7fc9cb..7abd187417 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -996,7 +996,7 @@ public: void OnResize() override { - this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST); + this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST, WidgetDimensions::scaled.framerect.Vertical()); } void OnEditboxChanged(WidgetID wid) override