Internal: Added two missing ImVec2 operators for consistency. Split up DragDropWithinSourceOrTarget

ImVec2 *= ImVec2 to match  ImVec2 * ImVec2, likewise with /
docking
ocornut 5 years ago
parent b016f1ad70
commit 1d5612a05e

@ -3846,7 +3846,8 @@ void ImGui::NewFrame()
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr; g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
g.DragDropAcceptIdCurr = 0; g.DragDropAcceptIdCurr = 0;
g.DragDropAcceptIdCurrRectSurface = FLT_MAX; g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
g.DragDropWithinSourceOrTarget = false; g.DragDropWithinSource = false;
g.DragDropWithinTarget = false;
// Update keyboard input state // Update keyboard input state
memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration)); memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
@ -4237,9 +4238,9 @@ void ImGui::EndFrame()
// Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing. // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount) if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)
{ {
g.DragDropWithinSourceOrTarget = true; g.DragDropWithinSource = true;
SetTooltip("..."); SetTooltip("...");
g.DragDropWithinSourceOrTarget = false; g.DragDropWithinSource = false;
} }
// End frame // End frame
@ -7459,7 +7460,7 @@ void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags toolt
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.DragDropWithinSourceOrTarget) if (g.DragDropWithinSource || g.DragDropWithinTarget)
{ {
// 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) // 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. // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
@ -9119,7 +9120,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
g.DragDropMouseButton = mouse_button; g.DragDropMouseButton = mouse_button;
} }
g.DragDropSourceFrameCount = g.FrameCount; g.DragDropSourceFrameCount = g.FrameCount;
g.DragDropWithinSourceOrTarget = true; g.DragDropWithinSource = true;
if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
{ {
@ -9146,7 +9147,7 @@ void ImGui::EndDragDropSource()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(g.DragDropActive); IM_ASSERT(g.DragDropActive);
IM_ASSERT(g.DragDropWithinSourceOrTarget && "Not after a BeginDragDropSource()?"); IM_ASSERT(g.DragDropWithinSource && "Not after a BeginDragDropSource()?");
if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
EndTooltip(); EndTooltip();
@ -9154,7 +9155,7 @@ void ImGui::EndDragDropSource()
// Discard the drag if have not called SetDragDropPayload() // Discard the drag if have not called SetDragDropPayload()
if (g.DragDropPayload.DataFrameCount == -1) if (g.DragDropPayload.DataFrameCount == -1)
ClearDragDrop(); ClearDragDrop();
g.DragDropWithinSourceOrTarget = false; g.DragDropWithinSource = false;
} }
// Use 'cond' to choose to submit payload on drag start or every frame // Use 'cond' to choose to submit payload on drag start or every frame
@ -9216,10 +9217,10 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
if (window->SkipItems) if (window->SkipItems)
return false; return false;
IM_ASSERT(g.DragDropWithinSourceOrTarget == false); IM_ASSERT(g.DragDropWithinTarget == false);
g.DragDropTargetRect = bb; g.DragDropTargetRect = bb;
g.DragDropTargetId = id; g.DragDropTargetId = id;
g.DragDropWithinSourceOrTarget = true; g.DragDropWithinTarget = true;
return true; return true;
} }
@ -9246,10 +9247,10 @@ bool ImGui::BeginDragDropTarget()
if (g.DragDropPayload.SourceId == id) if (g.DragDropPayload.SourceId == id)
return false; return false;
IM_ASSERT(g.DragDropWithinSourceOrTarget == false); IM_ASSERT(g.DragDropWithinTarget == false);
g.DragDropTargetRect = display_rect; g.DragDropTargetRect = display_rect;
g.DragDropTargetId = id; g.DragDropTargetId = id;
g.DragDropWithinSourceOrTarget = true; g.DragDropWithinTarget = true;
return true; return true;
} }
@ -9313,8 +9314,8 @@ void ImGui::EndDragDropTarget()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(g.DragDropActive); IM_ASSERT(g.DragDropActive);
IM_ASSERT(g.DragDropWithinSourceOrTarget); IM_ASSERT(g.DragDropWithinTarget);
g.DragDropWithinSourceOrTarget = false; g.DragDropWithinTarget = false;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

@ -261,10 +261,12 @@ static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); } static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); } static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); } static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; } static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; } static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; }
static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; }
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); } static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); } static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); } static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
@ -1128,7 +1130,8 @@ struct ImGuiContext
// Drag and Drop // Drag and Drop
bool DragDropActive; bool DragDropActive;
bool DragDropWithinSourceOrTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block. bool DragDropWithinSource; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source.
bool DragDropWithinTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target.
ImGuiDragDropFlags DragDropSourceFlags; ImGuiDragDropFlags DragDropSourceFlags;
int DragDropSourceFrameCount; int DragDropSourceFrameCount;
int DragDropMouseButton; int DragDropMouseButton;
@ -1284,7 +1287,7 @@ struct ImGuiContext
ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging
MouseCursor = ImGuiMouseCursor_Arrow; MouseCursor = ImGuiMouseCursor_Arrow;
DragDropActive = DragDropWithinSourceOrTarget = false; DragDropActive = DragDropWithinSource = DragDropWithinTarget = false;
DragDropSourceFlags = ImGuiDragDropFlags_None; DragDropSourceFlags = ImGuiDragDropFlags_None;
DragDropSourceFrameCount = -1; DragDropSourceFrameCount = -1;
DragDropMouseButton = -1; DragDropMouseButton = -1;

Loading…
Cancel
Save