ID Stack Tool: Display UI
| 24158 | |
| 24159 | // ID Stack Tool: Display UI |
| 24160 | void ImGui::ShowIDStackToolWindow(bool* p_open) |
| 24161 | { |
| 24162 | ImGuiContext& g = *GImGui; |
| 24163 | if ((g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasSize) == 0) |
| 24164 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 24165 | if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 24166 | { |
| 24167 | End(); |
| 24168 | return; |
| 24169 | } |
| 24170 | |
| 24171 | ImGuiDebugItemPathQuery* query = &g.DebugItemPathQuery; |
| 24172 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 24173 | tool->LastActiveFrame = g.FrameCount; |
| 24174 | const char* result_path = DebugItemPathQuery_GetResultAsPath(query, tool->OptHexEncodeNonAsciiChars); |
| 24175 | Text("0x%08X", query->MainID); |
| 24176 | SameLine(); |
| 24177 | 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."); |
| 24178 | |
| 24179 | // Ctrl+C to copy path |
| 24180 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 24181 | PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); |
| 24182 | Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars); |
| 24183 | SameLine(); |
| 24184 | Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC); |
| 24185 | PopStyleVar(); |
| 24186 | SameLine(); |
| 24187 | 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*"); |
| 24188 | if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) |
| 24189 | { |
| 24190 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 24191 | SetClipboardText(result_path); |
| 24192 | } |
| 24193 | |
| 24194 | Text("- Path \"%s\"", query->Complete ? result_path : ""); |
| 24195 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 24196 | Text("- Label \"%s\"", query->MainID ? ImGuiTestEngine_FindItemDebugLabel(&g, query->MainID) : ""); |
| 24197 | #endif |
| 24198 | Separator(); |
| 24199 | |
| 24200 | // Display decorated stack |
| 24201 | if (query->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) |
| 24202 | { |
| 24203 | const float id_width = CalcTextSize("0xDDDDDDDD").x; |
| 24204 | TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 24205 | TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); |
| 24206 | TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 24207 | TableHeadersRow(); |
| 24208 | for (int n = 0; n < query->Results.Size; n++) |
| 24209 | { |
| 24210 | ImGuiStackLevelInfo* info = &query->Results[n]; |
| 24211 | TableNextColumn(); |
| 24212 | Text("0x%08X", (n > 0) ? query->Results[n - 1].ID : 0); |
| 24213 | TableNextColumn(); |
| 24214 | DebugItemPathQuery_FormatLevelInfo(query, n, true, g.TempBuffer.Data, g.TempBuffer.Size); |
| 24215 | TextUnformatted(g.TempBuffer.Data); |
| 24216 | TableNextColumn(); |
| 24217 | Text("0x%08X", info->ID); |
nothing calls this directly
no test coverage detected