Now that selection, translation, and scaling of windows is worked out, we can add support for our final supported gesture, flinging the window into a section of the screen to dock it. Imagine the user poking a window and then tossing it in whichever direction they choose with literally a flick of the wrist. Who wouldn't want to have the ability to dismissively toss around windows?
Implementing the gesture detection is straightforward enough; the Swipe
gesture is triggered when the user draws a straight (-ish) line in the air, rapidly. In addition the gesture can be active while the user is still drawing the swipe, which allows us to provide a little bit of instant visual feedback.
Going back to our previous switch(gesture.type())
block we can insert another case to handle Swipe
gestures:
case Leap::Gesture::TYPE_SWIPE: { auto swipe = Leap::SwipeGesture(gesture); auto direction = swipe.direction();
The swipe
direction is a vector representing...