ID Stack Tool: Display UI
| 15172 | |
| 15173 | // ID Stack Tool: Display UI |
| 15174 | void ImGui::ShowIDStackToolWindow(bool* p_open) |
| 15175 | { |
| 15176 | ImGuiContext& g = *GImGui; |
| 15177 | if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize)) |
| 15178 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 15179 | if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 15180 | { |
| 15181 | End(); |
| 15182 | return; |
| 15183 | } |
| 15184 | |
| 15185 | // Display hovered/active status |
| 15186 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 15187 | const ImGuiID hovered_id = g.HoveredIdPreviousFrame; |
| 15188 | const ImGuiID active_id = g.ActiveId; |
| 15189 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 15190 | 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) : ""); |
| 15191 | #else |
| 15192 | Text("HoveredId: 0x%08X, ActiveId: 0x%08X", hovered_id, active_id); |
| 15193 | #endif |
| 15194 | SameLine(); |
| 15195 | 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."); |
| 15196 | |
| 15197 | // CTRL+C to copy path |
| 15198 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 15199 | Checkbox("Ctrl+C: copy path to clipboard", &tool->CopyToClipboardOnCtrlC); |
| 15200 | SameLine(); |
| 15201 | 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*"); |
| 15202 | if (tool->CopyToClipboardOnCtrlC && IsKeyDown(ImGuiMod_Ctrl) && IsKeyPressed(ImGuiKey_C)) |
| 15203 | { |
| 15204 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 15205 | char* p = g.TempBuffer.Data; |
| 15206 | char* p_end = p + g.TempBuffer.Size; |
| 15207 | for (int stack_n = 0; stack_n < tool->Results.Size && p + 3 < p_end; stack_n++) |
| 15208 | { |
| 15209 | *p++ = '/'; |
| 15210 | char level_desc[256]; |
| 15211 | StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc)); |
| 15212 | for (int n = 0; level_desc[n] && p + 2 < p_end; n++) |
| 15213 | { |
| 15214 | if (level_desc[n] == '/') |
| 15215 | *p++ = '\\'; |
| 15216 | *p++ = level_desc[n]; |
| 15217 | } |
| 15218 | } |
| 15219 | *p = '\0'; |
| 15220 | SetClipboardText(g.TempBuffer.Data); |
| 15221 | } |
| 15222 | |
| 15223 | // Display decorated stack |
| 15224 | tool->LastActiveFrame = g.FrameCount; |
| 15225 | if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) |
| 15226 | { |
| 15227 | const float id_width = CalcTextSize("0xDDDDDDDD").x; |
| 15228 | TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 15229 | TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); |
| 15230 | TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 15231 | TableHeadersRow(); |
nothing calls this directly
no test coverage detected