ID Stack Tool: Display UI
| 18243 | |
| 18244 | // ID Stack Tool: Display UI |
| 18245 | void ImGui::ShowIDStackToolWindow(bool* p_open) |
| 18246 | { |
| 18247 | ImGuiContext& g = *GImGui; |
| 18248 | if ((g.NextWindowData.HasFlags & ImGuiNextWindowDataFlags_HasSize) == 0) |
| 18249 | SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); |
| 18250 | if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) |
| 18251 | { |
| 18252 | End(); |
| 18253 | return; |
| 18254 | } |
| 18255 | |
| 18256 | ImGuiDebugItemPathQuery* query = &g.DebugItemPathQuery; |
| 18257 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 18258 | tool->LastActiveFrame = g.FrameCount; |
| 18259 | const char* result_path = DebugItemPathQuery_GetResultAsPath(query, tool->OptHexEncodeNonAsciiChars); |
| 18260 | Text("0x%08X", query->MainID); |
| 18261 | SameLine(); |
| 18262 | 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."); |
| 18263 | |
| 18264 | // Ctrl+C to copy path |
| 18265 | const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime; |
| 18266 | PushStyleVarY(ImGuiStyleVar_FramePadding, 0.0f); |
| 18267 | Checkbox("Hex-encode non-ASCII", &tool->OptHexEncodeNonAsciiChars); |
| 18268 | SameLine(); |
| 18269 | Checkbox("Ctrl+C: copy path", &tool->OptCopyToClipboardOnCtrlC); |
| 18270 | PopStyleVar(); |
| 18271 | SameLine(); |
| 18272 | 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*"); |
| 18273 | if (tool->OptCopyToClipboardOnCtrlC && Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused)) |
| 18274 | { |
| 18275 | tool->CopyToClipboardLastTime = (float)g.Time; |
| 18276 | SetClipboardText(result_path); |
| 18277 | } |
| 18278 | |
| 18279 | Text("- Path \"%s\"", query->Complete ? result_path : ""); |
| 18280 | #ifdef IMGUI_ENABLE_TEST_ENGINE |
| 18281 | Text("- Label \"%s\"", query->MainID ? ImGuiTestEngine_FindItemDebugLabel(&g, query->MainID) : ""); |
| 18282 | #endif |
| 18283 | Separator(); |
| 18284 | |
| 18285 | // Display decorated stack |
| 18286 | if (query->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) |
| 18287 | { |
| 18288 | const float id_width = CalcTextSize("0xDDDDDDDD").x; |
| 18289 | TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 18290 | TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); |
| 18291 | TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width); |
| 18292 | TableHeadersRow(); |
| 18293 | for (int n = 0; n < query->Results.Size; n++) |
| 18294 | { |
| 18295 | ImGuiStackLevelInfo* info = &query->Results[n]; |
| 18296 | TableNextColumn(); |
| 18297 | Text("0x%08X", (n > 0) ? query->Results[n - 1].ID : 0); |
| 18298 | TableNextColumn(); |
| 18299 | DebugItemPathQuery_FormatLevelInfo(query, n, true, g.TempBuffer.Data, g.TempBuffer.Size); |
| 18300 | TextUnformatted(g.TempBuffer.Data); |
| 18301 | TableNextColumn(); |
| 18302 | Text("0x%08X", info->ID); |
nothing calls this directly
no test coverage detected