ID Stack Tool: Display UI
| 17779 | |
| 17780 | // ID Stack Tool: Display UI |
| 17781 | void ImGui::ShowIDStackToolWindow(bool* p_open) |
| 17782 | { |
| 17783 | ImGuiContext& g = *GImGui; |
| 17784 | if ((g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasSize) == 0) |
| 17785 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 17786 | if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 17787 | { |
| 17788 | End(); |
| 17789 | return; |
| 17790 | } |
| 17791 | |
| 17792 | // Display hovered/active status |
| 17793 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 17794 | |
| 17795 | // Build and display path |
| 17796 | tool->ResultTempBuf.resize(0); |
| 17797 | for (int stack_n = 0; stack_n < tool->Results.Size; stack_n++) |
| 17798 | { |
| 17799 | char level_desc[256]; |
| 17800 | StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); |
| 17801 | tool->ResultTempBuf.append(stack_n == 0 ? "//" : "/"); |
| 17802 | for (const char* p = level_desc; *p != 0; ) |
| 17803 | { |
| 17804 | unsigned int c; |
| 17805 | const char* p_next = p + ImTextCharFromUtf8(&c, p, NULL); |
| 17806 | if (c == '/') |
| 17807 | tool->ResultTempBuf.append("\\"); |
| 17808 | if (c < 256 || !tool->OptHexEncodeNonAsciiChars) |
| 17809 | tool->ResultTempBuf.append(p, p_next); |
| 17810 | else for (; p < p_next; p++) |
| 17811 | tool->ResultTempBuf.appendf("\\x%02x", (unsigned char)*p); |
| 17812 | p = p_next; |
| 17813 | } |
| 17814 | } |
| 17815 | Text("0x%08X", tool->QueryMainId); |
| 17816 | SameLine(); |
| 17817 | 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."); |
| 17818 | |
| 17819 | // CTRL+C to copy path |
| 17820 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 17821 | PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); |
| 17822 | Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars); |
| 17823 | SameLine(); |
| 17824 | Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC); |
| 17825 | PopStyleVar(); |
| 17826 | SameLine(); |
| 17827 | 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*"); |
| 17828 | if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) |
| 17829 | { |
| 17830 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 17831 | SetClipboardText(tool->ResultTempBuf.c_str()); |
| 17832 | } |
| 17833 | |
| 17834 | Text("- Path \"%s\"", tool->ResultTempBuf.c_str()); |
| 17835 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 17836 | Text("- Label \"%s\"", tool->QueryMainId ? ImGuiTestEngine_FindItemDebugLabel(&g, tool->QueryMainId) : ""); |
| 17837 | #endif |
| 17838 |
nothing calls this directly
no test coverage detected