[dali_2.3.6] Merge branch 'devel/master'
[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) 2021 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/gesture-processor.h>
23 #include <dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h>
24 #include <dali/internal/event/render-tasks/render-task-impl.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 class Scene;
31 class Stage;
32
33 struct RotationGestureEvent;
34
35 /**
36  * Rotation Gesture Event Processing:
37  *
38  * When we receive a rotation gesture event, we do the following:
39  * - Find the hit actor that requires a rotation underneath the center-point of the rotation.
40  * - Emit the gesture if the event satisfies the detector conditions.
41  *
42  * The above is only checked when our gesture starts. We continue sending the rotation gesture to this
43  * detector until the rotation ends or is cancelled.
44  */
45 class RotationGestureProcessor : public GestureProcessor, public RecognizerObserver<RotationGestureEvent>
46 {
47 public:
48   /**
49    * Create a rotation gesture processor.
50    */
51   RotationGestureProcessor();
52
53   /**
54    * Non-virtual destructor; RotationGestureProcessor is not a base class
55    */
56   ~RotationGestureProcessor() override = default;
57
58   RotationGestureProcessor(const RotationGestureProcessor&) = delete;                ///< Deleted copy constructor.
59   RotationGestureProcessor& operator=(const RotationGestureProcessor& rhs) = delete; ///< Deleted copy assignment operator.
60
61 public: // To be called by GestureEventProcessor
62   /**
63    * This method is called whenever a rotation gesture event occurs.
64    * @param[in] scene The scene the rotation gesture event occurs in.
65    * @param[in] rotationEvent The event that has occurred.
66    * @param[in] actor The actor where the event occurred. If this is null, the actor is found through hittest.
67    */
68   void Process(Scene& scene, const RotationGestureEvent& rotationEvent, Actor* actor = nullptr) override;
69
70   /**
71    * Adds a gesture detector to this gesture processor.
72    * If this is the first gesture detector being added, then this method registers the required
73    * gesture with the adaptor.
74    * @param[in]  gestureDetector  The gesture detector being added
75    * @param[in]  scene            The scene the rotation gesture occurred in
76    */
77   void AddGestureDetector(RotationGestureDetector* gestureDetector, Scene& scene);
78
79   /**
80    * Removes the specified gesture detector from this gesture processor.  If, after removing this
81    * gesture detector, there are no more gesture detectors registered, then this method unregisters
82    * the gesture from the adaptor.
83    * @param[in]  gestureDetector  The gesture detector being removed.
84    */
85   void RemoveGestureDetector(RotationGestureDetector* gestureDetector);
86
87   /**
88    * Sets the minimum touch events required before a rotation can be started
89    * @param[in] value The number of touch events
90    */
91   void SetMinimumTouchEvents(uint32_t value);
92
93   /**
94    * Sets the minimum touch events required after a rotation started
95    * @param[in] value The number of touch events
96    */
97   void SetMinimumTouchEventsAfterStart(uint32_t value);
98
99 private:
100   // GestureProcessor overrides
101
102   /**
103    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
104    */
105   void OnGesturedActorStageDisconnection() override;
106
107   /**
108    * @copydoc GestureProcessor::CheckGestureDetector()
109    */
110   bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
111
112   /**
113    * @copydoc GestureProcessor::EmitGestureSignal()
114    */
115   void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
116
117 private:
118   RotationGestureDetectorContainer mRotationGestureDetectors;
119   GestureDetectorContainer         mCurrentRotationEmitters;
120   RenderTaskPtr                    mCurrentRenderTask;
121
122   const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
123
124   uint32_t mMinimumTouchEvents;
125   uint32_t mMinimumTouchEventsAfterStart;
126 };
127
128 } // namespace Internal
129
130 } // namespace Dali
131
132 #endif // DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H