1 #ifndef __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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/public-api/adaptor-framework/common/timer.h>
25 #include <internal/common/events/gesture-detector.h>
33 struct LongPressGestureRequest;
42 class CoreEventInterface;
45 * When given a set of touch events, this detector attempts to determine if a long press gesture has taken place.
46 * Emits a LongPressGestureEvent (state = Started) when a long press has been detected (Touch held down for more than duration).
47 * Emits a further LongPressGestureEvent (state = Finished) when a long press has been completed (Touch Release).
49 class LongPressGestureDetector : 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 long press gesture request.
59 LongPressGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::LongPressGestureRequest& request);
64 virtual ~LongPressGestureDetector();
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);
82 * @return will return false; one-shot timer.
87 * Emits the long press gesture if all conditions are applicable.
88 * @param[in] state The state of this gesture event.
90 void EmitGesture(Gesture::State state);
93 * Get current system setting value for tap and hold gesture
94 * @return system value for tap and hold gesture [ms]
101 * Internal state machine.
105 Clear, ///< No gesture detected.
106 Touched, ///< User is touching the screen.
107 Failed, ///< Gesture has failed.
108 Finished ///< Gesture has been detected and sent.
111 CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
112 State mState; ///< The current state of the detector.
114 unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
115 unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
117 std::map<int, Vector2> mTouchPositions; ///< A map with all the touch down positions.
118 unsigned long mTouchTime; ///< The time we first pressed down.
120 Dali::Timer mTimer; ///< The timer used to determine a long press.
121 SlotDelegate< LongPressGestureDetector > mTimerSlot;
124 } // namespace Adaptor
126 } // namespace Internal
130 #endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__