Debug Tools: Metrics: Improved Monitors and Viewports minimap display. Highlight on hover. (amends)
diff --git a/imgui.cpp b/imgui.cpp
index cbc8153..5635f19 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -19646,10 +19646,19 @@
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
+ // Draw monitor and calculate their boundaries
float SCALE = 1.0f / 8.0f;
- ImRect bb_full(g.Viewports[0]->Pos, g.Viewports[0]->Pos + g.Viewports[0]->Size);
+ ImRect bb_full(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
+ for (ImGuiPlatformMonitor& monitor : g.PlatformIO.Monitors)
+ bb_full.Add(ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize));
ImVec2 p = window->DC.CursorPos;
ImVec2 off = p - bb_full.Min * SCALE;
+ for (ImGuiPlatformMonitor& monitor : g.PlatformIO.Monitors)
+ {
+ ImRect monitor_draw_bb(off + (monitor.MainPos) * SCALE, off + (monitor.MainPos + monitor.MainSize) * SCALE);
+ window->DrawList->AddRect(monitor_draw_bb.Min, monitor_draw_bb.Max, (g.DebugMetricsConfig.HighlightMonitorIdx == g.PlatformIO.Monitors.index_from_ptr(&monitor)) ? IM_COL32(255, 255, 0, 255) : ImGui::GetColorU32(ImGuiCol_Border), 4.0f);
+ window->DrawList->AddRectFilled(monitor_draw_bb.Min, monitor_draw_bb.Max, ImGui::GetColorU32(ImGuiCol_Border, 0.10f), 4.0f);
+ }
// Draw viewports
for (ImGuiViewportP* viewport : g.Viewports)
@@ -20045,6 +20054,7 @@
// Viewports
if (TreeNode("Viewports", "Viewports (%d)", g.Viewports.Size))
{
+ cfg->HighlightMonitorIdx = -1;
bool open = TreeNode("Monitors", "Monitors (%d)", g.PlatformIO.Monitors.Size);
SameLine();
MetricsHelpMarker("Dear ImGui uses monitor data:\n- to query DPI settings on a per monitor basis\n- to position popup/tooltips so they don't straddle monitors.");
@@ -20057,6 +20067,8 @@
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())
+ cfg->HighlightMonitorIdx = i;
}
TreePop();
}
@@ -20078,10 +20090,14 @@
if (viewports.Size > 1)
ImQsort(viewports.Data, viewports.Size, sizeof(ImGuiViewport*), ViewportComparerByLastFocusedStampCount);
for (ImGuiViewportP* viewport : viewports)
+ {
BulletText("Viewport #%d, ID: 0x%08X, LastFocused = %08d, PlatformFocused = %s, Window: \"%s\"",
viewport->Idx, viewport->ID, viewport->LastFocusedStampCount,
(g.PlatformIO.Platform_GetWindowFocus && viewport->PlatformWindowCreated) ? (g.PlatformIO.Platform_GetWindowFocus(viewport) ? "1" : "0") : "N/A",
viewport->Window ? viewport->Window->Name : "N/A");
+ if (IsItemHovered())
+ cfg->HighlightViewportID = viewport->ID;
+ }
TreePop();
}