From 9918ec31d6ce25d911b9ac7f7dcbf76b001e806b Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 13 Apr 2015 19:54:40 +0100 Subject: [PATCH] Added ResetMouseDragDelta() for iterative dragging operations --- imgui.cpp | 8 ++++++++ imgui.h | 1 + 2 files changed, 9 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 5190157f..b69b9cac 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2699,6 +2699,14 @@ ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold) return ImVec2(0.0f, 0.0f); } +void ImGui::ResetMouseDragDelta(int button) +{ + ImGuiState& g = *GImGui; + IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); + // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr + g.IO.MouseClickedPos[button] = g.IO.MousePos; +} + ImGuiMouseCursor ImGui::GetMouseCursor() { return GImGui->MouseCursor; diff --git a/imgui.h b/imgui.h index 4db43e1d..e2707d58 100644 --- a/imgui.h +++ b/imgui.h @@ -390,6 +390,7 @@ namespace ImGui 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(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking, also see: GetItemActiveDragDelta(). if lock_threshold < -1.0f uses io.MouseDraggingThreshold + IMGUI_API void ResetMouseDragDelta(int button = 0); IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type IMGUI_API float GetTime();