1 #ifndef DALI_INTERNAL_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_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>
23 #include <dali/public-api/events/gesture.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/object/ref-object.h>
26 #include <dali/internal/event/events/gesture-event.h>
38 struct GestureRequest;
42 class RecognizerObserver
45 virtual void Process( Scene& scene, const T& event ) = 0;
47 virtual ~RecognizerObserver(){};
52 * Abstract Base class for all adaptor gesture detectors.
54 * @note this may be replaced by gesture events sent directly from X.
56 class GestureRecognizer : public RefObject
61 * Called when it gets a touch event. The gesture recognizer should
62 * evaluate this event along with previously received events to determine
63 * whether the gesture they require has taken place.
64 * @param[in] event The latest touch event.
66 virtual void SendEvent(const Integration::TouchEvent& event) = 0;
69 * Called when Core updates the gesture's detection requirements.
70 * @param[in] request The updated detection requirements.
72 virtual void Update(const GestureRequest& request) = 0;
75 * Returns the type of gesture detector.
76 * @return Type of gesture detector.
78 GestureType::Value GetType() const { return mType; }
81 * Called when we get a touch event.
82 * @param[in] scene The scene the touch event has occurred on
83 * @param[in] event The latest touch event
85 void SendEvent( Scene& scene, const Integration::TouchEvent& event )
94 * Protected Constructor. Should only be able to create derived class objects.
95 * @param[in] screenSize The size of the screen.
96 * @param[in] detectorType The type of gesture detector.
98 GestureRecognizer( Vector2 screenSize, GestureType::Value detectorType )
99 : mScreenSize( screenSize ),
100 mType( detectorType ),
106 * Protected Constructor. Should only be able to create derived class objects.
108 * Use this constructor with the screen size is not used in the dereived class.
109 * @param[in] detectorType The type of gesture detector.
111 GestureRecognizer( GestureType::Value detectorType )
112 : GestureRecognizer( Vector2::ZERO, detectorType )
117 * Virtual destructor.
119 virtual ~GestureRecognizer() {}
123 GestureType::Value mType;
127 using GestureRecognizerPtr = IntrusivePtr<GestureRecognizer>;
129 } // namespace Internal
133 #endif // DALI_INTERNAL_GESTURE_RECOGNIZER_H