1 #ifndef DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H
5 * Copyright (c) 2021 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/internal/event/events/gesture-detector-impl.h>
23 #include <dali/internal/event/events/long-press-gesture/long-press-gesture-processor.h>
24 #include <dali/internal/event/events/pan-gesture/pan-gesture-processor.h>
25 #include <dali/internal/event/events/pinch-gesture/pinch-gesture-processor.h>
26 #include <dali/internal/event/events/rotation-gesture/rotation-gesture-processor.h>
27 #include <dali/internal/event/events/tap-gesture/tap-gesture-processor.h>
28 #include <dali/public-api/actors/actor.h>
29 #include <dali/public-api/events/gesture.h>
35 class RenderController;
49 * Gesture Event Processing:
51 * The GestureEventProcessor determines what type of gesture event we have received and sends it to
52 * the appropriate gesture processor for processing.
54 class GestureEventProcessor
58 * Create a gesture event processor.
59 * @param[in] updateManager The update manager
60 * @param[in] renderController The render controller
62 GestureEventProcessor(SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController);
65 * Non-virtual destructor; GestureProcessor is not a base class
67 ~GestureEventProcessor();
69 public: // To be called by EventProcessor
71 * This function is called by Core whenever a touch event occurs
72 * @param[in] scene The scene
73 * @param[in] event The event that has occurred
75 void ProcessTouchEvent(Scene& scene, const Integration::TouchEvent& event);
77 public: // To be called by gesture detectors
79 * This method adds the specified gesture detector to the relevant gesture processor.
80 * @param[in] gestureDetector The gesture detector to add
82 void AddGestureDetector(GestureDetector* gestureDetector, Scene& scene);
85 * This method removes the specified gesture detector from the relevant gesture processor.
86 * @param[in] gestureDetector The gesture detector to remove.
88 void RemoveGestureDetector(GestureDetector* gestureDetector);
91 * This method informs the appropriate processor that the gesture detector has been updated.
92 * @param[in] gestureDetector The gesture detector that has been updated.
94 void GestureDetectorUpdated(GestureDetector* gestureDetector);
97 * Called by GestureDetectors to set the gesture properties in the update thread.
98 * @param[in] gesture The gesture whose values will be used in the Update object.
99 * @note If we are in the middle of processing the gesture being set, then this call is ignored.
101 void SetGestureProperties(const Dali::Gesture& gesture);
103 public: // Called by Core
105 * Returns true if any GestureDetector requires a Core::Update. Clears
106 * the state flag after reading.
108 * @return true if any GestureDetector requires a Core::Update
113 * Called to provide pan-gesture profiling information.
115 void EnablePanGestureProfiling();
118 * @brief Called to set how pan gestures predict input
120 * @param[in] mode The prediction mode to use
122 void SetPanGesturePredictionMode(int32_t mode);
125 * @brief Sets the prediction amount of the pan gesture
127 * @param[in] amount The prediction amount in milliseconds
129 void SetPanGesturePredictionAmount(uint32_t amount);
132 * @brief Sets the upper bound of the prediction amount for clamping
134 * @param[in] amount The prediction amount in milliseconds
136 void SetPanGestureMaximumPredictionAmount(uint32_t amount);
139 * @brief Sets the lower bound of the prediction amount for clamping
141 * @param[in] amount The prediction amount in milliseconds
143 void SetPanGestureMinimumPredictionAmount(uint32_t amount);
146 * @brief Sets the prediction amount to adjust when the pan velocity is changed.
147 * If the pan velocity is accelerating, the prediction amount will be increased
148 * by the specified amount until it reaches the upper bound. If the pan velocity
149 * is decelerating, the prediction amount will be decreased by the specified amount
150 * until it reaches the lower bound.
152 * @param[in] amount The prediction amount in milliseconds
154 void SetPanGesturePredictionAmountAdjustment(uint32_t amount);
157 * @brief Called to set how pan gestures smooth input
159 * @param[in] mode The smoothing mode to use
161 void SetPanGestureSmoothingMode(int32_t mode);
164 * @brief Sets the prediction amount of the pan gesture
166 * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
168 void SetPanGestureSmoothingAmount(float amount);
171 * @brief Sets whether to use actual times of the real gesture and frames or not.
173 * @param[in] value True = use actual times, False = use perfect values
175 void SetPanGestureUseActualTimes(bool value);
178 * @brief Sets the interpolation time range (ms) of past points to use (with weights) when interpolating.
180 * @param[in] value Time range in ms
182 void SetPanGestureInterpolationTimeRange(int32_t value);
185 * @brief Sets whether to use scalar only prediction, which when enabled, ignores acceleration.
187 * @param[in] value True = use scalar prediction only
189 void SetPanGestureScalarOnlyPredictionEnabled(bool value);
192 * @brief Sets whether to use two point prediction. This combines two interpolated points to get more steady acceleration and velocity values.
194 * @param[in] value True = use two point prediction
196 void SetPanGestureTwoPointPredictionEnabled(bool value);
199 * @brief Sets the time in the past to interpolate the second point when using two point interpolation.
201 * @param[in] value Time in past in ms
203 void SetPanGestureTwoPointInterpolatePastTime(int32_t value);
206 * @brief Sets the two point velocity bias. This is the ratio of first and second points to use for velocity.
208 * @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
210 void SetPanGestureTwoPointVelocityBias(float value);
213 * @brief Sets the two point acceleration bias. This is the ratio of first and second points to use for acceleration.
215 * @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
217 void SetPanGestureTwoPointAccelerationBias(float value);
220 * @brief Sets the range of time (ms) of points in the history to perform multitap smoothing with (if enabled).
222 * @param[in] value Time in past in ms
224 void SetPanGestureMultitapSmoothingRange(int32_t value);
227 * @brief Sets the minimum distance required to start a pan event
229 * @param[in] value Distance in pixels
231 void SetPanGestureMinimumDistance(int32_t value);
234 * @brief Sets the minimum number of touch events required to start a pan
236 * @param[in] value Number of touch events
238 void SetPanGestureMinimumPanEvents(int32_t value);
241 * @brief Sets the minimum distance required to start a pinch event
243 * @param[in] value Distance in pixels
245 void SetPinchGestureMinimumDistance(float value);
248 * @brief Sets the minimum touch events required before a pinch can be started
250 * @param[in] value The number of touch events
252 void SetPinchGestureMinimumTouchEvents(uint32_t value);
255 * @brief Sets the minimum touch events required after a pinch started
257 * @param[in] value The number of touch events
259 void SetPinchGestureMinimumTouchEventsAfterStart(uint32_t value);
262 * @brief Sets the minimum touch events required before a rotation can be started
264 * @param[in] value The number of touch events
266 void SetRotationGestureMinimumTouchEvents(uint32_t value);
269 * @brief Sets the minimum touch events required after a rotation started
271 * @param[in] value The number of touch events
273 void SetRotationGestureMinimumTouchEventsAfterStart(uint32_t value);
276 * @brief Sets the minimum holding time required to be recognized as a long press gesture
278 * @param[in] value The time value in milliseconds
280 void SetLongPressMinimumHoldingTime(uint32_t value);
283 * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
285 uint32_t GetLongPressMinimumHoldingTime() const;
288 * @brief Sets the maximum allowed time required to be recognized as a multi tap gesture (millisecond)
290 * @param[in] time The time value in milliseconds
292 void SetTapMaximumAllowedTime(uint32_t time);
294 public: // needed for PanGesture
296 * @return the pan gesture processor
298 const PanGestureProcessor& GetPanGestureProcessor();
302 GestureEventProcessor(const GestureEventProcessor&);
303 GestureEventProcessor& operator=(const GestureEventProcessor& rhs);
306 LongPressGestureProcessor mLongPressGestureProcessor;
307 PanGestureProcessor mPanGestureProcessor;
308 PinchGestureProcessor mPinchGestureProcessor;
309 TapGestureProcessor mTapGestureProcessor;
310 RotationGestureProcessor mRotationGestureProcessor;
311 Integration::RenderController& mRenderController;
313 int32_t envOptionMinimumPanDistance;
314 int32_t envOptionMinimumPanEvents;
317 } // namespace Internal
321 #endif // DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H