1 #ifndef DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
33 struct RotationGestureEvent;
36 * Rotation Gesture Event Processing:
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.
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.
45 class RotationGestureProcessor : public GestureProcessor, public RecognizerObserver<RotationGestureEvent>
49 * Create a rotation gesture processor.
51 RotationGestureProcessor();
54 * Non-virtual destructor; RotationGestureProcessor is not a base class
56 ~RotationGestureProcessor() override = default;
58 RotationGestureProcessor(const RotationGestureProcessor&) = delete; ///< Deleted copy constructor.
59 RotationGestureProcessor& operator=(const RotationGestureProcessor& rhs) = delete; ///< Deleted copy assignment operator.
61 public: // To be called by GestureEventProcessor
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.
68 void Process(Scene& scene, const RotationGestureEvent& rotationEvent, Actor* actor = nullptr) override;
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
77 void AddGestureDetector(RotationGestureDetector* gestureDetector, Scene& scene);
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.
85 void RemoveGestureDetector(RotationGestureDetector* gestureDetector);
88 * Sets the minimum touch events required before a rotation can be started
89 * @param[in] value The number of touch events
91 void SetMinimumTouchEvents(uint32_t value);
94 * Sets the minimum touch events required after a rotation started
95 * @param[in] value The number of touch events
97 void SetMinimumTouchEventsAfterStart(uint32_t value);
100 // GestureProcessor overrides
103 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
105 void OnGesturedActorStageDisconnection() override;
108 * @copydoc GestureProcessor::CheckGestureDetector()
110 bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
113 * @copydoc GestureProcessor::EmitGestureSignal()
115 void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
118 RotationGestureDetectorContainer mRotationGestureDetectors;
119 GestureDetectorContainer mCurrentRotationEmitters;
120 RenderTaskPtr mCurrentRenderTask;
122 const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
124 uint32_t mMinimumTouchEvents;
125 uint32_t mMinimumTouchEventsAfterStart;
128 } // namespace Internal
132 #endif // DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H