23be5ed6923c8c1d8ffd54d9eb182c6a9ebbed30
[platform/core/api/maps-service.git] / src / view / inertial_gesture.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_INERTIAL_GESTURE_H__
17 #define __MAPS_VIEW_INERTIAL_GESTURE_H__
18
19
20 #include "gesture_detector.h"
21
22 namespace view
23 {
24         class inertial_gesture : public gesture_detector {
25         protected:
26                 gesture_detector *_d;
27                 touch_point _down[MAX_FINGERS];
28                 touch_point _last[MAX_FINGERS];
29                 touch_point _prev[MAX_FINGERS];
30                 touch_point _inertial_start[MAX_FINGERS];
31                 double _cur_x[MAX_FINGERS];
32                 double _cur_y[MAX_FINGERS];
33                 double _derivative_x[MAX_FINGERS];
34                 double _derivative_y[MAX_FINGERS];
35                 bool transiting;
36                 bool transiting_part[MAX_FINGERS];
37                 bool transiting_trajectory;
38                 unsigned transiting_start[MAX_FINGERS];
39                 double _dt[MAX_FINGERS];
40         private:
41 #if (__cplusplus >= 201103L)
42                 static constexpr double __ACCURACY = 1;
43 #else
44                 static const double __ACCURACY = 1;
45 #endif
46         public:
47                 inertial_gesture(maps_view_h view);
48                 ~inertial_gesture();
49         private:
50                 inertial_gesture(const inertial_gesture &src);
51                 inertial_gesture &operator=(const inertial_gesture &src);
52         public:
53                 virtual void tap(int finger_no, const touch_point &tp);
54                 virtual void move(int finger_no, const touch_point &tp);
55                 virtual void up(int finger_no, const touch_point &tp);
56
57                 bool is_transiting() const { return transiting; }
58                 void set_transiting(bool b) { transiting = b; }
59                 bool next_transition_step();
60         public:
61                 //static void on_idle(void *data);
62         protected:
63                 double get_next_point(const double &start,
64                                       const double &derivative,
65                                       const double &dt);
66                 double get_next_derivative(const double &derivative,
67                                            const double &dt);
68                 static unsigned int get_cur_time();
69                 unsigned int get_transition_time(int finger_no) const;
70                 void reset();
71                 void update_inertial_start_point(int finger_no);
72         };
73 };
74
75 #endif                          /* __MAPS_VIEW_INERTIAL_GESTURE_H__ */