1 #ifndef __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
5 * Copyright (c) 2014 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/tap-gesture-event.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/events/touch-point.h>
27 #include <events/gesture-detector.h>
35 struct TapGestureRequest;
44 class CoreEventInterface;
47 * When given a set of touch events, this detector attempts to determine if a tap gesture has taken place.
49 class TapGestureDetector : public GestureDetector
55 * @param[in] coreEventInterface Used to send events to Core.
56 * @param[in] screenSize The size of the screen.
57 * @param[in] request The tap gesture request.
59 TapGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::TapGestureRequest& request);
64 virtual ~TapGestureDetector();
69 * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
71 virtual void SendEvent(const Integration::TouchEvent& event);
74 * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
76 virtual void Update(const Integration::GestureRequest& request);
81 * Checks if registered taps are within required bounds and emits tap gesture if they are.
83 * @param[in] state current state of incomplete gesture
84 * @param[in] time time of this latest touch event
86 void EmitGesture( Gesture::State state, unsigned int time );
89 * Initialises tap gesture detector for next tap sequence
91 * @param[in] event registered touch event
92 * @param[in] point position touch event occurred
94 void SetupForTouchDown( const Integration::TouchEvent& event, const TouchPoint& point );
97 * Emit a touch down event for hit testing
99 * @param[in] event registered touch event
101 void EmitPossibleState( const Integration::TouchEvent& event );
104 * Force a touch event sequence to be treated as a single tap
106 * @param[in] time time of this latest touch event
107 * @param[in] point position touch event occurred
109 void EmitSingleTap( unsigned int time, const TouchPoint& point );
114 * @param[in] time time of this latest touch event
115 * @param[in] event registered touch event
117 void EmitTap( unsigned int time, Integration::TapGestureEvent& event );
122 * Internal state machine.
126 Clear, ///< No gesture detected.
127 Touched, ///< User is touching the screen.
128 Registered, ///< At least one tap has been registered.
129 Failed, ///< Gesture has failed.
132 CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
133 State mState; ///< Current state of the detector.
135 int mMinimumTapsRequired; ///< Minimum number of taps required.
136 int mMaximumTapsRequired; ///< Maximum number of taps required.
137 int mTapsRegistered; ///< In current detection, the number of taps registered.
139 Vector2 mTouchPosition; ///< The initial touch down position.
140 unsigned long mTouchTime; ///< The initial touch down time.
141 unsigned long mLastTapTime; ///< Time last tap gesture was registered
145 } // namespace Adaptor
147 } // namespace Internal
151 #endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__