1 #ifndef DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
2 #define DALI_INTERNAL_TAP_GESTURE_DETECTOR_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.
22 #include <cstdint> // uint32_t
23 #include <dali/integration-api/events/tap-gesture-event.h>
24 #include <dali/public-api/common/vector-wrapper.h>
25 #include <dali/integration-api/events/point.h>
28 #include <dali/internal/input/common/gesture-detector.h>
36 struct TapGestureRequest;
45 class CoreEventInterface;
48 * When given a set of touch events, this detector attempts to determine if a tap gesture has taken place.
50 class TapGestureDetector : public GestureDetector
56 * @param[in] coreEventInterface Used to send events to Core.
57 * @param[in] screenSize The size of the screen.
58 * @param[in] request The tap gesture request.
60 TapGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::TapGestureRequest& request);
65 virtual ~TapGestureDetector();
70 * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
72 virtual void SendEvent(const Integration::TouchEvent& event);
75 * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
77 virtual void Update(const Integration::GestureRequest& request);
82 * Checks if registered taps are within required bounds and emits tap gesture if they are.
84 * @param[in] state current state of incomplete gesture
85 * @param[in] time time of this latest touch event
87 void EmitGesture( Gesture::State state, uint32_t time );
90 * Initialises tap gesture detector for next tap sequence
92 * @param[in] event registered touch event
93 * @param[in] point position touch event occurred
95 void SetupForTouchDown( const Integration::TouchEvent& event, const Integration::Point& point );
98 * Emit a touch down event for hit testing
100 * @param[in] event registered touch event
102 void EmitPossibleState( const Integration::TouchEvent& event );
105 * Force a touch event sequence to be treated as a single tap
107 * @param[in] time time of this latest touch event
108 * @param[in] point position touch event occurred
110 void EmitSingleTap( uint32_t time, const Integration::Point& point );
115 * @param[in] time time of this latest touch event
116 * @param[in] event registered touch event
118 void EmitTap( uint32_t time, Integration::TapGestureEvent& event );
123 * Internal state machine.
127 Clear, ///< No gesture detected.
128 Touched, ///< User is touching the screen.
129 Registered, ///< At least one tap has been registered.
130 Failed, ///< Gesture has failed.
133 CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
134 State mState; ///< Current state of the detector.
136 int mMinimumTapsRequired; ///< Minimum number of taps required.
137 int mMaximumTapsRequired; ///< Maximum number of taps required.
138 int mTapsRegistered; ///< In current detection, the number of taps registered.
140 Vector2 mTouchPosition; ///< The initial touch down position.
141 uint32_t mTouchTime; ///< The initial touch down time.
142 uint32_t mLastTapTime; ///< Time last tap gesture was registered
146 } // namespace Adaptor
148 } // namespace Internal
152 #endif // DALI_INTERNAL_TAP_GESTURE_DETECTOR_H