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

Method UpdateWidgetSize

src/misc_gui.cpp:641–652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639 }
640
641 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
642 {
643 if (widget != WID_TT_BACKGROUND) return;
644
645 auto str = this->text.GetDecodedString();
646 size.width = std::min<uint>(GetStringBoundingBox(str).width, ScaleGUITrad(194));
647 size.height = GetStringHeight(str, size.width);
648
649 /* Increase slightly to have some space around the box. */
650 size.width += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal();
651 size.height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical();
652 }
653
654 void DrawWidget(const Rect &r, WidgetID widget) const override
655 {

Callers

nothing calls this directly

Calls 6

GetStringBoundingBoxFunction · 0.85
GetStringHeightFunction · 0.85
GetDecodedStringMethod · 0.80
HorizontalMethod · 0.80
VerticalMethod · 0.80
ScaleGUITradFunction · 0.70

Tested by

no test coverage detected