Add support for new accessibility actions
[platform/core/uifw/dali-adaptor.git] / adaptors / common / events / pinch-gesture-detector.h
1 #ifndef __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 // INTERNAL INCLUDES
25 #include <events/gesture-detector.h>
26
27 namespace Dali
28 {
29
30 namespace Integration
31 {
32 struct TouchEvent;
33 }
34
35 namespace Internal
36 {
37
38 namespace Adaptor
39 {
40
41 class CoreEventInterface;
42
43 /**
44  * When given a set of touch events, this detector attempts to determine if a pinch gesture has taken place.
45  */
46 class PinchGestureDetector : public GestureDetector
47 {
48 public:
49
50   /**
51    * Constructor
52    * @param[in] coreEventInterface Used to send events to Core.
53    * @param[in] screenSize The size of the screen.
54    */
55   PinchGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, float minimumPinchDistance);
56
57   /**
58    * Virtual destructor.
59    */
60   virtual ~PinchGestureDetector();
61
62   /**
63    * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
64    * trigger a pinch gesture
65    *
66    * @param[in] distance The minimum pinch distance in pixels
67    */
68   void SetMinimumPinchDistance(float distance);
69
70 public:
71
72   /**
73    * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
74    */
75   virtual void SendEvent(const Integration::TouchEvent& event);
76
77   /**
78    * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
79    */
80   virtual void Update(const Integration::GestureRequest& request);
81
82 private:
83
84   /**
85    * Emits the pinch gesture event to the core.
86    * @param[in]  state         The state of the pinch (whether it's starting, continuing or finished).
87    * @param[in]  currentEvent  The latest touch event.
88    */
89   void SendPinch(Gesture::State state, const Integration::TouchEvent& currentEvent);
90
91 private:
92
93   /**
94    * Internal state machine.
95    */
96   enum State
97   {
98     Clear,    ///< No gesture detected.
99     Possible, ///< The current touch event data suggests that a gesture is possible.
100     Started,  ///< A gesture has been detected.
101   };
102
103   CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
104   State mState; ///< The current state of the detector.
105   std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
106
107   float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
108
109   float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
110 };
111
112 } // namespace Adaptor
113
114 } // namespace Internal
115
116 } // namespace Dali
117
118 #endif // __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__