Browse Source

Added GetMouseDragDelta() helper. No unlock threshold yet (#167)

ocornut 10 years ago
parent
commit
2d29907611
2 changed files with 9 additions and 0 deletions
  1. 8 0
      imgui.cpp
  2. 1 0
      imgui.h

+ 8 - 0
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();

+ 1 - 0
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);