From 1fad7ca618408814deb8fcfffef9170a6de9ddfe Mon Sep 17 00:00:00 2001 From: Helco Date: Fri, 7 Dec 2018 13:59:06 +0100 Subject: [PATCH] pcmockup: tweaks --- pcmockup/window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pcmockup/window.c b/pcmockup/window.c index e12f0dd..74c345a 100644 --- a/pcmockup/window.c +++ b/pcmockup/window.c @@ -2,6 +2,7 @@ #include "window_internal.h" #define MOUSE_BUTTON_COUNT 5 // even imgui uses this "magic" number +#define DEFAULT_MOUSE_THRESHOLD -1.0f struct Window { @@ -72,7 +73,7 @@ void window_update(Window* me) static bool window_shouldHandleDrag(const Window* me, int button) { - if (!igIsMouseDragging(button, -1.0f) || me->onDrag == NULL) + if (!igIsMouseDragging(button, DEFAULT_MOUSE_THRESHOLD) || me->onDrag == NULL) return false; const ImVec2 dragSource = igGetIO()->MouseClickedPos[button]; return @@ -82,7 +83,7 @@ static bool window_shouldHandleDrag(const Window* me, int button) void window_handleDragEvent(Window* me) { - for (int button = 0; button < 4; button++) + for (int button = 0; button < MOUSE_BUTTON_COUNT; button++) { if (!window_shouldHandleDrag(me, button)) { @@ -90,7 +91,7 @@ void window_handleDragEvent(Window* me) continue; } ImVec2 lastDelta = me->lastDragDelta[button], delta; - igGetMouseDragDelta_nonUDT(&delta, button, -1.0f); + igGetMouseDragDelta_nonUDT(&delta, button, DEFAULT_MOUSE_THRESHOLD); ImVec2 deltaDelta = { delta.x - lastDelta.x, delta.y - lastDelta.y }; me->onDrag(me, button, deltaDelta, me->onDragUserdata);