MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateWidgetSize

Method UpdateWidgetSize

src/newgrf_gui.cpp:2158–2177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2156 }
2157
2158 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
2159 {
2160 switch (widget) {
2161 case WID_SP_PROGRESS_BAR:
2162 size = GetStringBoundingBox(GetString(STR_GENERATION_PROGRESS, GetParamMaxValue(100)));
2163 /* We need some spacing for the 'border' */
2164 size.height += WidgetDimensions::scaled.frametext.Horizontal();
2165 size.width += WidgetDimensions::scaled.frametext.Vertical();
2166 break;
2167
2168 case WID_SP_PROGRESS_TEXT: {
2169 uint64_t max_digits = GetParamMaxDigits(4);
2170 /* We really don't know the width. We could determine it by scanning the NewGRFs,
2171 * but this is the status window for scanning them... */
2172 size.width = std::max<uint>(size.width, GetStringBoundingBox(GetString(STR_NEWGRF_SCAN_STATUS, max_digits, max_digits)).width + padding.width);
2173 size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
2174 break;
2175 }
2176 }
2177 }
2178
2179 void DrawWidget(const Rect &r, WidgetID widget) const override
2180 {

Callers

nothing calls this directly

Calls 7

GetStringBoundingBoxFunction · 0.85
GetParamMaxValueFunction · 0.85
GetParamMaxDigitsFunction · 0.85
GetCharacterHeightFunction · 0.85
HorizontalMethod · 0.80
VerticalMethod · 0.80
GetStringFunction · 0.70

Tested by

no test coverage detected