Debug Tools: Metrics: Improved Monitors and Viewports minimap display. Highlight on hover.
Added ImGuiViewport ID in Master branch.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 7d2b1be..76131e5 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -68,6 +68,7 @@
over popups that are also child windows.
- Combo: Fixed not reusing windows optimally when used inside a popup stack.
- Debug Tools: Metrics: Fixed debug break in SetShortcutRouting() not handling ImGuiMod_Shortcut redirect.
+- Debug Tools: Metrics: Improved Monitors and Viewports minimap display. Highlight on hover.
- Debug Tools: Debug Log: Added "Input Routing" logging.
- Debug Tools: Added "nop" to IM_DEBUG_BREAK macro on GCC to work around GDB bug (#7266) [@Peter0x44]
- Backends: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by
diff --git a/imgui.cpp b/imgui.cpp
index ab03c38..716e770 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -1126,6 +1126,7 @@
static void RenderDimmedBackgrounds();
// Viewports
+const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter.
static void UpdateViewportsNewFrame();
}
@@ -3596,6 +3597,7 @@
// Create default viewport
ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
+ viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID;
g.Viewports.push_back(viewport);
g.TempBuffer.resize(1024 * 3 + 1, 0);
@@ -13975,7 +13977,7 @@
//-----------------------------------------------------------------------------
// [SECTION] METRICS/DEBUGGER WINDOW
//-----------------------------------------------------------------------------
-// - RenderViewportThumbnail() [Internal]
+// - DebugRenderViewportThumbnail() [Internal]
// - RenderViewportsThumbnails() [Internal]
// - DebugTextEncoding()
// - MetricsHelpMarker() [Internal]
@@ -14014,7 +14016,7 @@
ImRect thumb_r = thumb_window->Rect();
ImRect title_r = thumb_window->TitleBarRect();
thumb_r = ImRect(ImTrunc(off + thumb_r.Min * scale), ImTrunc(off + thumb_r.Max * scale));
- title_r = ImRect(ImTrunc(off + title_r.Min * scale), ImTrunc(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height
+ title_r = ImRect(ImTrunc(off + title_r.Min * scale), ImTrunc(off + ImVec2(title_r.Max.x, title_r.Min.y + title_r.GetHeight() * 3.0f) * scale)); // Exaggerate title bar height
thumb_r.ClipWithFull(bb);
title_r.ClipWithFull(bb);
const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight);
@@ -14024,6 +14026,8 @@
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r.Min, GetColorU32(ImGuiCol_Text, alpha_mul), thumb_window->Name, FindRenderedTextEnd(thumb_window->Name));
}
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul));
+ if (viewport->ID == g.DebugMetricsConfig.HighlightViewportID)
+ window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255));
}
static void RenderViewportsThumbnails()
@@ -14031,13 +14035,12 @@
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
- // We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports.
float SCALE = 1.0f / 8.0f;
- ImRect bb_full(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
- for (ImGuiViewportP* viewport : g.Viewports)
- bb_full.Add(viewport->GetMainRect());
+ ImRect bb_full(g.Viewports[0]->Pos, g.Viewports[0]->Pos + g.Viewports[0]->Size);
ImVec2 p = window->DC.CursorPos;
ImVec2 off = p - bb_full.Min * SCALE;
+
+ // Draw viewports
for (ImGuiViewportP* viewport : g.Viewports)
{
ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE);
@@ -14280,7 +14283,7 @@
MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.");
if (Checkbox("Show Item Picker", &g.DebugItemPickerActive) && g.DebugItemPickerActive)
DebugStartItemPicker();
- Checkbox("Show \"Debug Break\" buttons in other sections", &g.IO.ConfigDebugIsDebuggerPresent);
+ Checkbox("Show \"Debug Break\" buttons in other sections (io.ConfigDebugIsDebuggerPresent)", &g.IO.ConfigDebugIsDebuggerPresent);
SeparatorText("Visualize");
@@ -14416,9 +14419,14 @@
// Viewports
if (TreeNode("Viewports", "Viewports (%d)", g.Viewports.Size))
{
- Indent(GetTreeNodeToLabelSpacing());
- RenderViewportsThumbnails();
- Unindent(GetTreeNodeToLabelSpacing());
+ SetNextItemOpen(true, ImGuiCond_Once);
+ if (TreeNode("Windows Minimap"))
+ {
+ RenderViewportsThumbnails();
+ TreePop();
+ }
+ cfg->HighlightViewportID = 0;
+
for (ImGuiViewportP* viewport : g.Viewports)
DebugNodeViewport(viewport);
TreePop();
@@ -15120,8 +15128,12 @@
void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
{
+ ImGuiContext& g = *GImGui;
SetNextItemOpen(true, ImGuiCond_Once);
- if (TreeNode("viewport0", "Viewport #%d", 0))
+ bool open = TreeNode("viewport0", "Viewport #%d", 0);
+ if (IsItemHovered())
+ g.DebugMetricsConfig.HighlightViewportID = viewport->ID;
+ if (open)
{
ImGuiWindowFlags flags = viewport->Flags;
BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nWorkArea Offset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f",
diff --git a/imgui.h b/imgui.h
index 4d79f20..8d05fba 100644
--- a/imgui.h
+++ b/imgui.h
@@ -3123,6 +3123,7 @@
// - Windows are generally trying to stay within the Work Area of their host viewport.
struct ImGuiViewport
{
+ ImGuiID ID; // Unique identifier for the viewport
ImGuiViewportFlags Flags; // See ImGuiViewportFlags_
ImVec2 Pos; // Main Area: Position of the viewport (Dear ImGui coordinates are the same as OS desktop/native coordinates)
ImVec2 Size; // Main Area: Size of the viewport.
diff --git a/imgui_internal.h b/imgui_internal.h
index d826fbc..2e55ff3 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1865,6 +1865,8 @@
bool ShowAtlasTintedWithTextColor = false;
int ShowWindowsRectsType = -1;
int ShowTablesRectsType = -1;
+ int HighlightMonitorIdx = -1;
+ ImGuiID HighlightViewportID = 0;
};
struct ImGuiStackLevelInfo