MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / BeginTooltipEx

Method BeginTooltipEx

plugins/Cardinal/src/DearImGui/imgui.cpp:8429–8459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8427}
8428
8429void ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags)
8430{
8431 ImGuiContext& g = *GImGui;
8432
8433 if (g.DragDropWithinSource || g.DragDropWithinTarget)
8434 {
8435 // 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)
8436 // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
8437 // 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.
8438 //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
8439 ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
8440 SetNextWindowPos(tooltip_pos);
8441 SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
8442 //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
8443 tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip;
8444 }
8445
8446 char window_name[16];
8447 ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
8448 if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip)
8449 if (ImGuiWindow* window = FindWindowByName(window_name))
8450 if (window->Active)
8451 {
8452 // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
8453 window->Hidden = true;
8454 window->HiddenFramesCanSkipItems = 1; // FIXME: This may not be necessary?
8455 ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
8456 }
8457 ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
8458 Begin(window_name, NULL, flags | extra_window_flags);
8459}
8460
8461void ImGui::EndTooltip()
8462{

Callers

nothing calls this directly

Calls 2

ImVec2Function · 0.85
ImFormatStringFunction · 0.85

Tested by

no test coverage detected