1 #ifndef __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__
2 #define __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__
5 * Copyright (c) 2014 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/render-tasks/render-task.h>
23 #include <dali/internal/event/events/pan-gesture-detector-impl.h>
24 #include <dali/internal/event/events/gesture-processor.h>
33 struct PanGestureEvent;
47 * Pan Gesture Event Processing:
49 * When we receive a pinch gesture event, we do the following:
50 * - Determine the hot actor underneath the current position of the pan gesture event.
51 * - Determine whether this actor is, or is a child of, the actor(s) attached to any of the
53 * - Emit the gesture when all the above conditions are met.
55 * The above is only checked when our gesture starts. We continue sending the pan gesture to the
56 * same actor and detector until the pan ends or is cancelled.
58 class PanGestureProcessor : public GestureProcessor
63 * Create a pan gesture processor.
64 * @param[in] stage The stage.
65 * @param[in] gestureManager The gesture manager
67 PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager );
70 * Non-virtual destructor; PanGestureProcessor is not a base class
72 ~PanGestureProcessor();
74 public: // To be called by GestureEventProcessor
77 * This method is called whenever a pinch gesture event occurs.
78 * @param[in] panEvent The event that has occurred.
80 void Process( const Integration::PanGestureEvent& panEvent );
83 * Adds a gesture detector to this gesture processor.
84 * If this is the first gesture detector being added, then this method registers the required
85 * gesture with the adaptor.
86 * @param[in] gestureDetector The gesture detector being added.
88 void AddGestureDetector( PanGestureDetector* gestureDetector );
91 * Removes the specified gesture detector from this gesture processor. If, after removing this
92 * gesture detector, there are no more gesture detectors registered, then this method unregisters
93 * the gesture from the adaptor.
94 * @param[in] gestureDetector The gesture detector being removed.
96 void RemoveGestureDetector( PanGestureDetector* gestureDetector );
99 * This method updates the gesture detection parameters.
100 * @param[in] gestureDetector The gesture detector that has been updated.
102 void GestureDetectorUpdated( PanGestureDetector* gestureDetector );
105 * Sets the pan gesture properties stored in the scene object directly,
106 * @param[in] pan The pan gesture to override the properties with.
107 * @note If we are already processing a normal pan, then this call is ignored.
109 void SetPanGestureProperties( const PanGesture& pan );
112 * Called to provide pan-gesture profiling information.
114 void EnableProfiling();
117 * Called to set the prediction mode for pan gestures
119 * @param[in] mode The prediction mode
123 * 1 - Average Smoothing (no actual prediction)
124 * 2 - Interpolation using last vsync time and event time
125 * 3 - Same as 2 for now, in progress
127 void SetPredictionMode(int mode);
130 * @brief Sets the prediction amount of the pan gesture
132 * @param[in] amount The prediction amount in milliseconds
134 void SetPredictionAmount(unsigned int amount);
139 PanGestureProcessor( const PanGestureProcessor& );
140 PanGestureProcessor& operator=( const PanGestureProcessor& rhs );
143 * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
144 * its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
146 void UpdateDetection();
149 * Creates a PanGesture and asks the specified detector to emit its detected signal.
150 * @param[in] actor The actor that has been panned.
151 * @param[in] gestureDetectors The gesture detector container that should emit the signal.
152 * @param[in] panEvent The panEvent received from the adaptor.
153 * @param[in] localCurrent Current position relative to the actor attached to the detector.
154 * @param[in] state The state of the gesture.
155 * @param[in] renderTask The renderTask to use.
157 void EmitPanSignal( Actor* actor,
158 const GestureDetectorContainer& gestureDetectors,
159 const Integration::PanGestureEvent& panEvent,
160 Vector2 localCurrent,
161 Gesture::State state,
162 Dali::RenderTask renderTask );
164 // GestureProcessor overrides
167 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
169 void OnGesturedActorStageDisconnection();
172 * @copydoc GestureProcessor::CheckGestureDetector()
174 bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
177 * @copydoc GestureProcessor::EmitGestureSignal()
179 void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
184 Integration::GestureManager& mGestureManager;
185 PanGestureDetectorContainer mGestureDetectors;
186 GestureDetectorContainer mCurrentPanEmitters;
187 Dali::RenderTask mCurrentRenderTask;
188 Vector2 mPossiblePanPosition;
190 unsigned int mMinTouchesRequired;
191 unsigned int mMaxTouchesRequired;
193 Vector2 mLastVelocity; ///< The last recorded velocity in local actor coordinates.
194 Vector2 mLastScreenVelocity; ///< The last recorded velocity in screen coordinates.
196 const Integration::PanGestureEvent* mCurrentPanEvent; ///< Pointer to current PanEvent, used when calling ProcessAndEmit()
197 SceneGraph::PanGesture* mSceneObject; ///< Not owned, but we write to it directly
200 } // namespace Internal
204 #endif // __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__