From de4e00c93f971d985adfb7c3fa0448786b7453b0 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 9 Apr 2024 08:34:45 +0100 Subject: [PATCH] Codechange: Pass by reference to UpdateWidgetSize. (#12457) These parameters are always provided and not optional. --- src/ai/ai_gui.cpp | 8 +- src/airport_gui.cpp | 14 +-- src/autoreplace_gui.cpp | 22 ++--- src/bootstrap_gui.cpp | 16 ++-- src/bridge_gui.cpp | 12 +-- src/build_vehicle_gui.cpp | 30 +++---- src/cheat_gui.cpp | 6 +- src/company_gui.cpp | 130 ++++++++++++++-------------- src/date_gui.cpp | 4 +- src/depot_gui.cpp | 20 ++--- src/dock_gui.cpp | 6 +- src/dropdown.cpp | 4 +- src/engine_gui.cpp | 8 +- src/error_gui.cpp | 12 +-- src/fios_gui.cpp | 10 +-- src/framerate_gui.cpp | 36 ++++---- src/game/game_gui.cpp | 10 +-- src/genworld_gui.cpp | 30 +++---- src/goal_gui.cpp | 12 +-- src/graph_gui.cpp | 30 +++---- src/group_gui.cpp | 34 ++++---- src/industry_gui.cpp | 40 ++++----- src/intro_gui.cpp | 6 +- src/league_gui.cpp | 18 ++-- src/linkgraph/linkgraph_gui.cpp | 6 +- src/linkgraph/linkgraph_gui.h | 2 +- src/misc_gui.cpp | 40 ++++----- src/music_gui.cpp | 14 +-- src/network/network_content_gui.cpp | 22 ++--- src/network/network_content_gui.h | 2 +- src/network/network_gui.cpp | 80 ++++++++--------- src/newgrf_debug_gui.cpp | 22 ++--- src/newgrf_gui.cpp | 64 +++++++------- src/news_gui.cpp | 32 +++---- src/object_gui.cpp | 42 ++++----- src/order_gui.cpp | 10 +-- src/rail_gui.cpp | 50 +++++------ src/road_gui.cpp | 26 +++--- src/script/script_gui.cpp | 22 ++--- src/settings_gui.cpp | 30 +++---- src/signs_gui.cpp | 14 +-- src/station_gui.cpp | 30 +++---- src/statusbar_gui.cpp | 4 +- src/story_gui.cpp | 6 +- src/subsidy_gui.cpp | 6 +- src/terraform_gui.cpp | 6 +- src/textfile_gui.cpp | 8 +- src/textfile_gui.h | 2 +- src/timetable_gui.cpp | 12 +-- src/toolbar_gui.cpp | 6 +- src/town_gui.cpp | 36 ++++---- src/tree_gui.cpp | 6 +- src/vehicle_gui.cpp | 70 +++++++-------- src/widget.cpp | 8 +- src/window_gui.h | 8 +- 55 files changed, 602 insertions(+), 602 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 68c0e3d2e5..9bdf53a1de 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -128,20 +128,20 @@ struct AIConfigWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_AIC_DECREASE_NUMBER: case WID_AIC_INCREASE_NUMBER: case WID_AIC_DECREASE_INTERVAL: case WID_AIC_INCREASE_INTERVAL: - *size = maxdim(*size, NWidgetScrollbar::GetHorizontalDimension()); + size = maxdim(size, NWidgetScrollbar::GetHorizontalDimension()); break; case WID_AIC_LIST: this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; - resize->height = this->line_height; - size->height = 8 * this->line_height; + resize.height = this->line_height; + size.height = 8 * this->line_height; break; } } diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index a6e4109f59..3b346d2629 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -317,7 +317,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_AP_CLASS_DROPDOWN: { @@ -327,7 +327,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -336,11 +336,11 @@ public: const AirportSpec *as = AirportSpec::Get(i); if (!as->enabled) continue; - size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(as->name).width + padding.width); } this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; - size->height = 5 * this->line_height; + size.height = 5 * this->line_height; break; } @@ -354,7 +354,7 @@ public: Dimension d = GetSpriteSize(sprite); d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.height += WidgetDimensions::scaled.framerect.Vertical(); - *size = maxdim(d, *size); + size = maxdim(d, size); } } } @@ -368,8 +368,8 @@ public: StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT); if (string == STR_UNDEFINED) continue; - Dimension d = GetStringMultiLineBoundingBox(string, *size); - *size = maxdim(d, *size); + Dimension d = GetStringMultiLineBoundingBox(string, size); + size = maxdim(d, size); } } break; diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 93f2ae7825..62e8b1e85e 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -316,26 +316,26 @@ public: this->sel_group = id_g; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_RV_LEFT_MATRIX: case WID_RV_RIGHT_MATRIX: - resize->height = GetEngineListHeight((VehicleType)this->window_number); - size->height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize->height; + resize.height = GetEngineListHeight((VehicleType)this->window_number); + size.height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize.height; break; case WID_RV_LEFT_DETAILS: case WID_RV_RIGHT_DETAILS: - size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; + size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; break; case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { @@ -346,7 +346,7 @@ public: d = maxdim(d, GetStringBoundingBox(str)); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -355,7 +355,7 @@ public: d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS)); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -364,7 +364,7 @@ public: d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED)); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -375,7 +375,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -386,7 +386,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -397,7 +397,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 3487998615..e2e0e37004 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -97,12 +97,12 @@ public: this->Window::Close(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_BEM_MESSAGE) { - *size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR); - size->width += WidgetDimensions::scaled.frametext.Horizontal(); - size->height += WidgetDimensions::scaled.frametext.Vertical(); + size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR); + size.width += WidgetDimensions::scaled.frametext.Horizontal(); + size.height += WidgetDimensions::scaled.frametext.Vertical(); } } @@ -211,7 +211,7 @@ public: this->Window::Close(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { /* We cache the button size. This is safe as no reinit can happen here. */ if (this->button_size.width == 0) { @@ -223,13 +223,13 @@ public: switch (widget) { case WID_BAFD_QUESTION: /* The question is twice as wide as the buttons, and determine the height based on the width. */ - size->width = this->button_size.width * 2; - size->height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size->width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical(); + size.width = this->button_size.width * 2; + size.height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size.width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical(); break; case WID_BAFD_YES: case WID_BAFD_NO: - *size = this->button_size; + size = this->button_size; break; } } diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 97f152457e..1eba99ddce 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -174,14 +174,14 @@ public: this->last_sorting = this->bridges.GetListing(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BBS_DROPDOWN_ORDER: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_BBS_DROPDOWN_CRITERIA: { @@ -191,7 +191,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_BBS_BRIDGE_LIST: { @@ -201,11 +201,11 @@ public: sprite_dim = maxdim(sprite_dim, GetScaledSpriteSize(bridge_data.spec->sprite)); text_dim = maxdim(text_dim, GetStringBoundingBox(GetBridgeSelectString(bridge_data))); } - resize->height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges. + resize.height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges. this->icon_width = sprite_dim.width; // Width of bridge icon. - size->width = this->icon_width + WidgetDimensions::scaled.hsep_normal + text_dim.width + padding.width; - size->height = 4 * resize->height; // Smallest bridge gui is 4 entries high in the matrix. + size.width = this->icon_width + WidgetDimensions::scaled.hsep_normal + text_dim.width + padding.width; + size.height = 4 * resize.height; // Smallest bridge gui is 4 entries high in the matrix. break; } } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 50244c24eb..db21d23c84 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1741,43 +1741,43 @@ struct BuildVehicleWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BV_LIST: - resize->height = GetEngineListHeight(this->vehicle_type); - size->height = 3 * resize->height; - size->width = std::max(size->width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width; + resize.height = GetEngineListHeight(this->vehicle_type); + size.height = 3 * resize.height; + size.width = std::max(size.width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width; break; case WID_BV_PANEL: - size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; + size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; break; case WID_BV_SORT_ASCENDING_DESCENDING: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_BV_CARGO_FILTER_DROPDOWN: - size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width); + size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width); break; case WID_BV_BUILD: - *size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type); - *size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type)); - size->width += padding.width; - size->height += padding.height; + size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type); + size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type)); + size.width += padding.width; + size.height += padding.height; break; case WID_BV_SHOW_HIDE: - *size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type); - *size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type)); - size->width += padding.width; - size->height += padding.height; + size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type); + size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type)); + size.width += padding.width; + size.height += padding.height; break; } } diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 394e7c5223..9bafd9120c 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -298,7 +298,7 @@ struct CheatWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_C_PANEL) return; @@ -339,8 +339,8 @@ struct CheatWindow : Window { this->line_height = std::max(this->icon.height, SETTING_BUTTON_HEIGHT); this->line_height = std::max(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical(); - size->width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH; - size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui); + size.width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH; + size.height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui); } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 3f81d4cfdc..c0a2ba6094 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -389,29 +389,29 @@ struct CompanyFinancesWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_CF_EXPS_CATEGORY: - size->width = GetMaxCategoriesWidth(); - size->height = GetTotalCategoriesHeight(); + size.width = GetMaxCategoriesWidth(); + size.height = GetTotalCategoriesHeight(); break; case WID_CF_EXPS_PRICE1: case WID_CF_EXPS_PRICE2: case WID_CF_EXPS_PRICE3: - size->height = GetTotalCategoriesHeight(); + size.height = GetTotalCategoriesHeight(); [[fallthrough]]; case WID_CF_BALANCE_VALUE: case WID_CF_LOAN_VALUE: case WID_CF_OWN_VALUE: SetDParamMaxValue(0, CompanyFinancesWindow::max_money); - size->width = std::max(GetStringBoundingBox(STR_FINANCES_NEGATIVE_INCOME).width, GetStringBoundingBox(STR_FINANCES_POSITIVE_INCOME).width) + padding.width; + size.width = std::max(GetStringBoundingBox(STR_FINANCES_NEGATIVE_INCOME).width, GetStringBoundingBox(STR_FINANCES_POSITIVE_INCOME).width) + padding.width; break; case WID_CF_INTEREST_RATE: - size->height = GetCharacterHeight(FS_NORMAL); + size.height = GetCharacterHeight(FS_NORMAL); break; } } @@ -718,7 +718,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SCL_SPACER_DROPDOWN: { @@ -736,7 +736,7 @@ public: } } - size->width = std::max(size->width, 5 + d.width + padding.width); + size.width = std::max(size.width, 5 + d.width + padding.width); break; } @@ -745,15 +745,15 @@ public: this->square = GetSpriteSize(SPR_SQUARE); this->line_height = std::max(this->square.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; - size->height = 5 * this->line_height; - resize->width = 1; - resize->height = this->line_height; + size.height = 5 * this->line_height; + resize.width = 1; + resize.height = this->line_height; break; } case WID_SCL_SEC_COL_DROPDOWN: if (!_loaded_newgrf_features.has_2CC) { - size->width = 0; + size.width = 0; break; } [[fallthrough]]; @@ -762,9 +762,9 @@ public: this->square = GetSpriteSize(SPR_SQUARE); int string_padding = this->square.width + WidgetDimensions::scaled.hsep_normal + padding.width; for (Colours colour = COLOUR_BEGIN; colour != COLOUR_END; colour++) { - size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DARK_BLUE + colour).width + string_padding); + size.width = std::max(size.width, GetStringBoundingBox(STR_COLOUR_DARK_BLUE + colour).width + string_padding); } - size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + string_padding); + size.width = std::max(size.width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + string_padding); break; } } @@ -1405,31 +1405,31 @@ public: this->number_dim = number_dim; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT: - *size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING)); - *size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE)); + size = maxdim(size, GetStringBoundingBox(STR_FACE_EARRING)); + size = maxdim(size, GetStringBoundingBox(STR_FACE_MOUSTACHE)); break; case WID_SCMF_TIE_EARRING_TEXT: - *size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING)); - *size = maxdim(*size, GetStringBoundingBox(STR_FACE_TIE)); + size = maxdim(size, GetStringBoundingBox(STR_FACE_EARRING)); + size = maxdim(size, GetStringBoundingBox(STR_FACE_TIE)); break; case WID_SCMF_LIPS_MOUSTACHE_TEXT: - *size = maxdim(*size, GetStringBoundingBox(STR_FACE_LIPS)); - *size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE)); + size = maxdim(size, GetStringBoundingBox(STR_FACE_LIPS)); + size = maxdim(size, GetStringBoundingBox(STR_FACE_MOUSTACHE)); break; case WID_SCMF_FACE: - *size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); + size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT)); break; case WID_SCMF_HAS_MOUSTACHE_EARRING: case WID_SCMF_HAS_GLASSES: - *size = this->yesno_dim; + size = this->yesno_dim; break; case WID_SCMF_EYECOLOUR: @@ -1442,7 +1442,7 @@ public: case WID_SCMF_COLLAR: case WID_SCMF_TIE_EARRING: case WID_SCMF_GLASSES: - *size = this->number_dim; + size = this->number_dim; break; } } @@ -1840,7 +1840,7 @@ struct CompanyInfrastructureWindow : Window } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { const Company *c = Company::Get((CompanyID)this->window_number); @@ -1848,20 +1848,20 @@ struct CompanyInfrastructureWindow : Window case WID_CI_RAIL_DESC: { uint lines = 1; // Starts at 1 because a line is also required for the section title - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width + padding.width); for (const auto &rt : _sorted_railtypes) { if (HasBit(this->railtypes, rt)) { lines++; - size->width = std::max(size->width, GetStringBoundingBox(GetRailTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent); + size.width = std::max(size.width, GetStringBoundingBox(GetRailTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent); } } if (this->railtypes != RAILTYPES_NONE) { lines++; - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); } - size->height = std::max(size->height, lines * GetCharacterHeight(FS_NORMAL)); + size.height = std::max(size.height, lines * GetCharacterHeight(FS_NORMAL)); break; } @@ -1869,28 +1869,28 @@ struct CompanyInfrastructureWindow : Window case WID_CI_TRAM_DESC: { uint lines = 1; // Starts at 1 because a line is also required for the section title - size->width = std::max(size->width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width + padding.width); for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) { lines++; - size->width = std::max(size->width, GetStringBoundingBox(GetRoadTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent); + size.width = std::max(size.width, GetStringBoundingBox(GetRoadTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent); } } - size->height = std::max(size->height, lines * GetCharacterHeight(FS_NORMAL)); + size.height = std::max(size.height, lines * GetCharacterHeight(FS_NORMAL)); break; } case WID_CI_WATER_DESC: - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT).width + padding.width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); break; case WID_CI_STATION_DESC: - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT).width + padding.width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS).width + padding.width + WidgetDimensions::scaled.hsep_indent); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS).width + padding.width + WidgetDimensions::scaled.hsep_indent); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS).width + padding.width + WidgetDimensions::scaled.hsep_indent); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS).width + padding.width + WidgetDimensions::scaled.hsep_indent); break; case WID_CI_RAIL_COUNT: @@ -1930,17 +1930,17 @@ struct CompanyInfrastructureWindow : Window StringID str_total = TimerGameEconomy::UsingWallclockUnits() ? STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD : STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR; SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year this->total_width = GetStringBoundingBox(str_total).width + WidgetDimensions::scaled.hsep_indent * 2; - size->width = std::max(size->width, this->total_width); + size.width = std::max(size.width, this->total_width); SetDParamMaxValue(0, max_cost * 12); // Convert to per year count_width += std::max(this->total_width, GetStringBoundingBox(str_total).width); } - size->width = std::max(size->width, count_width); + size.width = std::max(size.width, count_width); /* Set height of the total line. */ if (widget == WID_CI_TOTAL) { - size->height = _settings_game.economy.infrastructure_maintenance ? std::max(size->height, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL)) : 0; + size.height = _settings_game.economy.infrastructure_maintenance ? std::max(size.height, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL)) : 0; } break; } @@ -2249,11 +2249,11 @@ struct CompanyWindow : Window this->DrawWidgets(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_C_FACE: - *size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); + size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT)); break; case WID_C_DESC_COLOUR_SCHEME_EXAMPLE: { @@ -2261,31 +2261,31 @@ struct CompanyWindow : Window Dimension d = GetSpriteSize(SPR_VEH_BUS_SW_VIEW, &offset); d.width -= offset.x; d.height -= offset.y; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_C_DESC_COMPANY_VALUE: SetDParam(0, INT64_MAX); // Arguably the maximum company value - size->width = GetStringBoundingBox(STR_COMPANY_VIEW_COMPANY_VALUE).width; + size.width = GetStringBoundingBox(STR_COMPANY_VIEW_COMPANY_VALUE).width; break; case WID_C_DESC_VEHICLE_COUNTS: SetDParamMaxValue(0, 5000); // Maximum number of vehicles for (uint i = 0; i < lengthof(_company_view_vehicle_count_strings); i++) { - size->width = std::max(size->width, GetStringBoundingBox(_company_view_vehicle_count_strings[i]).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(_company_view_vehicle_count_strings[i]).width + padding.width); } break; case WID_C_DESC_INFRASTRUCTURE_COUNTS: SetDParamMaxValue(0, UINT_MAX); - size->width = GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL).width; - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_WATER).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_STATION).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_NONE).width); - size->width += padding.width; + size.width = GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL).width; + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_WATER).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_STATION).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_NONE).width); + size.width += padding.width; break; case WID_C_VIEW_HQ: @@ -2296,19 +2296,19 @@ struct CompanyWindow : Window case WID_C_HOSTILE_TAKEOVER: case WID_C_COMPANY_PASSWORD: case WID_C_COMPANY_JOIN: - size->width = GetStringBoundingBox(STR_COMPANY_VIEW_VIEW_HQ_BUTTON).width; - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_BUILD_HQ_BUTTON).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_RELOCATE_HQ).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_GIVE_MONEY_BUTTON).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_PASSWORD).width); - size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_JOIN).width); - size->width += padding.width; + size.width = GetStringBoundingBox(STR_COMPANY_VIEW_VIEW_HQ_BUTTON).width; + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_BUILD_HQ_BUTTON).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_RELOCATE_HQ).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_GIVE_MONEY_BUTTON).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_PASSWORD).width); + size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_JOIN).width); + size.width += padding.width; break; case WID_C_HAS_PASSWORD: - if (_networking) *size = maxdim(*size, GetSpriteSize(SPR_LOCK)); + if (_networking) size = maxdim(size, GetSpriteSize(SPR_LOCK)); break; } } @@ -2622,18 +2622,18 @@ struct BuyCompanyWindow : Window { this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BC_FACE: - *size = GetScaledSpriteSize(SPR_GRADIENT); + size = GetScaledSpriteSize(SPR_GRADIENT); break; case WID_BC_QUESTION: const Company *c = Company::Get((CompanyID)this->window_number); SetDParam(0, c->index); SetDParam(1, this->company_value); - size->height = GetStringHeight(this->hostile_takeover ? STR_BUY_COMPANY_HOSTILE_TAKEOVER : STR_BUY_COMPANY_MESSAGE, size->width); + size.height = GetStringHeight(this->hostile_takeover ? STR_BUY_COMPANY_HOSTILE_TAKEOVER : STR_BUY_COMPANY_MESSAGE, size.width); break; } } diff --git a/src/date_gui.cpp b/src/date_gui.cpp index 57b2c076a8..7faad2acf2 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -100,7 +100,7 @@ struct SetDateWindow : Window { ShowDropDownList(this, std::move(list), selected, widget); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { Dimension d = {0, 0}; switch (widget) { @@ -126,7 +126,7 @@ struct SetDateWindow : Window { d.width += padding.width; d.height += padding.height; - *size = d; + size = d; } void SetStringParameters(WidgetID widget) const override diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index ec1595460a..74d58bc415 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -653,7 +653,7 @@ struct DepotWindow : Window { this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING)); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_D_MATRIX: { @@ -679,18 +679,18 @@ struct DepotWindow : Window { } int base_width = this->count_width + this->header_width + padding.width; - resize->height = std::max(this->cell_size.height, min_height + padding.height); + resize.height = std::max(this->cell_size.height, min_height + padding.height); if (this->type == VEH_TRAIN) { - resize->width = 1; - size->width = base_width + 2 * ScaleSpriteTrad(29); // about 2 parts - size->height = resize->height * 6; + resize.width = 1; + size.width = base_width + 2 * ScaleSpriteTrad(29); // about 2 parts + size.height = resize.height * 6; } else { - resize->width = base_width + this->cell_size.extend_left + this->cell_size.extend_right; - size->width = resize->width * (this->type == VEH_ROAD ? 5 : 3); - size->height = resize->height * (this->type == VEH_ROAD ? 5 : 3); + resize.width = base_width + this->cell_size.extend_left + this->cell_size.extend_right; + size.width = resize.width * (this->type == VEH_ROAD ? 5 : 3); + size.height = resize.height * (this->type == VEH_ROAD ? 5 : 3); } - fill->width = resize->width; - fill->height = resize->height; + fill.width = resize.width; + fill.height = resize.height; break; } } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index e0d500fdf8..fec4024a3a 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -529,13 +529,13 @@ public: UpdateDocksDirection(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BDD_X: case WID_BDD_Y: - size->width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical(); break; } } diff --git a/src/dropdown.cpp b/src/dropdown.cpp index 292d524132..6366090b88 100644 --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -210,9 +210,9 @@ struct DropdownWindow : Window { if (this->position.y < button_rect.top && list_dim.height > widget_dim.height) this->vscroll->UpdatePosition(INT_MAX); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { - if (widget == WID_DM_ITEMS) *size = this->items_dim; + if (widget == WID_DM_ITEMS) size = this->items_dim; } Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index b24f902363..172b22f507 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -78,7 +78,7 @@ struct EnginePreviewWindow : Window { this->flags |= WF_STICKY; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_EP_QUESTION) return; @@ -98,11 +98,11 @@ struct EnginePreviewWindow : Window { } this->vehicle_space = std::max(ScaleSpriteTrad(40), y - y_offs); - size->width = std::max(size->width, x + std::abs(x_offs)); + size.width = std::max(size.width, x + std::abs(x_offs)); SetDParam(0, GetEngineCategoryName(engine)); - size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space; + size.height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size.width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space; SetDParam(0, engine); - size->height += GetStringHeight(GetEngineInfoString(engine), size->width); + size.height += GetStringHeight(GetEngineInfoString(engine), size.width); } void DrawWidget(const Rect &r, WidgetID widget) const override diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 412864226c..e702cdf133 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -189,16 +189,16 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_EM_MESSAGE: { CopyInDParam(this->params); if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack); - this->height_summary = GetStringHeight(this->summary_msg, size->width); - this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, size->width); - this->height_extra = (this->extra_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->extra_msg, size->width); + this->height_summary = GetStringHeight(this->summary_msg, size.width); + this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, size.width); + this->height_extra = (this->extra_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->extra_msg, size.width); if (this->textref_stack_size > 0) StopTextRefStackUsage(); @@ -206,11 +206,11 @@ public: if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide; if (this->extra_msg != INVALID_STRING_ID) panel_height += this->height_extra + WidgetDimensions::scaled.vsep_wide; - size->height = std::max(size->height, panel_height); + size.height = std::max(size.height, panel_height); break; } case WID_EM_FACE: - *size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); + size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT)); break; } } diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index c986b4eff6..58bfbe627f 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -561,23 +561,23 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SL_BACKGROUND: - size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; + size.height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; break; case WID_SL_DRIVES_DIRECTORIES_LIST: - resize->height = GetCharacterHeight(FS_NORMAL); - size->height = resize->height * 10 + padding.height; + resize.height = GetCharacterHeight(FS_NORMAL); + size.height = resize.height * 10 + padding.height; break; case WID_SL_SORT_BYNAME: case WID_SL_SORT_BYDATE: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index dc5698791d..ea1bd9e4dc 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -540,32 +540,32 @@ struct FramerateWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_FRW_RATE_GAMELOOP: SetDParam(0, STR_FRAMERATE_FPS_GOOD); SetDParam(1, 999999); SetDParam(2, 2); - *size = GetStringBoundingBox(STR_FRAMERATE_RATE_GAMELOOP); + size = GetStringBoundingBox(STR_FRAMERATE_RATE_GAMELOOP); break; case WID_FRW_RATE_DRAWING: SetDParam(0, STR_FRAMERATE_FPS_GOOD); SetDParam(1, 999999); SetDParam(2, 2); - *size = GetStringBoundingBox(STR_FRAMERATE_RATE_BLITTER); + size = GetStringBoundingBox(STR_FRAMERATE_RATE_BLITTER); break; case WID_FRW_RATE_FACTOR: SetDParam(0, 999999); SetDParam(1, 2); - *size = GetStringBoundingBox(STR_FRAMERATE_SPEED_FACTOR); + size = GetStringBoundingBox(STR_FRAMERATE_SPEED_FACTOR); break; case WID_FRW_TIMES_NAMES: { - size->width = 0; - size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * GetCharacterHeight(FS_NORMAL); - resize->width = 0; - resize->height = GetCharacterHeight(FS_NORMAL); + size.width = 0; + size.height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * GetCharacterHeight(FS_NORMAL); + resize.width = 0; + resize.height = GetCharacterHeight(FS_NORMAL); for (PerformanceElement e : DISPLAY_ORDER_PFE) { if (_pf_data[e].num_valid == 0) continue; Dimension line_size; @@ -576,7 +576,7 @@ struct FramerateWindow : Window { SetDParamStr(1, GetAIName(e - PFE_AI0)); line_size = GetStringBoundingBox(STR_FRAMERATE_AI); } - size->width = std::max(size->width, line_size.width); + size.width = std::max(size.width, line_size.width); } break; } @@ -584,14 +584,14 @@ struct FramerateWindow : Window { case WID_FRW_TIMES_CURRENT: case WID_FRW_TIMES_AVERAGE: case WID_FRW_ALLOCSIZE: { - *size = GetStringBoundingBox(STR_FRAMERATE_CURRENT + (widget - WID_FRW_TIMES_CURRENT)); + size = GetStringBoundingBox(STR_FRAMERATE_CURRENT + (widget - WID_FRW_TIMES_CURRENT)); SetDParam(0, 999999); SetDParam(1, 2); Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD); - size->width = std::max(size->width, item_size.width); - size->height += GetCharacterHeight(FS_NORMAL) * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal; - resize->width = 0; - resize->height = GetCharacterHeight(FS_NORMAL); + size.width = std::max(size.width, item_size.width); + size.height += GetCharacterHeight(FS_NORMAL) * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal; + resize.width = 0; + resize.height = GetCharacterHeight(FS_NORMAL); break; } } @@ -780,7 +780,7 @@ struct FrametimeGraphWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_FGW_GRAPH) { SetDParam(0, 100); @@ -792,10 +792,10 @@ struct FrametimeGraphWindow : Window { graph_size.height = std::max(100u, 10 * (size_ms_label.height + 1)); /* Always 2:1 graph area */ graph_size.width = 2 * graph_size.height; - *size = graph_size; + size = graph_size; - size->width += size_ms_label.width + 2; - size->height += size_s_label.height + 2; + size.width += size_ms_label.width + 2; + size.height += size_s_label.height + 2; } } diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index aae47f76e8..7ad4cd7b42 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -136,19 +136,19 @@ struct GSConfigWindow : public Window { this->vscroll->SetCount(this->visible_settings.size()); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_GSC_SETTINGS: this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; - resize->width = 1; - resize->height = this->line_height; - size->height = 5 * this->line_height; + resize.width = 1; + resize.height = this->line_height; + size.height = 5 * this->line_height; break; case WID_GSC_GSLIST: this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; - size->height = 1 * this->line_height; + size.height = 1 * this->line_height; break; } } diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 8c34d91f8e..e6942fe9c7 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -571,15 +571,15 @@ struct GenerateLandscapeWindow : public Window { } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)}; const StringID *strs = nullptr; switch (widget) { case WID_GL_TEMPERATE: case WID_GL_ARCTIC: case WID_GL_TROPICAL: case WID_GL_TOYLAND: - size->width += WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height += WidgetDimensions::scaled.fullbevel.Vertical(); + size.width += WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height += WidgetDimensions::scaled.fullbevel.Vertical(); break; case WID_GL_HEIGHTMAP_HEIGHT_TEXT: @@ -654,7 +654,7 @@ struct GenerateLandscapeWindow : public Window { break; case WID_GL_HEIGHTMAP_NAME_TEXT: - size->width = 0; + size.width = 0; break; default: @@ -667,7 +667,7 @@ struct GenerateLandscapeWindow : public Window { } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override @@ -1121,14 +1121,14 @@ struct CreateScenarioWindow : public Window this->DrawWidgets(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { StringID str = STR_JUST_INT; switch (widget) { case WID_CS_TEMPERATE: case WID_CS_ARCTIC: case WID_CS_TROPICAL: case WID_CS_TOYLAND: - size->width += WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height += WidgetDimensions::scaled.fullbevel.Vertical(); + size.width += WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height += WidgetDimensions::scaled.fullbevel.Vertical(); break; case WID_CS_START_DATE_TEXT: @@ -1151,7 +1151,7 @@ struct CreateScenarioWindow : public Window Dimension d = GetStringBoundingBox(str); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override @@ -1405,23 +1405,23 @@ struct GenerateProgressWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_GP_PROGRESS_BAR: { SetDParamMaxValue(0, 100); - *size = GetStringBoundingBox(STR_GENERATION_PROGRESS); + size = GetStringBoundingBox(STR_GENERATION_PROGRESS); /* We need some spacing for the 'border' */ - size->height += WidgetDimensions::scaled.frametext.Horizontal(); - size->width += WidgetDimensions::scaled.frametext.Vertical(); + size.height += WidgetDimensions::scaled.frametext.Horizontal(); + size.width += WidgetDimensions::scaled.frametext.Vertical(); break; } case WID_GP_PROGRESS_TEXT: for (uint i = 0; i < GWP_CLASS_COUNT; i++) { - size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width); } - size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; + size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; break; } } diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 033c6359e2..afbbd953d5 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -168,18 +168,18 @@ struct GoalListWindow : public Window { return num; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_GOAL_LIST) return; Dimension d = GetStringBoundingBox(STR_GOALS_NONE); - resize->width = 1; - resize->height = d.height; + resize.width = 1; + resize.height = d.height; d.height *= 5; d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.height += WidgetDimensions::scaled.framerect.Vertical(); - *size = maxdim(*size, d); + size = maxdim(size, d); } /** @@ -388,12 +388,12 @@ struct GoalQuestionWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_GQ_QUESTION) return; SetDParamStr(0, this->question); - size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width); + size.height = GetStringHeight(STR_JUST_RAW_STRING, size.width); } void DrawWidget(const Rect &r, WidgetID widget) const override diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index af2efd3722..01f6f4ad15 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -517,7 +517,7 @@ protected: } public: - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_GRAPH_GRAPH) return; @@ -548,9 +548,9 @@ public: SetDParam(1, INT64_MAX); uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width; - size->width = std::max(size->width, ScaleGUITrad(5) + y_label_width + this->num_vert_lines * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9)); - size->height = std::max(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4)); - size->height = std::max(size->height, size->width / 3); + size.width = std::max(size.width, ScaleGUITrad(5) + y_label_width + this->num_vert_lines * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9)); + size.height = std::max(size.height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4)); + size.height = std::max(size.height, size.width / 3); } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -990,14 +990,14 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); return; } - size->height = GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical(); + size.height = GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical(); for (const CargoSpec *cs : _sorted_standard_cargo_specs) { SetDParam(0, cs->name); @@ -1005,13 +1005,13 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { d.width += this->legend_width + WidgetDimensions::scaled.hsep_normal; // colour field d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.height += WidgetDimensions::scaled.framerect.Vertical(); - *size = maxdim(d, *size); + size = maxdim(d, size); } - this->line_height = size->height; - size->height = this->line_height * 11; /* Default number of cargo types in most climates. */ - resize->width = 0; - resize->height = this->line_height; + this->line_height = size.height; + size.height = this->line_height * 11; /* Default number of cargo types in most climates. */ + resize.width = 0; + resize.height = this->line_height; } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -1216,12 +1216,12 @@ struct PerformanceRatingDetailWindow : Window { uint score_detail_left; uint score_detail_right; - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_PRD_SCORE_FIRST: this->bar_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.Vertical(); - size->height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical(); + size.height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical(); uint score_info_width = 0; for (uint i = SCORE_BEGIN; i < SCORE_END; i++) { @@ -1257,9 +1257,9 @@ struct PerformanceRatingDetailWindow : Window { SetDParam(1, max); uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width; - size->width = WidgetDimensions::scaled.frametext.Horizontal() + score_info_width + WidgetDimensions::scaled.hsep_wide + this->bar_width + WidgetDimensions::scaled.hsep_wide + score_detail_width; + size.width = WidgetDimensions::scaled.frametext.Horizontal() + score_info_width + WidgetDimensions::scaled.hsep_wide + this->bar_width + WidgetDimensions::scaled.hsep_wide + score_detail_width; uint left = WidgetDimensions::scaled.frametext.left; - uint right = size->width - WidgetDimensions::scaled.frametext.right; + uint right = size.width - WidgetDimensions::scaled.frametext.right; bool rtl = _current_text_dir == TD_RTL; this->score_info_left = rtl ? right - score_info_width : left; diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 55bb30dd1e..c4b3998102 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -400,56 +400,56 @@ public: *this->sorting = this->vehgroups.GetListing(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_GL_LIST_GROUP: - size->width = this->ComputeGroupInfoSize(); - resize->height = this->tiny_step_height; - fill->height = this->tiny_step_height; + size.width = this->ComputeGroupInfoSize(); + resize.height = this->tiny_step_height; + fill.height = this->tiny_step_height; break; case WID_GL_ALL_VEHICLES: case WID_GL_DEFAULT_VEHICLES: - size->width = this->ComputeGroupInfoSize(); - size->height = this->tiny_step_height; + size.width = this->ComputeGroupInfoSize(); + size.height = this->tiny_step_height; break; case WID_GL_SORT_BY_ORDER: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_GL_LIST_VEHICLE: this->ComputeGroupInfoSize(); - resize->height = GetVehicleListHeight(this->vli.vtype, this->tiny_step_height); - size->height = 4 * resize->height; + resize.height = GetVehicleListHeight(this->vli.vtype, this->tiny_step_height); + size.height = 4 * resize.height; break; case WID_GL_GROUP_BY_DROPDOWN: - size->width = GetStringListWidth(this->vehicle_group_by_names) + padding.width; + size.width = GetStringListWidth(this->vehicle_group_by_names) + padding.width; break; case WID_GL_SORT_BY_DROPDOWN: - size->width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar); - size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock)); - size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar)); - size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock)); - size->width += padding.width; + size.width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar); + size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock)); + size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar)); + size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock)); + size.width += padding.width; break; case WID_GL_FILTER_BY_CARGO: - size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width); + size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width); break; case WID_GL_MANAGE_VEHICLES_DROPDOWN: { Dimension d = this->GetActionDropdownSize(true, true, true); d.height += padding.height; d.width += padding.width; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 711ee598f9..96d82325dc 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -423,7 +423,7 @@ public: this->SetupArrays(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_DPI_MATRIX_WIDGET: { @@ -431,10 +431,10 @@ public: for (const auto &indtype : this->list) { d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(indtype)->name)); } - resize->height = std::max(this->legend.height, GetCharacterHeight(FS_NORMAL)) + padding.height; + resize.height = std::max(this->legend.height, GetCharacterHeight(FS_NORMAL)) + padding.height; d.width += this->legend.width + WidgetDimensions::scaled.hsep_wide + padding.width; - d.height = 5 * resize->height; - *size = maxdim(*size, d); + d.height = 5 * resize.height; + size = maxdim(size, d); break; } @@ -478,8 +478,8 @@ public: /* Set it to something more sane :) */ height += extra_lines_prd + extra_lines_req + extra_lines_newgrf; - size->height = height * GetCharacterHeight(FS_NORMAL) + padding.height; - size->width = d.width + padding.width; + size.height = height * GetCharacterHeight(FS_NORMAL) + padding.height; + size.width = d.width + padding.width; break; } @@ -489,7 +489,7 @@ public: d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY)); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } @@ -1004,9 +1004,9 @@ public: if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { - if (widget == WID_IV_INFO) size->height = this->info_height; + if (widget == WID_IV_INFO) size.height = this->info_height; } void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override @@ -1720,14 +1720,14 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_ID_DROPDOWN_ORDER: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -1738,17 +1738,17 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_ID_INDUSTRY_LIST: { Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE); - resize->height = d.height; + resize.height = d.height; d.height *= 5; d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } @@ -2626,21 +2626,21 @@ struct IndustryCargoesWindow : public Window { CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_IC_PANEL: - resize->height = CargoesField::normal_height; - size->width = CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WidgetDimensions::scaled.frametext.Horizontal(); - size->height = CargoesField::small_height + 2 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); + resize.height = CargoesField::normal_height; + size.width = CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WidgetDimensions::scaled.frametext.Horizontal(); + size.height = CargoesField::small_height + 2 * resize.height + WidgetDimensions::scaled.frametext.Vertical(); break; case WID_IC_IND_DROPDOWN: - size->width = std::max(size->width, this->ind_textsize.width + padding.width); + size.width = std::max(size.width, this->ind_textsize.width + padding.width); break; case WID_IC_CARGO_DROPDOWN: - size->width = std::max(size->width, this->cargo_textsize.width + padding.width); + size.width = std::max(size.width, this->cargo_textsize.width + padding.width); break; } } diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 0e1d53c84c..32e6c2d34a 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -297,13 +297,13 @@ struct SelectGameWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE: case WID_SGI_TROPIC_LANDSCAPE: case WID_SGI_TOYLAND_LANDSCAPE: - size->width += WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height += WidgetDimensions::scaled.fullbevel.Vertical(); + size.width += WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height += WidgetDimensions::scaled.fullbevel.Vertical(); break; } } diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 3e9c5ca833..58b36c213b 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -129,7 +129,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_PLT_BACKGROUND) return; @@ -162,8 +162,8 @@ public: this->text_width = widest_width + WidgetDimensions::scaled.hsep_indent * 3; // Keep some extra spacing - size->width = WidgetDimensions::scaled.framerect.Horizontal() + this->ordinal_width + this->icon.width + this->text_width + WidgetDimensions::scaled.hsep_wide; - size->height = this->line_height * MAX_COMPANIES + WidgetDimensions::scaled.framerect.Vertical(); + size.width = WidgetDimensions::scaled.framerect.Horizontal() + this->ordinal_width + this->icon.width + this->text_width + WidgetDimensions::scaled.hsep_wide; + size.height = this->line_height * MAX_COMPANIES + WidgetDimensions::scaled.framerect.Vertical(); } void OnGameTick() override @@ -359,7 +359,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_SLT_BACKGROUND) return; @@ -385,18 +385,18 @@ public: if (!show_icon_column) this->icon_size.width = 0; else this->icon_size.width += WidgetDimensions::scaled.hsep_wide; - size->width = this->rank_width + this->icon_size.width + this->text_width + this->score_width + WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.hsep_wide * 2; - size->height = this->line_height * std::max(3u, (unsigned)this->rows.size()) + WidgetDimensions::scaled.framerect.Vertical(); + size.width = this->rank_width + this->icon_size.width + this->text_width + this->score_width + WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.hsep_wide * 2; + size.height = this->line_height * std::max(3u, (unsigned)this->rows.size()) + WidgetDimensions::scaled.framerect.Vertical(); if (!lt->header.empty()) { SetDParamStr(0, lt->header); - this->header_height = GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide; - size->height += header_height; + this->header_height = GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide; + size.height += header_height; } else this->header_height = 0; if (!lt->footer.empty()) { SetDParamStr(0, lt->footer); - size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide; + size.height += GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide; } } diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 7f9c944c4e..c065711504 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -579,7 +579,7 @@ void LinkGraphLegendWindow::SetOverlay(std::shared_ptr overlay } } -void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) { if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) { StringID str = STR_NULL; @@ -594,7 +594,7 @@ void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [ Dimension dim = GetStringBoundingBox(str, FS_SMALL); dim.width += padding.width; dim.height += padding.height; - *size = maxdim(*size, dim); + size = maxdim(size, dim); } } if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) { @@ -602,7 +602,7 @@ void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [ Dimension dim = GetStringBoundingBox(cargo->abbrev, FS_SMALL); dim.width += padding.width; dim.height += padding.height; - *size = maxdim(*size, dim); + size = maxdim(size, dim); } } diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index e86a38b84b..a8dc91c822 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -108,7 +108,7 @@ public: LinkGraphLegendWindow(WindowDesc *desc, int window_number); void SetOverlay(std::shared_ptr overlay); - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override; void DrawWidget(const Rect &r, WidgetID widget) const override; bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override; void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 182693b1a0..1412e849de 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -89,23 +89,23 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_LI_BACKGROUND) return; - size->height = WidgetDimensions::scaled.frametext.Vertical(); + size.height = WidgetDimensions::scaled.frametext.Vertical(); for (size_t i = 0; i < this->landinfo_data.size(); i++) { uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal(); - size->width = std::max(size->width, width); + size.width = std::max(size.width, width); - size->height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); + size.height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); } if (!this->cargo_acceptance.empty()) { uint width = GetStringBoundingBox(this->cargo_acceptance).width + WidgetDimensions::scaled.frametext.Horizontal(); - size->width = std::max(size->width, std::min(static_cast(ScaleGUITrad(300)), width)); + size.width = std::max(size.width, std::min(static_cast(ScaleGUITrad(300)), width)); SetDParamStr(0, cargo_acceptance); - size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.frametext.Horizontal()); + size.height += GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.frametext.Horizontal()); } } @@ -489,7 +489,7 @@ struct AboutWindow : public Window { if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_A_SCROLLING_TEXT) return; @@ -502,7 +502,7 @@ struct AboutWindow : public Window { for (const auto &str : _credits) { d.width = std::max(d.width, GetStringBoundingBox(str).width); } - *size = maxdim(*size, d); + size = maxdim(size, d); } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -702,17 +702,17 @@ struct TooltipsWindow : public Window return pt; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_TT_BACKGROUND) return; CopyInDParam(this->params); - size->width = std::min(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194)); - size->height = GetStringHeight(this->string_id, size->width); + size.width = std::min(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194)); + size.height = GetStringHeight(this->string_id, size.width); /* Increase slightly to have some space around the box. */ - size->width += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical(); } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -986,17 +986,17 @@ struct QueryStringWindow : public Window this->ReInit(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { /* We don't want this widget to show! */ - fill->width = 0; - resize->width = 0; - size->width = 0; + fill.width = 0; + resize.width = 0; + size.width = 0; } if (widget == WID_QS_WARNING) { - *size = this->warning_size; + size = this->warning_size; } } @@ -1139,11 +1139,11 @@ struct QueryWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_Q_TEXT) return; - *size = GetStringMultiLineBoundingBox(this->message, *size); + size = GetStringMultiLineBoundingBox(this->message, size); } void DrawWidget(const Rect &r, WidgetID widget) const override diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 081cd3650b..36817ae150 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -518,7 +518,7 @@ struct MusicTrackSelectionWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_MTS_PLAYLIST: { @@ -530,7 +530,7 @@ struct MusicTrackSelectionWindow : public Window { } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -547,7 +547,7 @@ struct MusicTrackSelectionWindow : public Window { } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } @@ -700,7 +700,7 @@ struct MusicWindow : public Window { ); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size. @@ -710,7 +710,7 @@ struct MusicWindow : public Window { Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE)); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -718,7 +718,7 @@ struct MusicWindow : public Window { Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -730,7 +730,7 @@ struct MusicWindow : public Window { } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 2a37224498..d6a15f44fa 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -116,21 +116,21 @@ void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data) this->Window::Close(); } -void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) { switch (widget) { case WID_NCDS_PROGRESS_BAR: SetDParamMaxDigits(0, 8); SetDParamMaxDigits(1, 8); SetDParamMaxDigits(2, 8); - *size = GetStringBoundingBox(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE); + size = GetStringBoundingBox(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE); /* We need some spacing for the 'border' */ - size->height += WidgetDimensions::scaled.frametext.Horizontal(); - size->width += WidgetDimensions::scaled.frametext.Vertical(); + size.height += WidgetDimensions::scaled.frametext.Horizontal(); + size.width += WidgetDimensions::scaled.frametext.Vertical(); break; case WID_NCDS_PROGRESS_TEXT: - size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; + size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; break; } } @@ -585,25 +585,25 @@ public: this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT)); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NCL_CHECKBOX: - size->width = this->checkbox_size.width + padding.width; + size.width = this->checkbox_size.width + padding.width; break; case WID_NCL_TYPE: { - Dimension d = *size; + Dimension d = size; for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) { d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS)); } - size->width = d.width + padding.width; + size.width = d.width + padding.width; break; } case WID_NCL_MATRIX: - resize->height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; - size->height = 10 * resize->height; + resize.height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; + size.height = 10 * resize.height; break; } } diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index 5af46a59aa..a0f014e239 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -33,7 +33,7 @@ public: BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); void Close([[maybe_unused]] int data = 0) override; - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override; void DrawWidget(const Rect &r, WidgetID widget) const override; void OnDownloadProgress(const ContentInfo *ci, int bytes) override; }; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index aa9940c936..54584a1a51 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -475,48 +475,48 @@ public: this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NG_MATRIX: - resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; - fill->height = resize->height; - size->height = 12 * resize->height; + resize.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; + fill.height = resize.height; + size.height = 12 * resize.height; break; case WID_NG_LASTJOINED: - size->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical(); + size.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical(); break; case WID_NG_LASTJOINED_SPACER: - size->width = NWidgetScrollbar::GetVerticalDimension().width; + size.width = NWidgetScrollbar::GetVerticalDimension().width; break; case WID_NG_NAME: - size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow + size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow break; case WID_NG_CLIENTS: - size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow + size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow SetDParamMaxValue(0, MAX_CLIENTS); SetDParamMaxValue(1, MAX_CLIENTS); SetDParamMaxValue(2, MAX_COMPANIES); SetDParamMaxValue(3, MAX_COMPANIES); - *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE)); + size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE)); break; case WID_NG_MAPSIZE: - size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow + size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow SetDParamMaxValue(0, MAX_MAP_SIZE); SetDParamMaxValue(1, MAX_MAP_SIZE); - *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT)); + size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT)); break; case WID_NG_DATE: case WID_NG_YEARS: - size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow + size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow SetDParamMaxValue(0, 5); - *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT)); + size = maxdim(size, GetStringBoundingBox(STR_JUST_INT)); break; } } @@ -1010,13 +1010,13 @@ struct NetworkStartServerWindow : public Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NSS_CONNTYPE_BTN: - *size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY)); - size->width += padding.width; - size->height += padding.height; + size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY)); + size.width += padding.width; + size.height += padding.height; break; } } @@ -1673,7 +1673,7 @@ public: this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_CL_SERVER_NAME: @@ -1684,14 +1684,14 @@ public: const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id); SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name); } - *size = GetStringBoundingBox(STR_JUST_RAW_STRING); - size->width = std::min(size->width, static_cast(ScaleGUITrad(200))); // By default, don't open the window too wide. + size = GetStringBoundingBox(STR_JUST_RAW_STRING); + size.width = std::min(size.width, static_cast(ScaleGUITrad(200))); // By default, don't open the window too wide. break; case WID_CL_SERVER_VISIBILITY: - *size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY)); - size->width += padding.width; - size->height += padding.height; + size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY)); + size.width += padding.width; + size.height += padding.height; break; case WID_CL_MATRIX: { @@ -1699,10 +1699,10 @@ public: height += WidgetDimensions::scaled.framerect.Vertical(); this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; - resize->width = 1; - resize->height = this->line_height; - fill->height = this->line_height; - size->height = std::max(size->height, 5 * this->line_height); + resize.width = 1; + resize.height = this->line_height; + fill.height = this->line_height; + size.height = std::max(size.height, 5 * this->line_height); break; } } @@ -2162,28 +2162,28 @@ struct NetworkJoinStatusWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NJS_PROGRESS_BAR: /* Account for the statuses */ for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) { - *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i)); + size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i)); } /* For the number of waiting (other) players */ SetDParamMaxValue(0, MAX_CLIENTS); - *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING)); + size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING)); /* We need some spacing for the 'border' */ - size->height += WidgetDimensions::scaled.frametext.Horizontal(); - size->width += WidgetDimensions::scaled.frametext.Vertical(); + size.height += WidgetDimensions::scaled.frametext.Horizontal(); + size.width += WidgetDimensions::scaled.frametext.Vertical(); break; case WID_NJS_PROGRESS_TEXT: /* Account for downloading ~ 10 MiB */ SetDParamMaxDigits(0, 8); SetDParamMaxDigits(1, 8); - *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1)); - *size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1)); + size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1)); + size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1)); break; } } @@ -2273,10 +2273,10 @@ struct NetworkCompanyPasswordWindow : public Window { this->ReInit(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_NCP_WARNING) { - *size = this->warning_size; + size = this->warning_size; } } @@ -2379,10 +2379,10 @@ struct NetworkAskRelayWindow : public Window { this->Window::Close(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_NAR_TEXT) { - *size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT); + size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT); } } @@ -2482,10 +2482,10 @@ struct NetworkAskSurveyWindow : public Window { this->InitNested(0); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_NAS_TEXT) { - *size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT); + size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT); } } diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 95695ab294..e19ccba54b 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -357,21 +357,21 @@ struct NewGRFInspectWindow : Window { GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex()); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NGRFI_VEH_CHAIN: { assert(this->HasChainIndex()); GrfSpecFeature f = GetFeatureNum(this->window_number); - size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical()); + size.height = std::max(size.height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical()); break; } case WID_NGRFI_MAINPANEL: - resize->height = std::max(11, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal); - resize->width = 1; + resize.height = std::max(11, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal); + resize.width = 1; - size->height = 5 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); + size.height = 5 * resize.height + WidgetDimensions::scaled.frametext.Vertical(); break; } } @@ -882,11 +882,11 @@ struct SpriteAlignerWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SA_SPRITE: - size->height = ScaleGUITrad(200); + size.height = ScaleGUITrad(200); break; case WID_SA_LIST: { @@ -896,10 +896,10 @@ struct SpriteAlignerWindow : Window { SetDParamMaxDigits(1, 6); d = maxdim(d, GetStringBoundingBox(STR_SPRITE_ALIGNER_SPRITE)); } - size->width = d.width + padding.width; - resize->height = GetCharacterHeight(FS_NORMAL) + padding.height; - resize->width = 1; - fill->height = resize->height; + size.width = d.width + padding.width; + resize.height = GetCharacterHeight(FS_NORMAL) + padding.height; + resize.width = 1; + fill.height = resize.height; break; } diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index e311fad3c6..ef8950a5ce 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -210,13 +210,13 @@ struct NewGRFParametersWindow : public Window { return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NP_NUMPAR_DEC: case WID_NP_NUMPAR_INC: { - size->width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL)); - size->height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)); + size.width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL)); + size.height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)); break; } @@ -225,16 +225,16 @@ struct NewGRFParametersWindow : public Window { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_NP_BACKGROUND: this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; - resize->width = 1; - resize->height = this->line_height; - size->height = 5 * this->line_height; + resize.width = 1; + resize.height = this->line_height; + size.height = 5 * this->line_height; break; case WID_NP_DESCRIPTION: @@ -248,7 +248,7 @@ struct NewGRFParametersWindow : public Window { d.height += WidgetDimensions::scaled.frametext.Vertical(); suggestion = maxdim(d, suggestion); } - size->height = suggestion.height; + size.height = suggestion.height; break; } } @@ -743,34 +743,34 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_NS_FILE_LIST: { Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN)); - resize->height = std::max(d.height + 2U, GetCharacterHeight(FS_NORMAL)); - size->height = std::max(size->height, padding.height + 6 * resize->height); + resize.height = std::max(d.height + 2U, GetCharacterHeight(FS_NORMAL)); + size.height = std::max(size.height, padding.height + 6 * resize.height); break; } case WID_NS_AVAIL_LIST: { Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN)); - resize->height = std::max(d.height + 2U, GetCharacterHeight(FS_NORMAL)); - size->height = std::max(size->height, padding.height + 8 * resize->height); + resize.height = std::max(d.height + 2U, GetCharacterHeight(FS_NORMAL)); + size.height = std::max(size.height, padding.height + 8 * resize.height); break; } case WID_NS_NEWGRF_INFO_TITLE: { Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE); - size->height = std::max(size->height, dim.height + WidgetDimensions::scaled.frametext.Vertical()); - size->width = std::max(size->width, dim.width + WidgetDimensions::scaled.frametext.Horizontal()); + size.height = std::max(size.height, dim.height + WidgetDimensions::scaled.frametext.Vertical()); + size.width = std::max(size.width, dim.width + WidgetDimensions::scaled.frametext.Horizontal()); break; } case WID_NS_NEWGRF_INFO: - size->height = std::max(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL)); + size.height = std::max(size.height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL)); break; case WID_NS_PRESET_LIST: { @@ -780,16 +780,16 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING)); } d.width += padding.width; - *size = maxdim(d, *size); + size = maxdim(d, size); break; } case WID_NS_CONTENT_DOWNLOAD: case WID_NS_CONTENT_DOWNLOAD2: { Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON); - *size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT)); - size->width += padding.width; - size->height += padding.height; + size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT)); + size.width += padding.width; + size.height += padding.height; break; } } @@ -2099,18 +2099,18 @@ struct SavePresetWindow : public Window { { } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SVP_PRESET_LIST: { - resize->height = GetCharacterHeight(FS_NORMAL); - size->height = 0; + resize.height = GetCharacterHeight(FS_NORMAL); + size.height = 0; for (uint i = 0; i < this->presets.size(); i++) { Dimension d = GetStringBoundingBox(this->presets[i]); - size->width = std::max(size->width, d.width + padding.width); - resize->height = std::max(resize->height, d.height); + size.width = std::max(size.width, d.width + padding.width); + resize.height = std::max(resize.height, d.height); } - size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + padding.height; + size.height = ClampU((uint)this->presets.size(), 5, 20) * resize.height + padding.height; break; } } @@ -2214,15 +2214,15 @@ struct ScanProgressWindow : public Window { this->InitNested(1); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SP_PROGRESS_BAR: { SetDParamMaxValue(0, 100); - *size = GetStringBoundingBox(STR_GENERATION_PROGRESS); + size = GetStringBoundingBox(STR_GENERATION_PROGRESS); /* We need some spacing for the 'border' */ - size->height += WidgetDimensions::scaled.frametext.Horizontal(); - size->width += WidgetDimensions::scaled.frametext.Vertical(); + size.height += WidgetDimensions::scaled.frametext.Horizontal(); + size.width += WidgetDimensions::scaled.frametext.Vertical(); break; } @@ -2231,8 +2231,8 @@ struct ScanProgressWindow : public Window { SetDParamMaxDigits(1, 4); /* We really don't know the width. We could determine it by scanning the NewGRFs, * but this is the status window for scanning them... */ - size->width = std::max(size->width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width); - size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; + size.width = std::max(size.width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width); + size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; break; } } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index e90772f170..8e8d98f261 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -358,7 +358,7 @@ struct NewsWindow : Window { return pt; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { StringID str = STR_NULL; switch (widget) { @@ -367,12 +367,12 @@ struct NewsWindow : Window { * thus it doesn't get the default sizing of a caption. */ Dimension d2 = GetStringBoundingBox(STR_NEWS_MESSAGE_CAPTION); d2.height += WidgetDimensions::scaled.captiontext.Vertical(); - *size = maxdim(*size, d2); + size = maxdim(size, d2); return; } case WID_N_MGR_FACE: - *size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); + size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT)); break; case WID_N_MGR_NAME: @@ -406,15 +406,15 @@ struct NewsWindow : Window { Dimension d2 = GetStringBoundingBox(this->GetWidget(WID_N_SHOW_GROUP)->widget_data); d2.height += WidgetDimensions::scaled.captiontext.Vertical(); d2.width += WidgetDimensions::scaled.captiontext.Horizontal(); - *size = d2; + size = d2; } else { /* Hide 'Show group window' button if this news is not about a vehicle. */ - size->width = 0; - size->height = 0; - resize->width = 0; - resize->height = 0; - fill->width = 0; - fill->height = 0; + size.width = 0; + size.height = 0; + resize.width = 0; + resize.height = 0; + fill.width = 0; + fill.height = 0; } return; @@ -423,13 +423,13 @@ struct NewsWindow : Window { } /* Update minimal size with length of the multi-line string. */ - Dimension d = *size; + Dimension d = size; d.width = (d.width >= padding.width) ? d.width - padding.width : 0; d.height = (d.height >= padding.height) ? d.height - padding.height : 0; d = GetStringMultiLineBoundingBox(str, d); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); } void SetStringParameters(WidgetID widget) const override @@ -1099,19 +1099,19 @@ struct MessageHistoryWindow : Window { this->OnInvalidateData(0); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_MH_BACKGROUND) { this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; - resize->height = this->line_height; + resize.height = this->line_height; /* Months are off-by-one, so it's actually 8. Not using * month 12 because the 1 is usually less wide. */ SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::ORIGINAL_MAX_YEAR, 7, 30)); this->date_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width + WidgetDimensions::scaled.hsep_wide; - size->height = 4 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible. - size->width = std::max(200u, size->width); // At least 200 pixels wide. + size.height = 4 * resize.height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible. + size.width = std::max(200u, size.width); // At least 200 pixels wide. } } diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 8d1880723a..7ea9fd37df 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -212,25 +212,25 @@ public: this->object_margin = ScaleGUITrad(4); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BO_CLASS_LIST: { for (auto object_class_id : this->object_classes) { ObjectClass *objclass = ObjectClass::Get(object_class_id); if (objclass->GetUISpecCount() == 0) continue; - size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(objclass->name).width + padding.width); } this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; - resize->height = this->line_height; - size->height = 5 * this->line_height; + resize.height = this->line_height; + size.height = 5 * this->line_height; break; } case WID_BO_OBJECT_NAME: case WID_BO_OBJECT_SIZE: /* We do not want the window to resize when selecting objects; better clip texts */ - size->width = 0; + size.width = 0; break; case WID_BO_OBJECT_MATRIX: { @@ -238,11 +238,11 @@ public: ObjectClass *objclass = ObjectClass::Get(_selected_object_class); const ObjectSpec *spec = objclass->GetSpec(_selected_object_index); if (spec != nullptr) { - if (spec->views >= 2) size->width += resize->width; - if (spec->views >= 4) size->height += resize->height; + if (spec->views >= 2) size.width += resize.width; + if (spec->views >= 4) size.height += resize.height; } - resize->width = 0; - resize->height = 0; + resize.width = 0; + resize.height = 0; break; } @@ -267,37 +267,37 @@ public: * we want these columns to be slightly less wide. When there are two rows, then * determine the size of the widgets based on the maximum size for a single row * of widgets, or just the twice the widget height of the two row ones. */ - size->height = std::max(height[0], height[1] * 2); + size.height = std::max(height[0], height[1] * 2); if (two_wide) { - size->width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2; + size.width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2; } else { - size->width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin; + size.width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin; } /* Get the right size for the single widget based on the current spec. */ ObjectClass *objclass = ObjectClass::Get(_selected_object_class); const ObjectSpec *spec = objclass->GetSpec(_selected_object_index); if (spec != nullptr) { - if (spec->views <= 1) size->width += WidgetDimensions::scaled.hsep_normal; - if (spec->views <= 2) size->height += WidgetDimensions::scaled.vsep_normal; - if (spec->views >= 2) size->width /= 2; - if (spec->views >= 4) size->height /= 2; + if (spec->views <= 1) size.width += WidgetDimensions::scaled.hsep_normal; + if (spec->views <= 2) size.height += WidgetDimensions::scaled.vsep_normal; + if (spec->views >= 2) size.width /= 2; + if (spec->views >= 4) size.height /= 2; } break; } case WID_BO_INFO: - size->height = this->info_height; + size.height = this->info_height; break; case WID_BO_SELECT_MATRIX: - fill->height = 1; - resize->height = 1; + fill.height = 1; + resize.height = 1; break; case WID_BO_SELECT_IMAGE: - size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); break; default: break; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 95d0d6f941..44979fd75a 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -836,12 +836,12 @@ public: this->OnInvalidateData(VIWD_MODIFY_ORDERS); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_O_ORDER_LIST: - resize->height = GetCharacterHeight(FS_NORMAL); - size->height = 6 * resize->height + padding.height; + resize.height = GetCharacterHeight(FS_NORMAL); + size.height = 6 * resize.height + padding.height; break; case WID_O_COND_VARIABLE: { @@ -851,7 +851,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -862,7 +862,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 16a0e985b6..a3ebd0843d 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1236,7 +1236,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BRAS_NEWST_LIST: { @@ -1244,17 +1244,17 @@ public: for (auto station_class : this->station_classes) { d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name)); } - size->width = std::max(size->width, d.width + padding.width); + size.width = std::max(size.width, d.width + padding.width); this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; - size->height = 5 * this->line_height; - resize->height = this->line_height; + size.height = 5 * this->line_height; + resize.height = this->line_height; break; } case WID_BRAS_SHOW_NEWST_TYPE: { if (!_railstation.newstations) { - size->width = 0; - size->height = 0; + size.width = 0; + size.height = 0; break; } @@ -1269,24 +1269,24 @@ public: d = maxdim(d, GetStringBoundingBox(str)); } } - size->width = std::max(size->width, d.width + padding.width); + size.width = std::max(size.width, d.width + padding.width); break; } case WID_BRAS_PLATFORM_DIR_X: case WID_BRAS_PLATFORM_DIR_Y: case WID_BRAS_IMAGE: - size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); break; case WID_BRAS_COVERAGE_TEXTS: - size->height = this->coverage_height; + size.height = this->coverage_height; break; case WID_BRAS_MATRIX: - fill->height = 1; - resize->height = 1; + fill.height = 1; + resize.height = 1; break; } } @@ -1752,14 +1752,14 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) { /* Two digits for signals density. */ - size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal()); + size.width = std::max(size.width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal()); } else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) { - size->width = std::max(size->width, this->sig_sprite_size.width + padding.width); - size->height = std::max(size->height, this->sig_sprite_size.height + padding.height); + size.width = std::max(size.width, this->sig_sprite_size.width + padding.width); + size.height = std::max(size.height, this->sig_sprite_size.height + padding.height); } } @@ -1951,12 +1951,12 @@ struct BuildRailDepotWindow : public PickerWindowBase { this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; - size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -2106,21 +2106,21 @@ struct BuildRailWaypointWindow : PickerWindowBase { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BRW_WAYPOINT_MATRIX: /* Two blobs high and three wide. */ - size->width += resize->width * 2; - size->height += resize->height * 1; + size.width += resize.width * 2; + size.height += resize.height * 1; /* Resizing in X direction only at blob size, but at pixel level in Y. */ - resize->height = 1; + resize.height = 1; break; case WID_BRW_WAYPOINT: - size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); break; } } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index e966d9b770..6bc38298ce 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1020,12 +1020,12 @@ struct BuildRoadDepotWindow : public PickerWindowBase { this->FinishInitNested(TRANSPORT_ROAD); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; - size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -1354,7 +1354,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_BROS_NEWST_LIST: { @@ -1362,10 +1362,10 @@ public: for (auto rs_class : this->roadstop_classes) { d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name)); } - size->width = std::max(size->width, d.width + padding.width); + size.width = std::max(size.width, d.width + padding.width); this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(); - size->height = 5 * this->line_height; - resize->height = this->line_height; + size.height = 5 * this->line_height; + resize.height = this->line_height; break; } @@ -1380,7 +1380,7 @@ public: d = maxdim(d, GetStringBoundingBox(str)); } } - size->width = std::max(size->width, d.width + padding.width); + size.width = std::max(size.width, d.width + padding.width); break; } @@ -1391,17 +1391,17 @@ public: case WID_BROS_STATION_X: case WID_BROS_STATION_Y: case WID_BROS_IMAGE: - size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); - size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); + size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); + size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); break; case WID_BROS_MATRIX: - fill->height = 1; - resize->height = 1; + fill.height = 1; + resize.height = 1; break; case WID_BROS_ACCEPTANCE: - size->height = this->coverage_height; + size.height = this->coverage_height; break; } } diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 21d0a5af0a..9706426a6a 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -103,15 +103,15 @@ struct ScriptListWindow : public Window { SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_LIST_CAPTION_GAMESCRIPT : STR_AI_LIST_CAPTION_AI); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_SCRL_LIST) return; this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; - resize->width = 1; - resize->height = this->line_height; - size->height = 5 * this->line_height; + resize.width = 1; + resize.height = this->line_height; + size.height = 5 * this->line_height; } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -341,15 +341,15 @@ struct ScriptSettingsWindow : public Window { SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_SETTINGS_CAPTION_GAMESCRIPT : STR_AI_SETTINGS_CAPTION_AI); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_SCRS_BACKGROUND) return; this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; - resize->width = 1; - resize->height = this->line_height; - size->height = 5 * this->line_height; + resize.width = 1; + resize.height = this->line_height; + size.height = 5 * this->line_height; } void DrawWidget(const Rect &r, WidgetID widget) const override @@ -823,11 +823,11 @@ struct ScriptDebugWindow : public Window { ScriptDebugWindow::initial_state = this->filter; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget == WID_SCRD_LOG_PANEL) { - resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; - size->height = 14 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); + resize.height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; + size.height = 14 * resize.height + WidgetDimensions::scaled.framerect.Vertical(); } } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index dbcd63755e..b188d429e6 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -648,7 +648,7 @@ struct GameOptionsWindow : Window { if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_GO_TEXT_SFX_VOLUME: @@ -656,7 +656,7 @@ struct GameOptionsWindow : Window { Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME)); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -669,7 +669,7 @@ struct GameOptionsWindow : Window { case WID_GO_BASE_SFX_DROPDOWN: case WID_GO_BASE_MUSIC_DROPDOWN: { int selected; - size->width = std::max(size->width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width); + size.width = std::max(size.width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width); break; } } @@ -2364,14 +2364,14 @@ struct GameSettingsWindow : Window { _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED)); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_GS_OPTIONSPANEL: - resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal; - resize->width = 1; + resize.height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal; + resize.width = 1; - size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); + size.height = 5 * resize.height + WidgetDimensions::scaled.framerect.Vertical(); break; case WID_GS_HELP_TEXT: { @@ -2382,16 +2382,16 @@ struct GameSettingsWindow : Window { }; for (uint i = 0; i < lengthof(setting_types); i++) { SetDParam(0, setting_types[i]); - size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width); } - size->height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + - std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width)); + size.height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + + std::max(size.height, GetSettingsTree().GetMaxHelpHeight(size.width)); break; } case WID_GS_RESTRICT_CATEGORY: case WID_GS_RESTRICT_TYPE: - size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width); + size.width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width); break; default: @@ -3010,7 +3010,7 @@ struct CustomCurrencyWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { /* Set the appropriate width for the up/down buttons. */ @@ -3018,21 +3018,21 @@ struct CustomCurrencyWindow : Window { case WID_CC_RATE_UP: case WID_CC_YEAR_DOWN: case WID_CC_YEAR_UP: - *size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT}); + size = maxdim(size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT}); break; /* Set the appropriate width for the edit buttons. */ case WID_CC_SEPARATOR_EDIT: case WID_CC_PREFIX_EDIT: case WID_CC_SUFFIX_EDIT: - *size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT}); + size = maxdim(size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT}); break; /* Make sure the window is wide enough for the widest exchange rate */ case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, INT32_MAX); - *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE); + size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE); break; } } diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index fd327eb020..1556930029 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -263,23 +263,23 @@ struct SignListWindow : Window, SignList { this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical()); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SIL_LIST: { Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON); this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text. - resize->height = std::max(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2); - Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height}; - *size = maxdim(*size, d); + resize.height = std::max(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2); + Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize.height}; + size = maxdim(size, d); break; } case WID_SIL_CAPTION: SetDParamMaxValue(0, Sign::GetPoolSize(), 3); - *size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION); - size->height += padding.height; - size->width += padding.width; + size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION); + size.height += padding.height; + size.width += padding.width; break; } } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a9c45fb5da..d277fdbf1f 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -411,14 +411,14 @@ public: CompanyStationsWindow::initial_state = this->filter; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_STL_SORTBY: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -429,13 +429,13 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_STL_LIST: - resize->height = std::max(GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_SMALL) + ScaleGUITrad(3)); - size->height = padding.height + 5 * resize->height; + resize.height = std::max(GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_SMALL) + ScaleGUITrad(3)); + size.height = padding.height + 5 * resize.height; /* Determine appropriate width for mini station rating graph */ this->rating_width = 0; @@ -1392,25 +1392,25 @@ struct StationViewWindow : public Window { data->Update(count); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_SV_WAITING: - resize->height = GetCharacterHeight(FS_NORMAL); - size->height = 4 * resize->height + padding.height; + resize.height = GetCharacterHeight(FS_NORMAL); + size.height = 4 * resize.height + padding.height; this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width); break; case WID_SV_ACCEPT_RATING_LIST: - size->height = ((this->GetWidget(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * GetCharacterHeight(FS_NORMAL) + padding.height; + size.height = ((this->GetWidget(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * GetCharacterHeight(FS_NORMAL) + padding.height; break; case WID_SV_CLOSE_AIRPORT: if (!(Station::Get(this->window_number)->facilities & FACIL_AIRPORT)) { /* Hide 'Close Airport' button if no airport present. */ - size->width = 0; - resize->width = 0; - fill->width = 0; + size.width = 0; + resize.width = 0; + fill.width = 0; } break; } @@ -2305,7 +2305,7 @@ struct SelectStationWindow : Window { this->Window::Close(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_JS_PANEL) return; @@ -2319,11 +2319,11 @@ struct SelectStationWindow : Window { d = maxdim(d, GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION)); } - resize->height = d.height; + resize.height = d.height; d.height *= 5; d.width += padding.width; d.height += padding.height; - *size = d; + size = d; } void DrawWidget(const Rect &r, WidgetID widget) const override diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 69f12dbfdd..dd6e33da34 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -83,7 +83,7 @@ struct StatusBarWindow : Window { Window::FindWindowPlacementAndResize(_toolbar_width, def_height); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { Dimension d; switch (widget) { @@ -106,7 +106,7 @@ struct StatusBarWindow : Window { d.width += padding.width; d.height += padding.height; - *size = maxdim(d, *size); + size = maxdim(d, size); } void DrawWidget(const Rect &r, WidgetID widget) const override diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 1ed4e950d9..9a91eb7128 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -751,7 +751,7 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return; @@ -780,14 +780,14 @@ public: d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_SB_PAGE_PANEL: { d.height *= 5; d.height += padding.height + WidgetDimensions::scaled.frametext.Vertical(); - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index f43226d5f4..98c218e3b6 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -131,17 +131,17 @@ struct SubsidyListWindow : Window { return 3 + num_awarded + num_not_awarded; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_SUL_PANEL) return; Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); - resize->height = GetCharacterHeight(FS_NORMAL); + resize.height = GetCharacterHeight(FS_NORMAL); d.height *= 5; d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.height += WidgetDimensions::scaled.framerect.Vertical(); - *size = maxdim(*size, d); + size = maxdim(size, d); } void DrawCargoIcon(const Rect &r, int y_offset, CargoID cid) const diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 6da19b9037..417c7fa427 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -553,12 +553,12 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget != WID_ETT_DOTS) return; - size->width = std::max(size->width, ScaleGUITrad(59)); - size->height = std::max(size->height, ScaleGUITrad(31)); + size.width = std::max(size.width, ScaleGUITrad(59)); + size.height = std::max(size.height, ScaleGUITrad(31)); } void DrawWidget(const Rect &r, WidgetID widget) const override diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 194c3c6a4c..bb6c2d876d 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -133,14 +133,14 @@ uint TextfileWindow::GetContentHeight() return this->lines.back().bottom; } -/* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +/* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) { switch (widget) { case WID_TF_BACKGROUND: - resize->height = GetCharacterHeight(FS_MONO); + resize.height = GetCharacterHeight(FS_MONO); - size->height = 4 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible. - size->width = std::max(200u, size->width); // At least 200 pixels wide. + size.height = 4 * resize.height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible. + size.width = std::max(200u, size.width); // At least 200 pixels wide. break; } } diff --git a/src/textfile_gui.h b/src/textfile_gui.h index 6376bd64c1..09d55a355d 100644 --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -23,7 +23,7 @@ struct TextfileWindow : public Window, MissingGlyphSearcher { Scrollbar *vscroll; ///< Vertical scrollbar. Scrollbar *hscroll; ///< Horizontal scrollbar. - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override; void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; void DrawWidget(const Rect &r, WidgetID widget) const override; void OnResize() override; diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index d55b7dc711..283dbd401e 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -248,7 +248,7 @@ struct TimetableWindow : Window { return (travelling && v->lateness_counter < 0); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_VT_ARRIVAL_DEPARTURE_PANEL: @@ -256,21 +256,21 @@ struct TimetableWindow : Window { if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) { /* A five-digit number would fit a timetable lasting 2.7 real-world hours, which should be plenty. */ SetDParamMaxDigits(1, 4, FS_SMALL); - size->width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE).width) + WidgetDimensions::scaled.hsep_wide + padding.width; + size.width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE).width) + WidgetDimensions::scaled.hsep_wide + padding.width; } else { SetDParamMaxValue(1, TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR), 0, FS_SMALL); - size->width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_DATE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_DATE).width) + WidgetDimensions::scaled.hsep_wide + padding.width; + size.width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_DATE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_DATE).width) + WidgetDimensions::scaled.hsep_wide + padding.width; } [[fallthrough]]; case WID_VT_ARRIVAL_DEPARTURE_SELECTION: case WID_VT_TIMETABLE_PANEL: - resize->height = GetCharacterHeight(FS_NORMAL); - size->height = 8 * resize->height + padding.height; + resize.height = GetCharacterHeight(FS_NORMAL); + size.height = 8 * resize.height + padding.height; break; case WID_VT_SUMMARY_PANEL: - size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; + size.height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; break; } } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 26fcfa798d..58589da48c 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2339,16 +2339,16 @@ struct ScenarioEditorToolbarWindow : Window { } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_TE_SPACER: - size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width; + size.width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width; break; case WID_TE_DATE: SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1)); - *size = GetStringBoundingBox(STR_JUST_DATE_LONG); + size = GetStringBoundingBox(STR_JUST_DATE_LONG); break; } } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 14ddaa8619..29e8c5396f 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -256,34 +256,34 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_TA_ACTION_INFO: { - assert(size->width > padding.width && size->height > padding.height); + assert(size.width > padding.width && size.height > padding.height); Dimension d = {0, 0}; for (int i = 0; i < TACT_COUNT; i++) { SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8); - d = maxdim(d, GetStringMultiLineBoundingBox(this->action_tooltips[i], *size)); + d = maxdim(d, GetStringMultiLineBoundingBox(this->action_tooltips[i], size)); } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_TA_COMMAND_LIST: - size->height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height; - size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width; + size.height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height; + size.width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width; for (uint i = 0; i < TACT_COUNT; i++ ) { - size->width = std::max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width); + size.width = std::max(size.width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width); } - size->width += padding.width; + size.width += padding.width; break; case WID_TA_RATING_INFO: - resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)}); - size->height = 9 * resize->height + padding.height; + resize.height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)}); + size.height = 9 * resize.height + padding.height; break; } } @@ -524,11 +524,11 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_TV_INFO: - size->height = GetDesiredInfoHeight(size->width) + padding.height; + size.height = GetDesiredInfoHeight(size.width) + padding.height; break; } } @@ -878,14 +878,14 @@ public: } } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_TD_SORT_ORDER: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_TD_SORT_CRITERIA: { @@ -895,7 +895,7 @@ public: } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_TD_LIST: { @@ -912,11 +912,11 @@ public: Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD); d.width += icon_size.width + 2; d.height = std::max(d.height, icon_size.height); - resize->height = d.height; + resize.height = d.height; d.height *= 5; d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_TD_WORLD_POPULATION: { @@ -924,7 +924,7 @@ public: Dimension d = GetStringBoundingBox(STR_TOWN_POPULATION); d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index f8dd8f6bad..e751dba3f5 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -152,13 +152,13 @@ public: this->FinishInitNested(window_number); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { if (widget >= WID_BT_TYPE_BUTTON_FIRST) { /* Ensure tree type buttons are sized after the largest tree type */ Dimension d = GetMaxTreeSpriteSize(); - size->width = d.width + padding.width; - size->height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space + size.width = d.width + padding.width; + size.height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space } } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 94fc106bae..7f4ce36146 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -916,20 +916,20 @@ struct RefitWindow : public Window { this->DrawWidgets(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_VR_MATRIX: - resize->height = GetCharacterHeight(FS_NORMAL) + padding.height; - size->height = resize->height * 8; + resize.height = GetCharacterHeight(FS_NORMAL) + padding.height; + size.height = resize.height * 8; break; case WID_VR_VEHICLE_PANEL_DISPLAY: - size->height = ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type)); + size.height = ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type)); break; case WID_VR_INFO: - size->width = this->information_width + padding.height; + size.width = this->information_width + padding.height; break; } } @@ -1901,20 +1901,20 @@ public: *this->sorting = this->vehgroups.GetListing(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_VL_LIST: - resize->height = GetVehicleListHeight(this->vli.vtype, 1); + resize.height = GetVehicleListHeight(this->vli.vtype, 1); switch (this->vli.vtype) { case VEH_TRAIN: case VEH_ROAD: - size->height = 6 * resize->height; + size.height = 6 * resize.height; break; case VEH_SHIP: case VEH_AIRCRAFT: - size->height = 4 * resize->height; + size.height = 4 * resize.height; break; default: NOT_REACHED(); } @@ -1924,31 +1924,31 @@ public: Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } case WID_VL_GROUP_BY_PULLDOWN: - size->width = GetStringListWidth(this->vehicle_group_by_names) + padding.width; + size.width = GetStringListWidth(this->vehicle_group_by_names) + padding.width; break; case WID_VL_SORT_BY_PULLDOWN: - size->width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar); - size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock)); - size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar)); - size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock)); - size->width += padding.width; + size.width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar); + size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock)); + size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar)); + size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock)); + size.width += padding.width; break; case WID_VL_FILTER_BY_CARGO: - size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width); + size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width); break; case WID_VL_MANAGE_VEHICLES_DROPDOWN: { Dimension d = this->GetActionDropdownSize(this->vli.type == VL_STANDARD, false, true); d.height += padding.height; d.width += padding.width; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } } @@ -2424,12 +2424,12 @@ struct VehicleDetailsWindow : Window { return desired_height; } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { switch (widget) { case WID_VD_TOP_DETAILS: { Dimension dim = { 0, 0 }; - size->height = 4 * GetCharacterHeight(FS_NORMAL) + padding.height; + size.height = 4 * GetCharacterHeight(FS_NORMAL) + padding.height; for (uint i = 0; i < 4; i++) SetDParamMaxValue(i, INT16_MAX); static const StringID info_strings[] = { @@ -2445,7 +2445,7 @@ struct VehicleDetailsWindow : Window { } SetDParam(0, STR_VEHICLE_INFO_AGE); dim = maxdim(dim, GetStringBoundingBox(TimerGameEconomy::UsingWallclockUnits() ? STR_VEHICLE_INFO_AGE_RUNNING_COST_PERIOD : STR_VEHICLE_INFO_AGE_RUNNING_COST_YR)); - size->width = dim.width + padding.width; + size.width = dim.width + padding.width; break; } @@ -2453,15 +2453,15 @@ struct VehicleDetailsWindow : Window { const Vehicle *v = Vehicle::Get(this->window_number); switch (v->type) { case VEH_ROAD: - size->height = this->GetRoadVehDetailsHeight(v) + padding.height; + size.height = this->GetRoadVehDetailsHeight(v) + padding.height; break; case VEH_SHIP: - size->height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; + size.height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; break; case VEH_AIRCRAFT: - size->height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; + size.height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; break; default: @@ -2471,8 +2471,8 @@ struct VehicleDetailsWindow : Window { } case WID_VD_MATRIX: - resize->height = std::max(ScaleGUITrad(14), GetCharacterHeight(FS_NORMAL) + padding.height); - size->height = 4 * resize->height; + resize.height = std::max(ScaleGUITrad(14), GetCharacterHeight(FS_NORMAL) + padding.height); + size.height = 4 * resize.height; break; case WID_VD_SERVICE_INTERVAL_DROPDOWN: { @@ -2484,7 +2484,7 @@ struct VehicleDetailsWindow : Window { } d.width += padding.width; d.height += padding.height; - *size = maxdim(*size, d); + size = maxdim(size, d); break; } @@ -2501,11 +2501,11 @@ struct VehicleDetailsWindow : Window { /*/ Vehicle was last serviced at year 0, and we're at max year */ SetDParamMaxValue(2, TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR)); } - size->width = std::max( + size.width = std::max( GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width, GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width ) + padding.width; - size->height = GetCharacterHeight(FS_NORMAL) + padding.height; + size.height = GetCharacterHeight(FS_NORMAL) + padding.height; break; } } @@ -3037,24 +3037,24 @@ public: this->Window::Close(); } - void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override { const Vehicle *v = Vehicle::Get(this->window_number); switch (widget) { case WID_VV_START_STOP: - size->height = std::max({size->height, (uint)GetCharacterHeight(FS_NORMAL), GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height; + size.height = std::max({size.height, (uint)GetCharacterHeight(FS_NORMAL), GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height; break; case WID_VV_FORCE_PROCEED: if (v->type != VEH_TRAIN) { - size->height = 0; - size->width = 0; + size.height = 0; + size.width = 0; } break; case WID_VV_VIEWPORT: - size->width = VV_INITIAL_VIEWPORT_WIDTH; - size->height = (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT; + size.width = VV_INITIAL_VIEWPORT_WIDTH; + size.height = (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT; break; } } diff --git a/src/widget.cpp b/src/widget.cpp index b9aa2c0d76..74e970eb66 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1216,7 +1216,7 @@ void NWidgetStacked::SetupSmallestSize(Window *w) Dimension fill = {(this->shown_plane == SZSP_HORIZONTAL), (this->shown_plane == SZSP_VERTICAL)}; Dimension resize = {(this->shown_plane == SZSP_HORIZONTAL), (this->shown_plane == SZSP_VERTICAL)}; /* Here we're primarily interested in the value of resize */ - if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); + if (this->index >= 0) w->UpdateWidgetSize(this->index, size, padding, fill, resize); this->smallest_x = size.width; this->smallest_y = size.height; @@ -1833,7 +1833,7 @@ void NWidgetMatrix::SetupSmallestSize(Window *w) Dimension fill = {0, 0}; Dimension resize = {this->pip_inter + this->children.front()->smallest_x, this->pip_inter + this->children.front()->smallest_y}; - if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); + if (this->index >= 0) w->UpdateWidgetSize(this->index, size, padding, fill, resize); this->smallest_x = size.width; this->smallest_y = size.height; @@ -2108,7 +2108,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w) case WWT_FRAME: padding = {WidgetDimensions::scaled.frametext.Horizontal(), WidgetDimensions::scaled.frametext.Vertical()}; break; case WWT_INSET: padding = {WidgetDimensions::scaled.inset.Horizontal(), WidgetDimensions::scaled.inset.Vertical()}; break; } - w->UpdateWidgetSize(this->index, &d, padding, &fill, &resize); + w->UpdateWidgetSize(this->index, d, padding, fill, resize); } } this->smallest_x = d.width; @@ -2730,7 +2730,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w) NOT_REACHED(); } - if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); + if (this->index >= 0) w->UpdateWidgetSize(this->index, size, padding, fill, resize); this->smallest_x = size.width; this->smallest_y = size.height; diff --git a/src/window_gui.h b/src/window_gui.h index 0993b4c95f..5a67fd9b2c 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -611,12 +611,12 @@ public: * and \a resize is taken to contain the resize steps. For the convenience of the callee, \a padding contains the amount of * padding between the content and the edge of the widget. This should be added to the returned size. * @param widget Widget number. - * @param size Size of the widget. + * @param[in,out] size Size of the widget. * @param padding Recommended amount of space between the widget content and the widget edge. - * @param fill Fill step of the widget. - * @param resize Resize step of the widget. + * @param[in,out] fill Fill step of the widget. + * @param[in,out] resize Resize step of the widget. */ - virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) {} + virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) {} /** * Initialize string parameters for a widget.