Add LCOV remarkers to increase line coverage rate
[platform/core/api/maps-service.git] / src / view / gesture_detector_statemachine.h
1 /* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
2  *
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
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15
16 #ifndef __MAPS_VIEW_GESTURE_DETECTOR_STATEMACHINE_H__
17 #define __MAPS_VIEW_GESTURE_DETECTOR_STATEMACHINE_H__
18
19
20 #include "maps_view.h"
21 #include "runtime_data.h"
22 #include "gesture_detector.h"
23
24 //LCOV_EXCL_START
25 namespace view
26 {
27         enum view_event_e {
28                 FINGER_DOWN,
29                 FINGER_MOVE,
30                 FINGER_UP,
31                 FINGER2_DOWN,
32                 FINGER2_MOVE,
33                 FINGER2_UP,
34                 TAP_TIMER,
35                 LONG_PRESS_TIMER
36         };
37
38         enum detector_states_e {
39                 /* Initial state */
40                 STATE_NONE,
41
42                 /* After finger down */
43                 STATE_PRESSED,
44
45                 /* After finger down, no significant move, finger up */
46                 STATE_CLICKED,
47
48                 /* After finger down and hold */
49                 STATE_LONG_PRESSED,
50
51                 /* Finger down and recently was click */
52                 STATE_SECOND_PRESSED,
53
54                 /* Second click */
55                 STATE_SECOND_CLICKED,
56
57                 /* Click and then finger down and hold for awhile */
58                 STATE_SECOND_LONG_PRESSED,
59
60                 /* Moving single finger */
61                 STATE_MOVING,
62
63                 /* Moving the second finger after the first one was untouched */
64                 STATE_FINGER2_MOVING,
65
66                 /* Both Finger 1 and 2 are pressed */
67                 STATE_FINGER2_PRESSED,
68
69                 /* Finger 1 or finger 2 was up */
70                 STATE_FINGER1_PRESSED,
71
72                 /* Both fingers are pressed now */
73                 STATE_2FINGERS_PRESSED,
74
75                 /* Clicked with two fingers */
76                 STATE_2FINGERS_CLICKED,
77
78                 /* Moving Finger1 or 2 when both pressed */
79                 STATE_2FINGERS_MOVING,
80
81                 /* Moving after first click */
82                 STATE_MOVING_AFTER_SECOND_PRESS
83         };
84
85
86         class gesture_detector_statemachine : public gesture_detector {
87         public:
88                 /* Current state of detector state machine */
89                 detector_states_e _current_state;
90
91                 bool is_panning[MAX_FINGERS];
92                 bool is_rotating;
93                 bool is_zoomming;
94                 bool is_2fingers_panning;
95
96         public:
97                 gesture_detector_statemachine(maps_view_h v);
98                 virtual ~gesture_detector_statemachine();
99         public:
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();
106         public:
107                 void state_machine_on_event(view_event_e event);
108         private:
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 */
118         private:
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; }
127
128         private:
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);
133         };
134 };
135 //LCOV_EXCL_STOP
136
137 #endif                          /* __MAPS_VIEW_GESTURE_DETECTOR_STATEMACHINE_H__ */