MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / resizeFrame

Method resizeFrame

src/openrct2/interface/WindowBase.cpp:74–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 }
73
74 void WindowBase::resizeFrame()
75 {
76 if (widgets.size() < 3)
77 return;
78
79 // Frame
80 auto& frameWidget = widgets[0];
81 if (frameWidget.type == WidgetType::frame)
82 {
83 frameWidget.right = width - 1;
84 frameWidget.bottom = height - 1;
85 }
86
87 // Title/caption
88 auto& titleWidget = widgets[1];
89 bool hasTitleWidget = titleWidget.type == WidgetType::caption;
90 if (hasTitleWidget)
91 titleWidget.right = width - 2;
92
93 // Close button
94 auto& closeButton = widgets[2];
95 if (closeButton.type == WidgetType::closeBox || closeButton.type == WidgetType::empty)
96 {
97 bool translucent = colours[closeButton.colour].flags.has(ColourFlag::translucent);
98 repositionCloseButton(closeButton, width, translucent);
99 }
100
101 // Page/resize widget
102 if (widgets.size() >= 4)
103 {
104 auto& pageWidget = widgets[3];
105 if (pageWidget.type == WidgetType::resize)
106 {
107 pageWidget.right = width - 1;
108 pageWidget.bottom = height - 1;
109 }
110 }
111
112 // Figure out if we need to push the other widgets down to accommodate a resized title/caption
113 auto preferredHeight = getTitleBarTargetHeight();
114 auto currentHeight = titleWidget.height() - 1;
115 auto heightDifference = preferredHeight - currentHeight;
116
117 if (!hasTitleWidget || heightDifference == 0)
118 return;
119
120 invalidate();
121
122 // Offset title and close button
123 titleWidget.bottom += heightDifference;
124 closeButton.bottom += heightDifference;
125
126 height += heightDifference;
127 minHeight += heightDifference;
128 maxHeight += heightDifference;
129
130 invalidate();
131

Callers 3

WindowResizeByDeltaFunction · 0.80
WindowSetResizeFunction · 0.80
ControlsMouseUpMethod · 0.80

Calls 5

repositionCloseButtonFunction · 0.85
heightMethod · 0.80
hasMethod · 0.65
invalidateFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected