Skip to content

Commit

Permalink
pcmockup: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Dec 7, 2018
1 parent 05aaf48 commit 1fad7ca
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pcmockup/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand All @@ -82,15 +83,15 @@ 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))
{
me->lastDragDelta[button] = (ImVec2) { 0, 0 };
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);
Expand Down

0 comments on commit 1fad7ca

Please sign in to comment.