X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fgesturedetector.h;h=8804dd1abc76a073439a1dae8d8fb64bd33cc4ce;hb=11ab96ba152e389814543a6398e2cd6f17a31092;hp=a6186fdef815dce6fa56956bd8261360b1632f3f;hpb=1b33313502f837e2b0d02d3f2d129c85a8c66064;p=libs%2Fgui.git diff --git a/source/input/gesturedetector.h b/source/input/gesturedetector.h index a6186fd..8804dd1 100644 --- a/source/input/gesturedetector.h +++ b/source/input/gesturedetector.h @@ -1,6 +1,7 @@ #ifndef MSP_INPUT_GESTUREDETECTOR_H_ #define MSP_INPUT_GESTUREDETECTOR_H_ +#include #include "device.h" namespace Msp { @@ -13,8 +14,10 @@ enum Gesture GESTURE_NONE, GESTURE_TAP, GESTURE_TAP_2, + GESTURE_TAP_3, GESTURE_DRAG, GESTURE_DRAG_2, + GESTURE_DRAG_3, GESTURE_PINCH, GESTURE_ROTATE }; @@ -25,13 +28,10 @@ provided for each type of gesture. Axes 0 and 1 indicate the starting position of the gesture; axes 2 and 3 track its progress. The progress axis may exhibit absolute values greater than one. */ -class GestureDetector: public Device +class MSPGUI_API GestureDetector: public Device { private: - enum - { - MAX_POINTS = 3 - }; + static constexpr size_t MAX_POINTS = 3; struct TouchPoint { @@ -47,18 +47,17 @@ private: Touchscreen &touchscreen; TouchPoint points[MAX_POINTS]; - Gesture current_gesture; - unsigned active_points; - Gesture pending_tap; - bool invalid_gesture; - float threshold_x_sq; - float threshold_y_sq; + Gesture current_gesture = GESTURE_NONE; + Gesture pending_tap = GESTURE_NONE; + bool invalid_gesture = false; + float threshold_x_sq = 1.0f; + float threshold_y_sq = 1.0f; public: GestureDetector(Touchscreen &); - virtual std::string get_button_name(unsigned) const; - virtual std::string get_axis_name(unsigned) const; + std::string get_button_name(unsigned) const override; + std::string get_axis_name(unsigned) const override; private: void touch_down(unsigned); @@ -66,11 +65,15 @@ private: void touch_move(unsigned, float, float); void start_gesture(); void set_gesture_location(unsigned); + void set_gesture_delta(unsigned); void update_progress(); void end_gesture(); void window_resized(unsigned, unsigned); }; + +MSPGUI_API unsigned gesture_points(Gesture); + } // namespace Input } // namespace Msp