Fix 8f14894024: Badge widths were not updated on interface scale change. (#13630)

Prepare GUI badge class lists in OnInit() method of Windows, so that they handle scaling changes.
This commit is contained in:
Peter Nelson
2025-02-22 13:29:52 +00:00
committed by GitHub
parent 8566030c53
commit bb4ac915ff
5 changed files with 17 additions and 12 deletions

View File

@@ -84,6 +84,7 @@ class ReplaceVehicleWindow : public Window {
bool reset_sel_engine; ///< Also reset #sel_engine while updating left and/or right and no valid engine selected.
GroupID sel_group; ///< Group selected to replace.
int details_height; ///< Minimal needed height of the details panels, in text lines (found so far).
VehicleType vehicle_type; ///< Type of vehicle in this window.
uint8_t sort_criteria; ///< Criteria of sorting vehicles.
bool descending_sort_order; ///< Order of sorting vehicles.
bool show_hidden_engines; ///< Whether to show the hidden engines.
@@ -267,6 +268,7 @@ class ReplaceVehicleWindow : public Window {
public:
ReplaceVehicleWindow(WindowDesc &desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
{
this->vehicle_type = vehicletype;
this->sel_railtype = INVALID_RAILTYPE;
this->sel_roadtype = INVALID_ROADTYPE;
this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
@@ -278,8 +280,6 @@ public:
this->sel_engine[1] = EngineID::Invalid();
this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
this->badge_classes = GUIBadgeClasses(static_cast<GrfSpecFeature>(GSF_TRAINS + vehicletype));
this->CreateNestedTree();
this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR);
this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR);
@@ -295,6 +295,11 @@ public:
this->sel_group = id_g;
}
void OnInit() override
{
this->badge_classes = GUIBadgeClasses(static_cast<GrfSpecFeature>(GSF_TRAINS + this->vehicle_type));
}
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{
switch (widget) {