1
0
mirror of https://github.com/ocornut/imgui.git synced 2025-01-31 03:53:44 +01:00

Viewports: update fallback monitor to primary monitor if there's one.

Amend 4b9bc490.
+ metrics: display fallback monitor.
This commit is contained in:
ocornut 2024-07-29 12:21:24 +02:00
parent 3552df562e
commit 5c9825c16d
3 changed files with 16 additions and 5 deletions

View File

@ -177,6 +177,7 @@ Other changes:
Docking+Viewports Branch: Docking+Viewports Branch:
- Viewports: Always update fallback monitor to primary monitor if there's one.
- Backends: OSX: Fixed NSAppKitVersion version limit for setWantsBestResolutionOpenGLSurface - Backends: OSX: Fixed NSAppKitVersion version limit for setWantsBestResolutionOpenGLSurface
usage. (#7814) [@YGXXD] usage. (#7814) [@YGXXD]
- Backends: SDL3: Fixed a bug preventing ImGuiViewportFlags_NoFocusOnAppearing support from - Backends: SDL3: Fixed a bug preventing ImGuiViewportFlags_NoFocusOnAppearing support from

View File

@ -15279,6 +15279,10 @@ static void ImGui::UpdateViewportsNewFrame()
g.PlatformMonitorsFullWorkRect.Add(monitor->WorkPos); g.PlatformMonitorsFullWorkRect.Add(monitor->WorkPos);
g.PlatformMonitorsFullWorkRect.Add(monitor->WorkPos + monitor->WorkSize); g.PlatformMonitorsFullWorkRect.Add(monitor->WorkPos + monitor->WorkSize);
} }
else
{
g.FallbackMonitor = g.PlatformIO.Monitors[0];
}
for (ImGuiPlatformMonitor& monitor : g.PlatformIO.Monitors) for (ImGuiPlatformMonitor& monitor : g.PlatformIO.Monitors)
{ {
g.PlatformMonitorsFullWorkRect.Add(monitor.WorkPos); g.PlatformMonitorsFullWorkRect.Add(monitor.WorkPos);
@ -20568,14 +20572,11 @@ void ImGui::ShowMetricsWindow(bool* p_open)
{ {
for (int i = 0; i < g.PlatformIO.Monitors.Size; i++) for (int i = 0; i < g.PlatformIO.Monitors.Size; i++)
{ {
const ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[i]; DebugNodePlatformMonitor(&g.PlatformIO.Monitors[i], "Monitor", i);
BulletText("Monitor #%d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)",
i, mon.DpiScale * 100.0f,
mon.MainPos.x, mon.MainPos.y, mon.MainPos.x + mon.MainSize.x, mon.MainPos.y + mon.MainSize.y, mon.MainSize.x, mon.MainSize.y,
mon.WorkPos.x, mon.WorkPos.y, mon.WorkPos.x + mon.WorkSize.x, mon.WorkPos.y + mon.WorkSize.y, mon.WorkSize.x, mon.WorkSize.y);
if (IsItemHovered()) if (IsItemHovered())
cfg->HighlightMonitorIdx = i; cfg->HighlightMonitorIdx = i;
} }
DebugNodePlatformMonitor(&g.FallbackMonitor, "Fallback", 0);
TreePop(); TreePop();
} }
@ -21492,6 +21493,14 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
} }
} }
void ImGui::DebugNodePlatformMonitor(ImGuiPlatformMonitor* monitor, const char* label, int idx)
{
BulletText("%s %d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)",
label, idx, monitor->DpiScale * 100.0f,
monitor->MainPos.x, monitor->MainPos.y, monitor->MainPos.x + monitor->MainSize.x, monitor->MainPos.y + monitor->MainSize.y, monitor->MainSize.x, monitor->MainSize.y,
monitor->WorkPos.x, monitor->WorkPos.y, monitor->WorkPos.x + monitor->WorkSize.x, monitor->WorkPos.y + monitor->WorkSize.y, monitor->WorkSize.x, monitor->WorkSize.y);
}
void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
{ {
if (window == NULL) if (window == NULL)

View File

@ -3944,6 +3944,7 @@ namespace ImGui
IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label); IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label);
IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack); IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack);
IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport); IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport);
IMGUI_API void DebugNodePlatformMonitor(ImGuiPlatformMonitor* monitor, const char* label, int idx);
IMGUI_API void DebugRenderKeyboardPreview(ImDrawList* draw_list); IMGUI_API void DebugRenderKeyboardPreview(ImDrawList* draw_list);
IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb); IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb);