|
|
@@ -3794,6 +3794,7 @@ void ImGui::NewFrame()
|
|
|
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
|
|
|
g.DragDropAcceptIdCurr = 0;
|
|
|
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
|
|
+ g.DragDropWithinSourceOrTarget = false;
|
|
|
|
|
|
// Update keyboard input state
|
|
|
memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
|
|
|
@@ -5162,7 +5163,23 @@ void ImGui::SetTooltip(const char* fmt, ...)
|
|
|
|
|
|
void ImGui::BeginTooltip()
|
|
|
{
|
|
|
- BeginTooltipEx(0, false);
|
|
|
+ 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)
|
|
|
+ // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
|
|
|
+ // 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.
|
|
|
+ //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
|
|
|
+ ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BeginTooltipEx(0, false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ImGui::EndTooltip()
|
|
|
@@ -7958,7 +7975,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|
|
bool hovered = ItemHoverable(bb, id);
|
|
|
|
|
|
// Drag source doesn't report as hovered
|
|
|
- if (hovered && g.DragDropActive && g.DragDropPayload.SourceId == id)
|
|
|
+ if (hovered && g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover))
|
|
|
hovered = false;
|
|
|
|
|
|
// Special mode for Drag and Drop where holding button pressed for a long time while dragging another item triggers the button
|
|
|
@@ -8111,7 +8128,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
|
|
MarkItemValueChanged(id);
|
|
|
|
|
|
// Render
|
|
|
- const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
RenderNavHighlight(bb, id);
|
|
|
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
|
|
RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);
|
|
|
@@ -8160,7 +8177,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
|
|
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
|
|
|
|
|
// Render
|
|
|
- const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
RenderNavHighlight(bb, id);
|
|
|
RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
|
|
|
RenderArrow(bb.Min + ImVec2(ImMax(0.0f, size.x - g.FontSize - g.Style.FramePadding.x), ImMax(0.0f, size.y - g.FontSize - g.Style.FramePadding.y)), dir);
|
|
|
@@ -8279,7 +8296,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
|
|
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
|
|
|
|
|
// Render
|
|
|
- const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
|
|
RenderNavHighlight(bb, id);
|
|
|
RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding));
|
|
|
if (bg_col.w > 0.0f)
|
|
|
@@ -13525,12 +13542,13 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|
|
g.DragDropSourceFlags = flags;
|
|
|
g.DragDropMouseButton = mouse_button;
|
|
|
}
|
|
|
+ g.DragDropWithinSourceOrTarget = true;
|
|
|
|
|
|
if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
|
|
|
{
|
|
|
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
|
|
|
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
|
|
|
- BeginDragDropTooltip();
|
|
|
+ BeginTooltip();
|
|
|
if (g.DragDropActive && g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
|
|
{
|
|
|
ImGuiWindow* tooltip_window = g.CurrentWindow;
|
|
|
@@ -13551,32 +13569,15 @@ void ImGui::EndDragDropSource()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
IM_ASSERT(g.DragDropActive);
|
|
|
+ IM_ASSERT(g.DragDropWithinSourceOrTarget && "Not after a BeginDragDropSource()?");
|
|
|
|
|
|
if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
|
|
|
- EndDragDropTooltip();
|
|
|
+ EndTooltip();
|
|
|
|
|
|
// Discard the drag if have not called SetDragDropPayload()
|
|
|
if (g.DragDropPayload.DataFrameCount == -1)
|
|
|
ClearDragDrop();
|
|
|
-}
|
|
|
-
|
|
|
-void ImGui::BeginDragDropTooltip()
|
|
|
-{
|
|
|
- // 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)
|
|
|
- // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
|
|
|
- // 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.
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
|
|
|
- ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
|
|
|
- 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);
|
|
|
-}
|
|
|
-
|
|
|
-void ImGui::EndDragDropTooltip()
|
|
|
-{
|
|
|
- EndTooltip();
|
|
|
+ g.DragDropWithinSourceOrTarget = false;
|
|
|
}
|
|
|
|
|
|
// Use 'cond' to choose to submit payload on drag start or every frame
|
|
|
@@ -13636,8 +13637,10 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
|
|
|
if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
|
|
|
return false;
|
|
|
|
|
|
+ IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
|
|
|
g.DragDropTargetRect = bb;
|
|
|
g.DragDropTargetId = id;
|
|
|
+ g.DragDropWithinSourceOrTarget = true;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -13664,8 +13667,10 @@ bool ImGui::BeginDragDropTarget()
|
|
|
if (g.DragDropPayload.SourceId == id)
|
|
|
return false;
|
|
|
|
|
|
+ IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
|
|
|
g.DragDropTargetRect = display_rect;
|
|
|
g.DragDropTargetId = id;
|
|
|
+ g.DragDropWithinSourceOrTarget = true;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -13721,8 +13726,10 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
|
|
// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
|
|
|
void ImGui::EndDragDropTarget()
|
|
|
{
|
|
|
- ImGuiContext& g = *GImGui; (void)g;
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
IM_ASSERT(g.DragDropActive);
|
|
|
+ IM_ASSERT(g.DragDropWithinSourceOrTarget);
|
|
|
+ g.DragDropWithinSourceOrTarget = false;
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
@@ -13948,7 +13955,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
(flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
|
|
|
(flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
|
|
|
ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, GetScrollMaxX(window), window->Scroll.y, GetScrollMaxY(window));
|
|
|
- ImGui::BulletText("Active: %d, WriteAccessed: %d", window->Active, window->WriteAccessed);
|
|
|
+ ImGui::BulletText("Active: %d, WriteAccessed: %d", window->Active || window->WasActive, window->WriteAccessed);
|
|
|
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
|
|
|
ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
|
|
|
if (!window->NavRectRel[0].IsInverted())
|