1 #ifndef DALI_INTERNAL_EVENT_ROTATION_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_EVENT_ROTATION_GESTURE_RECOGNIZER_H
5 * Copyright (c) 2020 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/public-api/common/vector-wrapper.h>
25 #include <dali/internal/event/events/gesture-recognizer.h>
26 #include <dali/internal/event/events/rotation-gesture/rotation-gesture-event.h>
40 * When given a set of touch events, this detector attempts to determine if a rotation gesture has taken place.
42 class RotationGestureRecognizer : public GestureRecognizer
46 using Observer = RecognizerObserver< RotationGestureEvent >;
50 * @param[in] observer The observer to send gesture too when it's detected
51 * @param[in] minimumTouchEvents The number of touch events required
52 * @param[in] minimumTouchEventsAfterStart The number of touch events required after a gesture started
54 RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart );
59 virtual ~RotationGestureRecognizer() = default;
64 * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
66 virtual void SendEvent( const Integration::TouchEvent& event );
69 * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
71 virtual void Update( const GestureRequest& request ) { /* Nothing to do */ }
74 * Sets the minimum touch events required before a rotation can be started
75 * @param[in] value The number of touch events
77 void SetMinimumTouchEvents( uint32_t value );
80 * Sets the minimum touch events required after a rotation started
81 * @param[in] value The number of touch events
83 void SetMinimumTouchEventsAfterStart( uint32_t value );
88 * Emits the rotation gesture event to the core.
89 * @param[in] state The state of the rotation (whether it's starting, continuing or finished).
90 * @param[in] currentEvent The latest touch event.
92 void SendRotation( Gesture::State state, const Integration::TouchEvent& currentEvent );
96 // Reference to the gesture processor for this recognizer
100 * Internal state machine.
104 Clear, ///< No gesture detected.
105 Possible, ///< The current touch event data suggests that a gesture is possible.
106 Started, ///< A gesture has been detected.
109 State mState; ///< The current state of the detector.
110 std::vector< Integration::TouchEvent > mTouchEvents; ///< The touch events since initial touch down.
112 float mStartingAngle; ///< The angle between the two touch points when the rotation is first detected.
114 uint32_t mMinimumTouchEvents; ///< The minimum touch events required before a rotation can be started.
116 uint32_t mMinimumTouchEventsAfterStart; ///< The minimum touch events required after a rotation started.
119 } // namespace Internal
123 #endif // DALI_INTERNAL_EVENT_ROTATION_GESTURE_RECOGNIZER_H