1 #ifndef DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_TAP_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/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);
89 TapGestureProcessor(const TapGestureProcessor&);
90 TapGestureProcessor& operator=(const TapGestureProcessor& rhs);
94 * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
95 * its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
97 void UpdateDetection();
99 // GestureProcessor overrides
102 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
104 void OnGesturedActorStageDisconnection() override
105 { /* Nothing to do */
109 * @copydoc GestureProcessor::CheckGestureDetector()
111 bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
114 * @copydoc GestureProcessor::EmitGestureSignal()
116 void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
119 TapGestureDetectorContainer mTapGestureDetectors;
121 unsigned int mMinTapsRequired;
122 unsigned int mMaxTapsRequired;
123 unsigned int mMinTouchesRequired;
124 unsigned int mMaxTouchesRequired;
126 ActorObserver mCurrentTapActor; ///< Observer for the current gesture actor
127 const TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
128 bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
131 } // namespace Internal
135 #endif // DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H