Added support for Rotation Gestures
[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 private:
91
92   // GestureProcessor overrides
93
94   /**
95    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
96    */
97   void OnGesturedActorStageDisconnection();
98
99   /**
100    * @copydoc GestureProcessor::CheckGestureDetector()
101    */
102   bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
103
104   /**
105    * @copydoc GestureProcessor::EmitGestureSignal()
106    */
107   void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
108
109 private:
110
111   RotationGestureDetectorContainer mRotationGestureDetectors;
112   GestureDetectorContainer mCurrentRotationEmitters;
113   RenderTaskPtr mCurrentRenderTask;
114
115   const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
116 };
117
118 } // namespace Internal
119
120 } // namespace Dali
121
122 #endif // DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H