1 #ifndef DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H
5 * Copyright (c) 2019 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.
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/integration-api/events/point.h>
28 #include <dali/internal/event/events/gesture-recognizer.h>
29 #include <dali/internal/event/events/tap-gesture-event.h>
41 struct TapGestureRequest;
44 * When given a set of touch events, this detector attempts to determine if a tap gesture has taken place.
46 class TapGestureRecognizer : public GestureRecognizer
50 using Observer = RecognizerObserver<TapGestureEvent>;
54 * @param[in] coreEventInterface Used to send events to Core.
55 * @param[in] screenSize The size of the screen.
56 * @param[in] request The tap gesture request.
58 TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request);
63 virtual ~TapGestureRecognizer();
68 * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
70 virtual void SendEvent(const Integration::TouchEvent& event);
73 * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
75 virtual void Update(const GestureRequest& request);
80 * Checks if registered taps are within required bounds and emits tap gesture if they are.
82 * @param[in] state current state of incomplete gesture
83 * @param[in] time time of this latest touch event
85 void EmitGesture( Gesture::State state, uint32_t time );
88 * Initialises tap gesture detector for next tap sequence
90 * @param[in] event registered touch event
91 * @param[in] point position touch event occurred
93 void SetupForTouchDown( const Integration::TouchEvent& event, const Integration::Point& point );
96 * Emit a touch down event for hit testing
98 * @param[in] event registered touch event
100 void EmitPossibleState( const Integration::TouchEvent& event );
103 * Force a touch event sequence to be treated as a single tap
105 * @param[in] time time of this latest touch event
106 * @param[in] point position touch event occurred
108 void EmitSingleTap( uint32_t time, const Integration::Point& point );
113 * @param[in] time time of this latest touch event
114 * @param[in] event registered touch event
116 void EmitTap( uint32_t time, TapGestureEvent& event );
119 * Send the event for processing
121 * @param[in] tap event for processing
123 void ProcessEvent( TapGestureEvent& event );
127 // Reference to the gesture processor for this recognizer
131 * Internal state machine.
135 Clear, ///< No gesture detected.
136 Touched, ///< User is touching the screen.
137 Registered, ///< At least one tap has been registered.
138 Failed, ///< Gesture has failed.
141 State mState; ///< Current state of the detector.
143 int mMinimumTapsRequired; ///< Minimum number of taps required.
144 int mMaximumTapsRequired; ///< Maximum number of taps required.
145 int mTapsRegistered; ///< In current detection, the number of taps registered.
147 Vector2 mTouchPosition; ///< The initial touch down position.
148 uint32_t mTouchTime; ///< The initial touch down time.
149 uint32_t mLastTapTime; ///< Time last tap gesture was registered
153 } // namespace Internal
158 #endif // DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H