1 #ifndef DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H
5 * Copyright (c) 2023 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/actor-observer.h>
23 #include <dali/internal/event/events/gesture-processor.h>
24 #include <dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h>
35 struct TapGestureEvent;
38 * Tap Gesture Event Processing:
40 * When we receive a tap gesture event, we do the following:
41 * - Find the actor that requires a tap where the tap occurred.
42 * - Emit the gesture if the tap gesture event satisfies the detector conditions.
44 class TapGestureProcessor : public GestureProcessor, public RecognizerObserver<TapGestureEvent>
48 * Create a tap gesture processor.
50 TapGestureProcessor();
53 * Non-virtual destructor; TapGestureProcessor is not a base class
55 ~TapGestureProcessor() override;
57 public: // To be called by GestureEventProcessor
59 * This method is called whenever a tap gesture event occurs.
60 * @param[in] scene The scene the tap gesture event occurs in.
61 * @param[in] tapEvent The event that has occurred.
63 void Process(Scene& scene, const TapGestureEvent& event) override;
66 * Adds a gesture detector to this gesture processor.
67 * If this is the first gesture detector being added, then this method registers the required
68 * gesture with the adaptor.
69 * @param[in] gestureDetector The gesture detector being added.
71 void AddGestureDetector(TapGestureDetector* gestureDetector, Scene& scene);
74 * Removes the specified gesture detector from this gesture processor. If, after removing this
75 * gesture detector, there are no more gesture detectors registered, then this method unregisters
76 * the gesture from the adaptor.
77 * @param[in] gestureDetector The gesture detector being removed.
79 void RemoveGestureDetector(TapGestureDetector* gestureDetector);
82 * This method updates the gesture detection parameters.
83 * @param[in] gestureDetector The gesture detector that has been updated.
85 void GestureDetectorUpdated(TapGestureDetector* gestureDetector);
88 * @brief This method sets the maximum allowed time required to be recognized as a multi tap gesture (millisecond)
90 * @param[in] time The time value in milliseconds
92 void SetMaximumAllowedTime(uint32_t time);
95 * @brief This method gets the maximum allowed time (millisecond)
97 * @return The time value in milliseconds
99 uint32_t GetMaximumAllowedTime() const;
102 * @brief This method sets the recognizer time required to be recognized as a tap gesture (millisecond)
104 * This time is from touch down to touch up to recognize the tap gesture.
106 * @param[in] time The time value in milliseconds
108 void SetRecognizerTime(uint32_t time);
111 * @brief This method gets the recognizer time required to be recognized as a tap gesture (millisecond)
113 * @return The time value in milliseconds
115 uint32_t GetRecognizerTime() const;
118 * @brief This method sets the recognizer distance required to be recognized as a tap gesture
120 * This distance is from touch down to touch up to recognize the tap gesture.
122 * @param[in] distance The distance
124 void SetMaximumMotionAllowedDistance(float distance);
127 * @brief This method gets the recognizer distance required to be recognized as a tap gesture
129 * @return The distance value
131 float GetMaximumMotionAllowedDistance() const;
135 TapGestureProcessor(const TapGestureProcessor&);
136 TapGestureProcessor& operator=(const TapGestureProcessor& rhs);
140 * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
141 * its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
143 void UpdateDetection();
145 // GestureProcessor overrides
148 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
150 void OnGesturedActorStageDisconnection() override
151 { /* Nothing to do */
155 * @copydoc GestureProcessor::CheckGestureDetector()
157 bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
160 * @copydoc GestureProcessor::EmitGestureSignal()
162 void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
165 TapGestureDetectorContainer mTapGestureDetectors;
167 uint32_t mMinTouchesRequired;
168 uint32_t mMaxTouchesRequired;
170 ActorObserver mCurrentTapActor; ///< Observer for the current gesture actor
171 const TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
172 bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
174 uint32_t mMaximumAllowedTime; ///< The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
175 uint32_t mRecognizerTime; ///< The recognizer time required to be recognized as a tap gesture (millisecond)
176 float mMaximumMotionAllowedDistance; ///< The recognizer distance required to be recognized as a tap gesture
179 } // namespace Internal
183 #endif // DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H