mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Tooltip: Testing DragDropWithinSourceOrTarget in BeginTooltipEx() instead of just BeginTooltip() - feel this was an overlook. Added tooltip flags instead of using bool.
This commit is contained in:
25
imgui.cpp
25
imgui.cpp
@ -7340,8 +7340,14 @@ void ImGui::SetScrollHereY(float center_y_ratio)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImGui::BeginTooltip()
|
||||
{
|
||||
BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None);
|
||||
}
|
||||
|
||||
void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
if (g.DragDropWithinSourceOrTarget)
|
||||
{
|
||||
// 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)
|
||||
@ -7352,21 +7358,12 @@ void ImGui::BeginTooltip()
|
||||
SetNextWindowPos(tooltip_pos);
|
||||
SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
|
||||
//PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
|
||||
BeginTooltipEx(0, true);
|
||||
tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip;
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginTooltipEx(0, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
|
||||
void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
char window_name[16];
|
||||
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
|
||||
if (override_previous_tooltip)
|
||||
if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip)
|
||||
if (ImGuiWindow* window = FindWindowByName(window_name))
|
||||
if (window->Active)
|
||||
{
|
||||
@ -7387,11 +7384,7 @@ void ImGui::EndTooltip()
|
||||
|
||||
void ImGui::SetTooltipV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.DragDropWithinSourceOrTarget)
|
||||
BeginTooltip();
|
||||
else
|
||||
BeginTooltipEx(0, true);
|
||||
BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip);
|
||||
TextV(fmt, args);
|
||||
EndTooltip();
|
||||
}
|
||||
|
Reference in New Issue
Block a user