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