3bbd75ddb13908fcee5f1c8d47fd885a405113e9
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture-processor.h
1 #ifndef DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H
3
4 /*
5  * Copyright (c) 2019 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 // INTERNAL INCLUDES
22 #include <dali/internal/event/events/pinch-gesture-detector-impl.h>
23 #include <dali/internal/event/events/gesture-processor.h>
24 #include <dali/internal/event/render-tasks/render-task-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class Scene;
33 class Stage;
34
35 struct PinchGestureEvent;
36
37 /**
38  * Pinch Gesture Event Processing:
39  *
40  * When we receive a pinch gesture event, we do the following:
41  * - Find the hit actor that requires a pinch underneath the center-point of the pinch.
42  * - Emit the gesture if the event satisfies the detector conditions.
43  *
44  * The above is only checked when our gesture starts. We continue sending the pinch gesture to this
45  * detector until the pinch ends or is cancelled.
46  */
47 class PinchGestureProcessor : public GestureProcessor, public RecognizerObserver<PinchGestureEvent>
48 {
49 public:
50
51   /**
52    * Create a pinch gesture processor.
53    * @param[in] gestureManager The gesture manager
54    */
55   PinchGestureProcessor();
56
57   /**
58    * Non-virtual destructor; PinchGestureProcessor is not a base class
59    */
60   ~PinchGestureProcessor();
61
62 public: // To be called by GestureEventProcessor
63
64   /**
65    * This method sets the minimum distance to start a pinch
66    * @param[in] value The distance in pixels
67    */
68   void SetMinimumPinchDistance( float value );
69
70   /**
71    * This method is called whenever a pinch gesture event occurs.
72    * @param[in] scene The scene the pinch gesture event occurs in.
73    * @param[in] pinchEvent The event that has occurred.
74    */
75   void Process( Scene& scene, const PinchGestureEvent& pinchEvent );
76
77   /**
78    * Adds a gesture detector to this gesture processor.
79    * If this is the first gesture detector being added, then this method registers the required
80    * gesture with the adaptor.
81    * @param[in]  gestureDetector  The gesture detector being added.
82    */
83   void AddGestureDetector(PinchGestureDetector* gestureDetector, Scene& scene);
84
85   /**
86    * Removes the specified gesture detector from this gesture processor.  If, after removing this
87    * gesture detector, there are no more gesture detectors registered, then this method unregisters
88    * the gesture from the adaptor.
89    * @param[in]  gestureDetector  The gesture detector being removed.
90    */
91   void RemoveGestureDetector(PinchGestureDetector* gestureDetector);
92
93   /**
94    * This method updates the gesture detection parameters.
95    * @param[in]  gestureDetector  The gesture detector that has been updated.
96    */
97   void GestureDetectorUpdated(PinchGestureDetector* gestureDetector);
98
99 private:
100
101   // Undefined
102   PinchGestureProcessor(const PinchGestureProcessor&);
103   PinchGestureProcessor& operator=(const PinchGestureProcessor& rhs);
104
105 private:
106
107   // GestureProcessor overrides
108
109   /**
110    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
111    */
112   void OnGesturedActorStageDisconnection();
113
114   /**
115    * @copydoc GestureProcessor::CheckGestureDetector()
116    */
117   bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
118
119   /**
120    * @copydoc GestureProcessor::EmitGestureSignal()
121    */
122   void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
123
124 private:
125
126   PinchGestureDetectorContainer mPinchGestureDetectors;
127   GestureDetectorContainer mCurrentPinchEmitters;
128   RenderTaskPtr mCurrentRenderTask;
129
130   const PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
131
132   float mMinimumPinchDistance;
133 };
134
135 } // namespace Internal
136
137 } // namespace Dali
138
139 #endif // DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H