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

Method UpdateMatrixSize

src/graph_gui.cpp:645–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643 }};
644
645 void UpdateMatrixSize(WidgetID widget, Dimension &size, Dimension &resize, auto labels)
646 {
647 size = {};
648 for (const StringID &str : labels) {
649 size = maxdim(size, GetStringBoundingBox(str, FS_SMALL));
650 }
651
652 size.width += WidgetDimensions::scaled.framerect.Horizontal();
653 size.height += WidgetDimensions::scaled.framerect.Vertical();
654
655 /* Set fixed height for number of ranges. */
656 size.height *= static_cast<uint>(std::size(labels));
657
658 resize.width = 0;
659 resize.height = 0;
660 this->GetWidget<NWidgetCore>(widget)->SetMatrixDimension(1, ClampTo<uint32_t>(std::size(labels)));
661 }
662
663public:
664 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override

Callers 1

UpdateWidgetSizeMethod · 0.95

Calls 6

maxdimFunction · 0.85
GetStringBoundingBoxFunction · 0.85
HorizontalMethod · 0.80
VerticalMethod · 0.80
SetMatrixDimensionMethod · 0.80
sizeFunction · 0.50

Tested by

no test coverage detected