MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / ShowIDStackToolWindow

Method ShowIDStackToolWindow

external/imgui/imgui.cpp:18252–18316  ·  view source on GitHub ↗

ID Stack Tool: Display UI

Source from the content-addressed store, hash-verified

18250
18251// ID Stack Tool: Display UI
18252void ImGui::ShowIDStackToolWindow(bool* p_open)
18253{
18254 ImGuiContext& g = *GImGui;
18255 if ((g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasSize) == 0)
18256 SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver);
18257 if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
18258 {
18259 End();
18260 return;
18261 }
18262
18263 ImGuiDebugItemPathQuery* query = &g.DebugItemPathQuery;
18264 ImGuiIDStackTool* tool = &g.DebugIDStackTool;
18265 tool->LastActiveFrame = g.FrameCount;
18266 const char* result_path = DebugItemPathQuery_GetResultAsPath(query, tool->OptHexEncodeNonAsciiChars);
18267 Text("0x%08X", query->MainID);
18268 SameLine();
18269 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.");
18270
18271 // Ctrl+C to copy path
18272 const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime;
18273 PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f);
18274 Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars);
18275 SameLine();
18276 Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC);
18277 PopStyleVar();
18278 SameLine();
18279 TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*");
18280 if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused))
18281 {
18282 tool->CopyToClipboardLastTime = (float)g.Time;
18283 SetClipboardText(result_path);
18284 }
18285
18286 Text("- Path \"%s\"", query->Complete ? result_path : "");
18287#ifdef IMGUI_ENABLE_TEST_ENGINE
18288 Text("- Label \"%s\"", query->MainID ? ImGuiTestEngine_FindItemDebugLabel(&g, query->MainID) : "");
18289#endif
18290 Separator();
18291
18292 // Display decorated stack
18293 if (query->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
18294 {
18295 const float id_width = CalcTextSize("0xDDDDDDDD").x;
18296 TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width);
18297 TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch);
18298 TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width);
18299 TableHeadersRow();
18300 for (int n = 0; n < query->Results.Size; n++)
18301 {
18302 ImGuiStackLevelInfo* info = &query->Results[n];
18303 TableNextColumn();
18304 Text("0x%08X", (n > 0) ? query->Results[n - 1].ID : 0);
18305 TableNextColumn();
18306 DebugItemPathQuery_FormatLevelInfo(query, n, true, g.TempBuffer.Data, g.TempBuffer.Size);
18307 TextUnformatted(g.TempBuffer.Data);
18308 TableNextColumn();
18309 Text("0x%08X", info->ID);

Callers

nothing calls this directly

Calls 6

ImVec2Function · 0.85
GetCurrentWindowFunction · 0.85
MetricsHelpMarkerFunction · 0.85
ImVec4Class · 0.85

Tested by

no test coverage detected