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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/public-api/render-tasks/render-task.h>
22 #include <dali/internal/event/events/pan-gesture-detector-impl.h>
23 #include <dali/internal/event/events/gesture-processor.h>
32 struct PanGestureEvent;
46 * Pan Gesture Event Processing:
48 * When we receive a pinch gesture event, we do the following:
49 * - Determine the hot actor underneath the current position of the pan gesture event.
50 * - Determine whether this actor is, or is a child of, the actor(s) attached to any of the
52 * - Emit the gesture when all the above conditions are met.
54 * The above is only checked when our gesture starts. We continue sending the pan gesture to the
55 * same actor and detector until the pan ends or is cancelled.
57 class PanGestureProcessor : public GestureProcessor
62 * Create a pan gesture processor.
63 * @param[in] stage The stage.
64 * @param[in] gestureManager The gesture manager
66 PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager );
69 * Non-virtual destructor; PanGestureProcessor is not a base class
71 ~PanGestureProcessor();
73 public: // To be called by GestureEventProcessor
76 * This method is called whenever a pinch gesture event occurs.
77 * @param[in] panEvent The event that has occurred.
79 void Process( const Integration::PanGestureEvent& panEvent );
82 * Adds a gesture detector to this gesture processor.
83 * If this is the first gesture detector being added, then this method registers the required
84 * gesture with the adaptor.
85 * @param[in] gestureDetector The gesture detector being added.
87 void AddGestureDetector( PanGestureDetector* gestureDetector );
90 * Removes the specified gesture detector from this gesture processor. If, after removing this
91 * gesture detector, there are no more gesture detectors registered, then this method unregisters
92 * the gesture from the adaptor.
93 * @param[in] gestureDetector The gesture detector being removed.
95 void RemoveGestureDetector( PanGestureDetector* gestureDetector );
98 * This method updates the gesture detection parameters.
99 * @param[in] gestureDetector The gesture detector that has been updated.
101 void GestureDetectorUpdated( PanGestureDetector* gestureDetector );
104 * Sets the pan gesture properties stored in the scene object directly,
105 * @param[in] pan The pan gesture to override the properties with.
106 * @note If we are already processing a normal pan, then this call is ignored.
108 void SetPanGestureProperties( const PanGesture& pan );
111 * Called to provide pan-gesture profiling information.
113 void EnableProfiling();
116 * Called to set the prediction mode for pan gestures
118 * @param[in] mode The prediction mode
122 * 1 - Average Smoothing (no actual prediction)
123 * 2 - Interpolation using last vsync time and event time
124 * 3 - Same as 2 for now, in progress
126 void SetPredictionMode(int mode);
131 PanGestureProcessor( const PanGestureProcessor& );
132 PanGestureProcessor& operator=( const PanGestureProcessor& rhs );
135 * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
136 * its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
138 void UpdateDetection();
141 * Creates a PanGesture and asks the specified detector to emit its detected signal.
142 * @param[in] actor The actor that has been panned.
143 * @param[in] gestureDetectors The gesture detector container that should emit the signal.
144 * @param[in] panEvent The panEvent received from the adaptor.
145 * @param[in] localCurrent Current position relative to the actor attached to the detector.
146 * @param[in] state The state of the gesture.
147 * @param[in] renderTask The renderTask to use.
149 void EmitPanSignal( Dali::Actor actor,
150 PanGestureDetectorContainer& gestureDetectors,
151 const Integration::PanGestureEvent& panEvent,
152 Vector2 localCurrent,
153 Gesture::State state,
154 Dali::RenderTask renderTask );
156 // GestureProcessor overrides
159 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
161 void OnGesturedActorStageDisconnection();
166 Integration::GestureManager& mGestureManager;
167 PanGestureDetectorContainer mGestureDetectors;
168 PanGestureDetectorContainer mCurrentPanEmitters;
169 Dali::RenderTask mCurrentRenderTask;
170 Vector2 mPossiblePanPosition;
172 unsigned int mMinTouchesRequired;
173 unsigned int mMaxTouchesRequired;
175 Vector2 mLastVelocity; ///< The last recorded velocity in local actor coordinates.
176 Vector2 mLastScreenVelocity; ///< The last recorded velocity in screen coordinates.
178 struct PanEventFunctor;
180 SceneGraph::PanGesture* mSceneObject; ///< Not owned, but we write to it directly
183 } // namespace Internal
187 #endif // __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__