diff --git a/imgui.cpp b/imgui.cpp index 6ae271089..bb2bffccb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2541,6 +2541,14 @@ ImVec2 ImGui::GetMousePos() return GImGui->IO.MousePos; } +ImVec2 ImGui::GetMouseDragDelta() +{ + ImGuiState& g = *GImGui; + if (g.IO.MouseDown[0]) + return g.IO.MousePos - g.IO.MouseClickedPos[0]; // Assume we can only get active with left-mouse button (at the moment). + return ImVec2(0.0f, 0.0f); +} + bool ImGui::IsItemHovered() { ImGuiWindow* window = GetCurrentWindow(); diff --git a/imgui.h b/imgui.h index 8f28d5fd6..5ba5e8bb6 100644 --- a/imgui.h +++ b/imgui.h @@ -371,6 +371,7 @@ namespace ImGui IMGUI_API bool IsMouseHoveringRect(const ImVec2& rect_min, const ImVec2& rect_max);// is mouse hovering given bounding rect IMGUI_API bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls + IMGUI_API ImVec2 GetMouseDragDelta(); // dragging amount - also see: GetItemActiveDragDelta(). IMGUI_API float GetTime(); IMGUI_API int GetFrameCount(); IMGUI_API const char* GetStyleColName(ImGuiCol idx);