1 #ifndef DALI_INTERNAL_LONG_PRESS_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_LONG_PRESS_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.
25 #include <dali/internal/event/events/gesture-recognizer.h>
26 #include <dali/internal/event/events/long-press-gesture/long-press-gesture-event.h>
40 struct LongPressGestureRequest;
41 class CoreEventInterface;
44 * When given a set of touch events, this detector attempts to determine if a long press gesture has taken place.
45 * Emits a LongPressGestureEvent (state = Started) when a long press has been detected (Touch held down for more than duration).
46 * Emits a further LongPressGestureEvent (state = Finished) when a long press has been completed (Touch Release).
48 class LongPressGestureRecognizer : public GestureRecognizer
52 using Observer = RecognizerObserver<LongPressGestureEvent>;
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 LongPressGestureRecognizer( Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request );
65 virtual ~LongPressGestureRecognizer();
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 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]
101 // Reference to the gesture processor for this recognizer
105 * Internal state machine.
109 Clear, ///< No gesture detected.
110 Touched, ///< User is touching the screen.
111 Failed, ///< Gesture has failed.
112 Finished ///< Gesture has been detected and sent.
115 State mState; ///< The current state of the detector.
117 unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
118 unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
120 std::map<int, Vector2> mTouchPositions; ///< A map with all the touch down positions.
121 uint32_t mTouchTime; ///< The time we first pressed down.
126 } // namespace Internal
130 #endif // DALI_INTERNAL_LONG_PRESS_GESTURE_RECOGNIZER_H