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

Method BeginTooltipEx

tutorials/common/imgui/imgui.cpp:9698–9728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9696}
9697
9698void ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags)
9699{
9700 ImGuiContext& g = *GImGui;
9701
9702 if (g.DragDropWithinSource || g.DragDropWithinTarget)
9703 {
9704 // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
9705 // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
9706 // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do.
9707 //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
9708 ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
9709 SetNextWindowPos(tooltip_pos);
9710 SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
9711 //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
9712 tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip;
9713 }
9714
9715 char window_name[16];
9716 ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
9717 if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip)
9718 if (ImGuiWindow* window = FindWindowByName(window_name))
9719 if (window->Active)
9720 {
9721 // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
9722 window->Hidden = true;
9723 window->HiddenFramesCanSkipItems = 1; // FIXME: This may not be necessary?
9724 ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
9725 }
9726 ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
9727 Begin(window_name, NULL, flags | extra_window_flags);
9728}
9729
9730void ImGui::EndTooltip()
9731{

Callers

nothing calls this directly

Calls 2

ImVec2Function · 0.85
ImFormatStringFunction · 0.85

Tested by

no test coverage detected