MCPcopy Create free account
hub / github.com/Raais/ImStudio / ShowStackToolWindow

Method ShowStackToolWindow

src/third-party/imgui/imgui.cpp:13027–13089  ·  view source on GitHub ↗

Stack Tool: Display UI

Source from the content-addressed store, hash-verified

13025
13026// Stack Tool: Display UI
13027void ImGui::ShowStackToolWindow(bool* p_open)
13028{
13029 ImGuiContext& g = *GImGui;
13030 if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize))
13031 SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver);
13032 if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
13033 {
13034 End();
13035 return;
13036 }
13037
13038 // Display hovered/active status
13039 const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
13040 const ImGuiID active_id = g.ActiveId;
13041#ifdef IMGUI_ENABLE_TEST_ENGINE
13042 Text("HoveredId: 0x%08X (\"%s\"), ActiveId: 0x%08X (\"%s\")", hovered_id, hovered_id ? ImGuiTestEngine_FindItemDebugLabel(&g, hovered_id) : "", active_id, active_id ? ImGuiTestEngine_FindItemDebugLabel(&g, active_id) : "");
13043#else
13044 Text("HoveredId: 0x%08X, ActiveId: 0x%08X", hovered_id, active_id);
13045#endif
13046 SameLine();
13047 MetricsHelpMarker("Hover an item with the mouse to display elements of the ID Stack leading to the item's final ID.\nEach level of the stack correspond to a PushID() call.\nAll levels of the stack are hashed together to make the final ID of a widget (ID displayed at the bottom level of the stack).\nRead FAQ entry about the ID stack for details.");
13048
13049 // Display decorated stack
13050 ImGuiStackTool* tool = &g.DebugStackTool;
13051 tool->LastActiveFrame = g.FrameCount;
13052 if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
13053 {
13054 const float id_width = CalcTextSize("0xDDDDDDDD").x;
13055 TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width);
13056 TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch);
13057 TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width);
13058 TableHeadersRow();
13059 for (int n = 0; n < tool->Results.Size; n++)
13060 {
13061 ImGuiStackLevelInfo* info = &tool->Results[n];
13062 TableNextColumn();
13063 Text("0x%08X", (n > 0) ? tool->Results[n - 1].ID : 0);
13064
13065 TableNextColumn();
13066 ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? FindWindowByID(info->ID) : NULL;
13067 if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked)
13068 Text("\"%s\" [window]", window->Name);
13069 else if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id)
13070 TextUnformatted(info->Desc);
13071 else if (tool->StackLevel >= tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers.
13072 {
13073#ifdef IMGUI_ENABLE_TEST_ENGINE
13074 if (const char* label = ImGuiTestEngine_FindItemDebugLabel(&g, info->ID)) // Source: ImGuiTestEngine's ItemInfo()
13075 Text("??? \"%s\"", label);
13076 else
13077#endif
13078 TextUnformatted("???");
13079 }
13080
13081 TableNextColumn();
13082 Text("0x%08X", info->ID);
13083 if (n == tool->Results.Size - 1)
13084 TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_Header));

Callers

nothing calls this directly

Calls 3

ImVec2Function · 0.85
GetCurrentWindowFunction · 0.85
MetricsHelpMarkerFunction · 0.85

Tested by

no test coverage detected