MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DrawAspectTab

Function DrawAspectTab

engine/Poseidon/Dev/Debug/DebugOverlay.cpp:1194–1288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1192 SDL_SetWindowPosition(s_window, SDL_WINDOWPOS_CENTERED_DISPLAY(disp), SDL_WINDOWPOS_CENTERED_DISPLAY(disp));
1193}
1194
1195void DrawAspectTab()
1196{
1197 AspectRatio::LiveControls& live = AspectRatio::Live();
1198 bool changed = false;
1199
1200 // --- Window size + monitor info + resize-to-ratio presets ---
1201 if (s_window)
1202 {
1203 int ww = 0, wh = 0;
1204 SDL_GetWindowSize(s_window, &ww, &wh);
1205 ImGui::Text("window : %d x %d (%.3f)", ww, wh,
1206 wh > 0 ? static_cast<float>(ww) / static_cast<float>(wh) : 0.0f);
1207 const SDL_DisplayID disp = SDL_GetDisplayForWindow(s_window);
1208 SDL_Rect ub{};
1209 if (SDL_GetDisplayUsableBounds(disp, &ub) && ub.h > 0)
1210 ImGui::Text("monitor: %d x %d (%.3f)", ub.w, ub.h, static_cast<float>(ub.w) / static_cast<float>(ub.h));
1211 ImGui::TextDisabled("resize window (fits monitor, centered):");
1212 struct RatioPreset
1213 {
1214 const char* label;
1215 float ratio;
1216 };
1217 static const RatioPreset presets[] = {
1218 {"32:9", 32.0f / 9.0f}, {"21:9", 21.0f / 9.0f}, {"16:9", 16.0f / 9.0f}, {"16:10", 16.0f / 10.0f},
1219 {"3:2", 3.0f / 2.0f}, {"4:3", 4.0f / 3.0f}, {"5:4", 5.0f / 4.0f},
1220 };
1221 for (int i = 0; i < static_cast<int>(sizeof(presets) / sizeof(presets[0])); ++i)
1222 {
1223 if (i > 0 && i != 4) // row break before "3:2"
1224 ImGui::SameLine();
1225 if (ImGui::Button(presets[i].label))
1226 {
1227 const float r = presets[i].ratio;
1228 Defer([r] { ResizeWindowToRatio(r); });
1229 }
1230 }
1231 ImGui::Separator();
1232 }
1233
1234 changed |= ImGui::Checkbox("Override enabled", &live.overrideEnabled);
1235 ImGui::SameLine();
1236 ImGui::TextDisabled("(off = display.cfg policy)");
1237 ImGui::Separator();
1238
1239 int style = static_cast<int>(live.style);
1240 if (ImGui::Combo("Display style", &style, "Modern\0Legacy\0"))
1241 {
1242 live.style = (style == 1) ? AspectRatio::Legacy : AspectRatio::Modern;
1243 changed = true;
1244 }
1245 int clamp = static_cast<int>(live.clamp);
1246 if (ImGui::Combo("Ultrawide clamp", &clamp,
1247 "Off\0"
1248 "21:9\0"
1249 "16:9\0"))
1250 {
1251 live.clamp = static_cast<AspectRatio::UltrawideClamp>(clamp);

Callers 1

DrawMainWindowFunction · 0.85

Calls 6

DeferFunction · 0.85
ResizeWindowToRatioFunction · 0.85
AspectReapplyFunction · 0.85
GetAspectSettingsMethod · 0.80
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected