ID Stack Tool: Display UI
| 22816 | |
| 22817 | // ID Stack Tool: Display UI |
| 22818 | void ImGui::ShowIDStackToolWindow(bool* p_open) |
| 22819 | { |
| 22820 | ImGuiContext& g = *GImGui; |
| 22821 | if ((g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasSize) == 0) |
| 22822 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 22823 | if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 22824 | { |
| 22825 | End(); |
| 22826 | return; |
| 22827 | } |
| 22828 | |
| 22829 | // Display hovered/active status |
| 22830 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 22831 | |
| 22832 | // Build and display path |
| 22833 | tool->ResultPathBuf.resize(0); |
| 22834 | for (int stack_n = 0; stack_n < tool->Results.Size; stack_n++) |
| 22835 | { |
| 22836 | char level_desc[256]; |
| 22837 | StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); |
| 22838 | tool->ResultPathBuf.append(stack_n == 0 ? "//" : "/"); |
| 22839 | for (int n = 0; level_desc[n]; n++) |
| 22840 | { |
| 22841 | if (level_desc[n] == '/') |
| 22842 | tool->ResultPathBuf.append("\\"); |
| 22843 | tool->ResultPathBuf.append(level_desc + n, level_desc + n + 1); |
| 22844 | } |
| 22845 | } |
| 22846 | Text("0x%08X", tool->QueryId); |
| 22847 | SameLine(); |
| 22848 | 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."); |
| 22849 | |
| 22850 | // CTRL+C to copy path |
| 22851 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 22852 | SameLine(); |
| 22853 | PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); Checkbox("Ctrl+C: copy path", &tool->CopyToClipboardOnCtrlC); PopStyleVar(); |
| 22854 | SameLine(); |
| 22855 | 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*"); |
| 22856 | if (tool->CopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) |
| 22857 | { |
| 22858 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 22859 | SetClipboardText(tool->ResultPathBuf.c_str()); |
| 22860 | } |
| 22861 | |
| 22862 | Text("- Path \"%s\"", tool->ResultPathBuf.c_str()); |
| 22863 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 22864 | Text("- Label \"%s\"", tool->QueryId ? ImGuiTestEngine_FindItemDebugLabel(&g, tool->QueryId) : ""); |
| 22865 | #endif |
| 22866 | |
| 22867 | Separator(); |
| 22868 | |
| 22869 | // Display decorated stack |
| 22870 | tool->LastActiveFrame = g.FrameCount; |
| 22871 | if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) |
| 22872 | { |
| 22873 | const float id_width = CalcTextSize("0xDDDDDDDD").x; |
| 22874 | TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 22875 | TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); |
nothing calls this directly
no test coverage detected