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() = default;
53 * Abstract Base class for all adaptor gesture detectors.
55 * @note this may be replaced by gesture events sent directly from X.
57 class GestureRecognizer : public RefObject
62 * Called when it gets a touch event. The gesture recognizer should
63 * evaluate this event along with previously received events to determine
64 * whether the gesture they require has taken place.
65 * @param[in] event The latest touch event.
67 virtual void SendEvent(const Integration::TouchEvent& event) = 0;
70 * Called when Core updates the gesture's detection requirements.
71 * @param[in] request The updated detection requirements.
73 virtual void Update(const GestureRequest& request) = 0;
76 * Returns the type of gesture detector.
77 * @return Type of gesture detector.
79 GestureType::Value GetType() const { return mType; }
82 * Called when we get a touch event.
83 * @param[in] scene The scene the touch event has occurred on
84 * @param[in] event The latest touch event
86 void SendEvent( Scene& scene, const Integration::TouchEvent& event )
95 * Protected Constructor. Should only be able to create derived class objects.
96 * @param[in] screenSize The size of the screen.
97 * @param[in] detectorType The type of gesture detector.
99 GestureRecognizer( Vector2 screenSize, GestureType::Value detectorType )
100 : mScreenSize( screenSize ),
101 mType( detectorType ),
107 * Protected Constructor. Should only be able to create derived class objects.
109 * Use this constructor with the screen size is not used in the dereived class.
110 * @param[in] detectorType The type of gesture detector.
112 GestureRecognizer( GestureType::Value detectorType )
113 : GestureRecognizer( Vector2::ZERO, detectorType )
118 * Virtual destructor.
120 ~GestureRecognizer() override = default;
124 GestureType::Value mType;
128 using GestureRecognizerPtr = IntrusivePtr<GestureRecognizer>;
130 } // namespace Internal
134 #endif // DALI_INTERNAL_GESTURE_RECOGNIZER_H