MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / getCenteredPositionOnDisplay

Function getCenteredPositionOnDisplay

src/OpenLoco/src/Ui.cpp:148–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146 }
147
148 static Point getCenteredPositionOnDisplay(uint32_t displayIndex, int32_t width, int32_t height)
149 {
150 SDL_Rect displayBounds{};
151 const auto displayId = getDisplayIdFromIndex(displayIndex);
152 if (!SDL_GetDisplayUsableBounds(displayId, &displayBounds))
153 {
154 displayBounds = { 0, 0, width, height };
155 }
156
157 const auto x = displayBounds.x + std::max(0, (displayBounds.w - width) / 2);
158 const auto y = displayBounds.y + std::max(0, (displayBounds.h - height) / 2);
159 return { x, y };
160 }
161
162 static void centerWindowOnDisplay(SDL_Window* window, uint32_t displayIndex, int32_t width, int32_t height)
163 {

Callers 2

centerWindowOnDisplayFunction · 0.85
getWindowPropsFunction · 0.85

Calls 1

getDisplayIdFromIndexFunction · 0.85

Tested by

no test coverage detected