diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 401649cd37..98f7117c17 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -286,7 +286,7 @@ struct DepotWindow : Window { /* Don't show 'rename button' of aircraft hangar */ this->GetWidget(WID_D_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0); /* Only train depots have a horizontal scrollbar and a 'sell chain' button */ - if (type == VEH_TRAIN) this->GetWidget(WID_D_MATRIX)->widget_data = 1 << MAT_COL_START; + if (type == VEH_TRAIN) this->GetWidget(WID_D_MATRIX)->SetMatrixDimension(1, 0 /* auto-scale */); this->GetWidget(WID_D_SHOW_H_SCROLL)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_HORIZONTAL); this->GetWidget(WID_D_SHOW_SELL_CHAIN)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_NONE); this->SetupWidgetData(type); diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 0a6fc46194..308ae2d611 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -555,7 +555,7 @@ public: resize.width = 0; resize.height = 0; - this->GetWidget(WID_GRAPH_RANGE_MATRIX)->SetMatrixDataTip(1, ClampTo(std::size(this->ranges)), STR_NULL); + this->GetWidget(WID_GRAPH_RANGE_MATRIX)->SetMatrixDimension(1, ClampTo(std::size(this->ranges))); break; case WID_GRAPH_GRAPH: { diff --git a/src/widget.cpp b/src/widget.cpp index 308ce8ade9..06a975788d 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1174,6 +1174,16 @@ void NWidgetCore::SetSpriteTip(SpriteID sprite, StringID tool_tip) this->SetToolTip(tool_tip); } +/** + * Set the matrix dimension. + * @param columns The number of columns in the matrix (0 for autoscaling). + * @param rows The number of rows in the matrix (0 for autoscaling). + */ +void NWidgetCore::SetMatrixDimension(uint8_t columns, uint8_t rows) +{ + this->widget_data = static_cast((rows << MAT_ROW_START) | (columns << MAT_COL_START)); +} + /** * Set the text style of the nested widget. * @param colour TextColour to use. diff --git a/src/widget_type.h b/src/widget_type.h index 7736d6d6b5..5dae59a778 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -377,7 +377,7 @@ public: void SetStringTip(StringID string, StringID tool_tip); void SetSprite(SpriteID sprite); void SetSpriteTip(SpriteID sprite, StringID tool_tip); - void SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip) { this->SetDataTip(static_cast((rows << MAT_ROW_START) | (cols << MAT_COL_START)), tip); } + void SetMatrixDimension(uint8_t columns, uint8_t rows); void SetToolTip(StringID tool_tip); StringID GetToolTip() const; void SetTextStyle(TextColour colour, FontSize size);