use modern construct 'override' in the derive class.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture / pinch-gesture-recognizer.h
1 #ifndef DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H
3
4 /*
5  * Copyright (c) 2020 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 <dali/internal/event/events/gesture-recognizer.h>
26 #include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
27
28 namespace Dali
29 {
30
31 namespace Integration
32 {
33 struct TouchEvent;
34 }
35
36 namespace Internal
37 {
38
39 /**
40  * When given a set of touch events, this detector attempts to determine if a pinch gesture has taken place.
41  */
42 class PinchGestureRecognizer : public GestureRecognizer
43 {
44 public:
45
46   using Observer = RecognizerObserver<PinchGestureEvent>;
47
48   /**
49    * Constructor
50    * @param[in] screenSize The size of the screen.
51    * @param[in] screenDpi The dpi value of the screen
52    * @param[in] minimumPinchDistance in pixels
53    * @param[in] minimumTouchEvents The number of touch events required
54    * @param[in] minimumTouchEventsAfterStart The number of touch events required after a gesture started
55    */
56   PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart );
57
58   /**
59    * Virtual destructor.
60    */
61   ~PinchGestureRecognizer() override;
62
63 public:
64
65   void SetMinimumPinchDistance(float value);
66
67   /**
68    * Sets the minimum touch events required before a pinch can be started
69    * @param[in] value The number of touch events
70    */
71   void SetMinimumTouchEvents( uint32_t value );
72
73   /**
74    * Sets the minimum touch events required after a pinch started
75    * @param[in] value The number of touch events
76    */
77   void SetMinimumTouchEventsAfterStart( uint32_t value );
78
79   /**
80    * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
81    */
82   void SendEvent(const Integration::TouchEvent& event) override;
83
84   /**
85    * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
86    */
87   void Update(const GestureRequest& request) override;
88
89 private:
90
91   /**
92    * Emits the pinch gesture event to the core.
93    * @param[in]  state         The state of the pinch (whether it's starting, continuing or finished).
94    * @param[in]  currentEvent  The latest touch event.
95    */
96   void SendPinch(GestureState state, const Integration::TouchEvent& currentEvent);
97
98 private:
99
100   // Reference to the gesture processor for this recognizer
101   Observer& mObserver;
102
103   /**
104    * Internal state machine.
105    */
106   enum State
107   {
108     CLEAR,    ///< No gesture detected.
109     POSSIBLE, ///< The current touch event data suggests that a gesture is possible.
110     STARTED,  ///< A gesture has been detected.
111   };
112
113   State mState; ///< The current state of the detector.
114   std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
115
116   float mDefaultMinimumDistanceDelta; ///< The default value of the mMinimumDistanceDelta.
117
118   float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
119
120   float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
121
122   uint32_t mMinimumTouchEvents; ///< The minimum touch events required before a pinch can be started.
123
124   uint32_t mMinimumTouchEventsAfterStart; ///< The minimum touch events required after a pinch started.
125 };
126
127 } // namespace Internal
128
129 } // namespace Dali
130
131 #endif // DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H