1 #ifndef DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_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/integration-api/events/point.h>
23 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/internal/event/events/gesture-recognizer.h>
28 #include <dali/internal/event/events/tap-gesture/tap-gesture-event.h>
39 struct TapGestureRequest;
42 * When given a set of touch events, this detector attempts to determine if a tap gesture has taken place.
44 class TapGestureRecognizer : public GestureRecognizer
47 using Observer = RecognizerObserver<TapGestureEvent>;
51 * @param[in] coreEventInterface Used to send events to Core.
52 * @param[in] screenSize The size of the screen.
53 * @param[in] request The tap gesture request.
54 * @param[in] maximumAllowedTime The maximum allowed time required in milliseconds.
56 TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request, uint32_t maximumAllowedTime);
61 ~TapGestureRecognizer() override;
65 * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
67 void SendEvent(const Integration::TouchEvent& event) override;
70 * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
72 void Update(const GestureRequest& request) override;
75 * @brief This method sets the maximum allowed time required to be recognized as a multi tap gesture (millisecond)
77 * @param[in] time The time value in milliseconds
79 void SetMaximumAllowedTime(uint32_t time);
83 * Checks if registered taps are within required bounds and emits tap gesture if they are.
85 * @param[in] state current state of incomplete gesture
86 * @param[in] time time of this latest touch event
88 void EmitGesture(GestureState state, uint32_t time);
91 * Initialises tap gesture detector for next tap sequence
93 * @param[in] event registered touch event
94 * @param[in] point position touch event occurred
96 void SetupForTouchDown(const Integration::TouchEvent& event, const Integration::Point& point);
99 * Emit a touch down event for hit testing
101 * @param[in] event registered touch event
103 void EmitPossibleState(const Integration::TouchEvent& event);
106 * Force a touch event sequence to be treated as a single tap
108 * @param[in] time time of this latest touch event
109 * @param[in] point position touch event occurred
111 void EmitSingleTap(uint32_t time, const Integration::Point& point);
116 * @param[in] time time of this latest touch event
117 * @param[in] event registered touch event
119 void EmitTap(uint32_t time, TapGestureEvent& event);
122 * Send the event for processing
124 * @param[in] tap event for processing
126 void ProcessEvent(TapGestureEvent& event);
129 // Reference to the gesture processor for this recognizer
133 * Internal state machine.
137 CLEAR, ///< No gesture detected.
138 TOUCHED, ///< User is touching the screen.
139 REGISTERED, ///< At least one tap has been registered.
140 FAILED, ///< Gesture has failed.
143 State mState; ///< Current state of the detector.
145 int mMinimumTapsRequired; ///< Minimum number of taps required.
146 int mMaximumTapsRequired; ///< Maximum number of taps required.
147 int mTapsRegistered; ///< In current detection, the number of taps registered.
149 Vector2 mTouchPosition; ///< The initial touch down position.
150 uint32_t mTouchTime; ///< The initial touch down time.
151 uint32_t mLastTapTime; ///< Time last tap gesture was registered
153 GestureSourceType mGestureSourceType; /// < Gesture input source type value.
154 uint32_t mMaximumAllowedTime; ///< The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
157 } // namespace Internal
161 #endif // DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H