Add methods to set variables for Pinch and Rotation gesture processing
[platform/core/uifw/dali-core.git] / dali / internal / event / events / rotation-gesture / rotation-gesture-processor.h
1 #ifndef DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_ROTATION_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/rotation-gesture/rotation-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 RotationGestureEvent;
36
37 /**
38  * Rotation Gesture Event Processing:
39  *
40  * When we receive a rotation gesture event, we do the following:
41  * - Find the hit actor that requires a rotation underneath the center-point of the rotation.
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 rotation gesture to this
45  * detector until the rotation ends or is cancelled.
46  */
47 class RotationGestureProcessor : public GestureProcessor, public RecognizerObserver<RotationGestureEvent>
48 {
49 public:
50
51   /**
52    * Create a rotation gesture processor.
53    */
54   RotationGestureProcessor();
55
56   /**
57    * Non-virtual destructor; RotationGestureProcessor is not a base class
58    */
59   ~RotationGestureProcessor() = default;
60
61   RotationGestureProcessor( const RotationGestureProcessor& )                = delete; ///< Deleted copy constructor.
62   RotationGestureProcessor& operator=( const RotationGestureProcessor& rhs ) = delete; ///< Deleted copy assignment operator.
63
64 public: // To be called by GestureEventProcessor
65
66   /**
67    * This method is called whenever a rotation gesture event occurs.
68    * @param[in] scene The scene the rotation gesture event occurs in.
69    * @param[in] rotationEvent The event that has occurred.
70    */
71   void Process( Scene& scene, const RotationGestureEvent& rotationEvent );
72
73   /**
74    * Adds a gesture detector to this gesture processor.
75    * If this is the first gesture detector being added, then this method registers the required
76    * gesture with the adaptor.
77    * @param[in]  gestureDetector  The gesture detector being added
78    * @param[in]  scene            The scene the rotation gesture occurred in
79    */
80   void AddGestureDetector( RotationGestureDetector* gestureDetector, Scene& scene );
81
82   /**
83    * Removes the specified gesture detector from this gesture processor.  If, after removing this
84    * gesture detector, there are no more gesture detectors registered, then this method unregisters
85    * the gesture from the adaptor.
86    * @param[in]  gestureDetector  The gesture detector being removed.
87    */
88   void RemoveGestureDetector( RotationGestureDetector* gestureDetector );
89
90   /**
91    * Sets the minimum touch events required before a rotation can be started
92    * @param[in] value The number of touch events
93    */
94   void SetMinimumTouchEvents( uint32_t value );
95
96   /**
97    * Sets the minimum touch events required after a rotation started
98    * @param[in] value The number of touch events
99    */
100   void SetMinimumTouchEventsAfterStart( uint32_t value );
101
102 private:
103
104   // GestureProcessor overrides
105
106   /**
107    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
108    */
109   void OnGesturedActorStageDisconnection();
110
111   /**
112    * @copydoc GestureProcessor::CheckGestureDetector()
113    */
114   bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
115
116   /**
117    * @copydoc GestureProcessor::EmitGestureSignal()
118    */
119   void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
120
121 private:
122
123   RotationGestureDetectorContainer mRotationGestureDetectors;
124   GestureDetectorContainer mCurrentRotationEmitters;
125   RenderTaskPtr mCurrentRenderTask;
126
127   const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
128
129   uint32_t mMinimumTouchEvents;
130   uint32_t mMinimumTouchEventsAfterStart;
131 };
132
133 } // namespace Internal
134
135 } // namespace Dali
136
137 #endif // DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H