ID Stack Tool: Display UI
| 18198 | |
| 18199 | // ID Stack Tool: Display UI |
| 18200 | void ImGui::ShowIDStackToolWindow(bool* p_open) |
| 18201 | { |
| 18202 | ImGuiContext& g = *GImGui; |
| 18203 | if ((g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasSize) == 0) |
| 18204 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 18205 | if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 18206 | { |
| 18207 | End(); |
| 18208 | return; |
| 18209 | } |
| 18210 | |
| 18211 | ImGuiDebugItemPathQuery* query = &g.DebugItemPathQuery; |
| 18212 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 18213 | tool->LastActiveFrame = g.FrameCount; |
| 18214 | const char* result_path = DebugItemPathQuery_GetResultAsPath(query, tool->OptHexEncodeNonAsciiChars); |
| 18215 | Text("0x%08X", query->MainID); |
| 18216 | SameLine(); |
| 18217 | 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."); |
| 18218 | |
| 18219 | // Ctrl+C to copy path |
| 18220 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 18221 | PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); |
| 18222 | Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars); |
| 18223 | SameLine(); |
| 18224 | Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC); |
| 18225 | PopStyleVar(); |
| 18226 | SameLine(); |
| 18227 | 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*"); |
| 18228 | if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) |
| 18229 | { |
| 18230 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 18231 | SetClipboardText(result_path); |
| 18232 | } |
| 18233 | |
| 18234 | Text("- Path \"%s\"", query->Complete ? result_path : ""); |
| 18235 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 18236 | Text("- Label \"%s\"", query->MainID ? ImGuiTestEngine_FindItemDebugLabel(&g, query->MainID) : ""); |
| 18237 | #endif |
| 18238 | Separator(); |
| 18239 | |
| 18240 | // Display decorated stack |
| 18241 | if (query->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) |
| 18242 | { |
| 18243 | const float id_width = CalcTextSize("0xDDDDDDDD").x; |
| 18244 | TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 18245 | TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); |
| 18246 | TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 18247 | TableHeadersRow(); |
| 18248 | for (int n = 0; n < query->Results.Size; n++) |
| 18249 | { |
| 18250 | ImGuiStackLevelInfo* info = &query->Results[n]; |
| 18251 | TableNextColumn(); |
| 18252 | Text("0x%08X", (n > 0) ? query->Results[n - 1].ID : 0); |
| 18253 | TableNextColumn(); |
| 18254 | DebugItemPathQuery_FormatLevelInfo(query, n, true, g.TempBuffer.Data, g.TempBuffer.Size); |
| 18255 | TextUnformatted(g.TempBuffer.Data); |
| 18256 | TableNextColumn(); |
| 18257 | Text("0x%08X", info->ID); |
nothing calls this directly
no test coverage detected