1 /* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __MAPS_VIEW_GESTURE_DETECTOR_STATEMACHINE_H__
17 #define __MAPS_VIEW_GESTURE_DETECTOR_STATEMACHINE_H__
20 #include "maps_view.h"
21 #include "runtime_data.h"
22 #include "gesture_detector.h"
38 enum detector_states_e {
42 /* After finger down */
45 /* After finger down, no significant move, finger up */
48 /* After finger down and hold */
51 /* Finger down and recently was click */
57 /* Click and then finger down and hold for awhile */
58 STATE_SECOND_LONG_PRESSED,
60 /* Moving single finger */
63 /* Moving the second finger after the first one was untouched */
66 /* Both Finger 1 and 2 are pressed */
67 STATE_FINGER2_PRESSED,
69 /* Finger 1 or finger 2 was up */
70 STATE_FINGER1_PRESSED,
72 /* Both fingers are pressed now */
73 STATE_2FINGERS_PRESSED,
75 /* Clicked with two fingers */
76 STATE_2FINGERS_CLICKED,
78 /* Moving Finger1 or 2 when both pressed */
79 STATE_2FINGERS_MOVING,
81 /* Moving after first click */
82 STATE_MOVING_AFTER_SECOND_PRESS
86 class gesture_detector_statemachine : public gesture_detector {
88 /* Current state of detector state machine */
89 detector_states_e _current_state;
91 bool is_panning[MAX_FINGERS];
94 bool is_2fingers_panning;
97 gesture_detector_statemachine(maps_view_h v);
98 virtual ~gesture_detector_statemachine();
100 virtual void tap(int finger_no, const touch_point &tp);
101 virtual void move(int finger_no, const touch_point &tp);
102 virtual void up(int finger_no, const touch_point &tp);
103 virtual void on_tap_timer();
104 virtual void on_long_press_timer();
105 virtual void halt_gesture();
107 void state_machine_on_event(view_event_e event);
109 void detected_tap(); /* Tap */
110 void detected_long_press(); /* Long Press */
111 void detected_double_tap(); /* Double Tap */
112 void detected_second_long_press(); /* Second Long Press */
113 void detected_single_finger_zoom(); /* Single Finger Zoom */
114 void detected_pan(); /* Pan */
115 void detected_finger2_pan(); /* Pan (by second finger) */
116 void detected_zoom_rotate(); /* Zoom, Rotate etc */
117 void detected_2finger_tap(); /* 2Finger Tap */
119 void start_panning(int finger_no);
120 void finish_panning(int finger_no);
121 void start_rotating() { is_rotating = true; }
122 void finish_rotating() { is_rotating = false; }
123 void start_zoomming() { is_zoomming = true; }
124 void finish_zoomming() { is_zoomming = false; }
125 void start_2fingers_panning() { is_2fingers_panning = true; }
126 void finish_2fingers_panning() { is_2fingers_panning = false; }
129 void log_state(view_event_e event, detector_states_e state);
130 void log_event(view_event_e event);
131 string get_state_str(detector_states_e state);
132 string get_event_str(view_event_e event);
136 #endif /* __MAPS_VIEW_GESTURE_DETECTOR_STATEMACHINE_H__ */