1 #ifndef __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__
2 #define __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__
5 * Copyright (c) 2017 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/internal/event/events/gesture-detector-impl.h>
24 #include <dali/internal/event/events/long-press-gesture-processor.h>
25 #include <dali/internal/event/events/pan-gesture-processor.h>
26 #include <dali/internal/event/events/pinch-gesture-processor.h>
27 #include <dali/internal/event/events/tap-gesture-processor.h>
38 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] stage The stage.
64 * @param[in] updateManager The update manager
65 * @param[in] gestureManager The gesture manager
66 * @param[in] renderController The render controller
68 GestureEventProcessor( Stage& stage, SceneGraph::UpdateManager& updateManager, Integration::GestureManager& gestureManager, Integration::RenderController& renderController );
71 * Non-virtual destructor; GestureProcessor is not a base class
73 ~GestureEventProcessor();
75 public: // To be called by EventProcessor
78 * This function is called by Core whenever a gesture event occurs.
79 * @param[in] event The event that has occurred.
81 void ProcessGestureEvent(const Integration::GestureEvent& event);
83 public: // To be called by gesture detectors
86 * This method adds the specified gesture detector to the relevant gesture processor.
87 * @param[in] gestureDetector The gesture detector to add
89 void AddGestureDetector(GestureDetector* gestureDetector);
92 * This method removes the specified gesture detector from the relevant gesture processor.
93 * @param[in] gestureDetector The gesture detector to remove.
95 void RemoveGestureDetector(GestureDetector* gestureDetector);
98 * This method informs the appropriate processor that the gesture detector has been updated.
99 * @param[in] gestureDetector The gesture detector that has been updated.
101 void GestureDetectorUpdated(GestureDetector* gestureDetector);
104 * This method is called by GestureDetectors on Started or Continue state events.
105 * Status is queried and reset by Core in ProcessEvents
107 void SetUpdateRequired();
110 * Called by GestureDetectors to set the gesture properties in the update thread.
111 * @param[in] gesture The gesture whose values will be used in the Update object.
112 * @note If we are in the middle of processing the gesture being set, then this call is ignored.
114 void SetGestureProperties( const Gesture& gesture );
116 public: // Called by Core
119 * Returns true if any GestureDetector requires a Core::Update. Clears
120 * the state flag after reading.
122 * @return true if any GestureDetector requires a Core::Update
127 * Called to provide pan-gesture profiling information.
129 void EnablePanGestureProfiling();
132 * @brief Called to set how pan gestures predict input
134 * @param[in] mode The prediction mode to use
136 void SetPanGesturePredictionMode( int mode );
139 * @brief Sets the prediction amount of the pan gesture
141 * @param[in] amount The prediction amount in milliseconds
143 void SetPanGesturePredictionAmount( unsigned int amount );
146 * @brief Sets the upper bound of the prediction amount for clamping
148 * @param[in] amount The prediction amount in milliseconds
150 void SetPanGestureMaximumPredictionAmount( unsigned int amount );
153 * @brief Sets the lower bound of the prediction amount for clamping
155 * @param[in] amount The prediction amount in milliseconds
157 void SetPanGestureMinimumPredictionAmount( unsigned int amount );
160 * @brief Sets the prediction amount to adjust when the pan velocity is changed.
161 * If the pan velocity is accelerating, the prediction amount will be increased
162 * by the specified amount until it reaches the upper bound. If the pan velocity
163 * is decelerating, the prediction amount will be decreased by the specified amount
164 * until it reaches the lower bound.
166 * @param[in] amount The prediction amount in milliseconds
168 void SetPanGesturePredictionAmountAdjustment( unsigned int amount );
171 * @brief Called to set how pan gestures smooth input
173 * @param[in] mode The smoothing mode to use
175 void SetPanGestureSmoothingMode( int mode );
178 * @brief Sets the prediction amount of the pan gesture
180 * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
182 void SetPanGestureSmoothingAmount( float amount );
187 GestureEventProcessor(const GestureEventProcessor&);
188 GestureEventProcessor& operator=(const GestureEventProcessor& rhs);
193 Integration::GestureManager& mGestureManager;
195 LongPressGestureProcessor mLongPressGestureProcessor;
196 PanGestureProcessor mPanGestureProcessor;
197 PinchGestureProcessor mPinchGestureProcessor;
198 TapGestureProcessor mTapGestureProcessor;
199 Integration::RenderController& mRenderController;
201 bool mUpdateRequired; ///< set to true by gesture detectors if they require a Core::Update
204 } // namespace Internal
208 #endif // __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__