Stack Tool: Display UI
| 19975 | |
| 19976 | // Stack Tool: Display UI |
| 19977 | void ImGui::ShowStackToolWindow(bool* p_open) |
| 19978 | { |
| 19979 | ImGuiContext& g = *GImGui; |
| 19980 | if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize)) |
| 19981 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 19982 | if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 19983 | { |
| 19984 | End(); |
| 19985 | return; |
| 19986 | } |
| 19987 | |
| 19988 | // Display hovered/active status |
| 19989 | ImGuiStackTool* tool = &g.DebugStackTool; |
| 19990 | const ImGuiID hovered_id = g.HoveredIdPreviousFrame; |
| 19991 | const ImGuiID active_id = g.ActiveId; |
| 19992 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 19993 | 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) : ""); |
| 19994 | #else |
| 19995 | Text("HoveredId: 0x%08X, ActiveId: 0x%08X", hovered_id, active_id); |
| 19996 | #endif |
| 19997 | SameLine(); |
| 19998 | 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."); |
| 19999 | |
| 20000 | // CTRL+C to copy path |
| 20001 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 20002 | Checkbox("Ctrl+C: copy path to clipboard", &tool->CopyToClipboardOnCtrlC); |
| 20003 | SameLine(); |
| 20004 | 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*"); |
| 20005 | if (tool->CopyToClipboardOnCtrlC && IsKeyDown(ImGuiMod_Ctrl) && IsKeyPressed(ImGuiKey_C)) |
| 20006 | { |
| 20007 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 20008 | char* p = g.TempBuffer.Data; |
| 20009 | char* p_end = p + g.TempBuffer.Size; |
| 20010 | for (int stack_n = 0; stack_n < tool->Results.Size && p + 3 < p_end; stack_n++) |
| 20011 | { |
| 20012 | *p++ = '/'; |
| 20013 | char level_desc[256]; |
| 20014 | StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); |
| 20015 | for (int n = 0; level_desc[n] && p + 2 < p_end; n++) |
| 20016 | { |
| 20017 | if (level_desc[n] == '/') |
| 20018 | *p++ = '\\'; |
| 20019 | *p++ = level_desc[n]; |
| 20020 | } |
| 20021 | } |
| 20022 | *p = '\0'; |
| 20023 | SetClipboardText(g.TempBuffer.Data); |
| 20024 | } |
| 20025 | |
| 20026 | // Display decorated stack |
| 20027 | tool->LastActiveFrame = g.FrameCount; |
| 20028 | if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) |
| 20029 | { |
| 20030 | const float id_width = CalcTextSize("0xDDDDDDDD").x; |
| 20031 | TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 20032 | TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); |
| 20033 | TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 20034 | TableHeadersRow(); |
nothing calls this directly
no test coverage detected