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 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.
26 #include <events/gesture-detector.h>
34 struct LongPressGestureRequest;
43 class CoreEventInterface;
46 * When given a set of touch events, this detector attempts to determine if a long press gesture has taken place.
47 * Emits a LongPressGestureEvent (state = Started) when a long press has been detected (Touch held down for more than duration).
48 * Emits a further LongPressGestureEvent (state = Finished) when a long press has been completed (Touch Release).
50 class LongPressGestureDetector : 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 long press gesture request.
60 LongPressGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::LongPressGestureRequest& request);
65 virtual ~LongPressGestureDetector();
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);
83 * @return will return false; one-shot timer.
88 * Emits the long press gesture if all conditions are applicable.
89 * @param[in] state The state of this gesture event.
91 void EmitGesture(Gesture::State state);
94 * Get current system setting value for tap and hold gesture
95 * @return system value for tap and hold gesture [ms]
102 * Internal state machine.
106 Clear, ///< No gesture detected.
107 Touched, ///< User is touching the screen.
108 Failed, ///< Gesture has failed.
109 Finished ///< Gesture has been detected and sent.
112 CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
113 State mState; ///< The current state of the detector.
115 unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
116 unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
118 std::map<int, Vector2> mTouchPositions; ///< A map with all the touch down positions.
119 unsigned long mTouchTime; ///< The time we first pressed down.
121 Dali::Timer mTimer; ///< The timer used to determine a long press.
122 SlotDelegate< LongPressGestureDetector > mTimerSlot;
125 } // namespace Adaptor
127 } // namespace Internal
131 #endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__