MCPcopy Create free account
hub / github.com/RenderKit/embree / ShowStackToolWindow

Method ShowStackToolWindow

tutorials/common/imgui/imgui.cpp:14128–14202  ·  view source on GitHub ↗

Stack Tool: Display UI

Source from the content-addressed store, hash-verified

14126
14127// Stack Tool: Display UI
14128void ImGui::ShowStackToolWindow(bool* p_open)
14129{
14130 ImGuiContext& g = *GImGui;
14131 if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize))
14132 SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver);
14133 if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
14134 {
14135 End();
14136 return;
14137 }
14138
14139 // Display hovered/active status
14140 ImGuiStackTool* tool = &g.DebugStackTool;
14141 const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
14142 const ImGuiID active_id = g.ActiveId;
14143#ifdef IMGUI_ENABLE_TEST_ENGINE
14144 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) : "");
14145#else
14146 Text("HoveredId: 0x%08X, ActiveId: 0x%08X", hovered_id, active_id);
14147#endif
14148 SameLine();
14149 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.");
14150
14151 // CTRL+C to copy path
14152 const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime;
14153 Checkbox("Ctrl+C: copy path to clipboard", &tool->CopyToClipboardOnCtrlC);
14154 SameLine();
14155 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*");
14156 if (tool->CopyToClipboardOnCtrlC && IsKeyDown(ImGuiMod_Ctrl) && IsKeyPressed(ImGuiKey_C))
14157 {
14158 tool->CopyToClipboardLastTime = (float)g.Time;
14159 char* p = g.TempBuffer.Data;
14160 char* p_end = p + g.TempBuffer.Size;
14161 for (int stack_n = 0; stack_n < tool->Results.Size && p + 3 < p_end; stack_n++)
14162 {
14163 *p++ = '/';
14164 char level_desc[256];
14165 StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc));
14166 for (int n = 0; level_desc[n] && p + 2 < p_end; n++)
14167 {
14168 if (level_desc[n] == '/')
14169 *p++ = '\\';
14170 *p++ = level_desc[n];
14171 }
14172 }
14173 *p = '\0';
14174 SetClipboardText(g.TempBuffer.Data);
14175 }
14176
14177 // Display decorated stack
14178 tool->LastActiveFrame = g.FrameCount;
14179 if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
14180 {
14181 const float id_width = CalcTextSize("0xDDDDDDDD").x;
14182 TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width);
14183 TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch);
14184 TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width);
14185 TableHeadersRow();

Callers

nothing calls this directly

Calls 5

ImVec2Function · 0.85
GetCurrentWindowFunction · 0.85
MetricsHelpMarkerFunction · 0.85
ImVec4Class · 0.85
StackToolFormatLevelInfoFunction · 0.85

Tested by

no test coverage detected