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 );
113 PanGestureProcessor( const PanGestureProcessor& );
114 PanGestureProcessor& operator=( const PanGestureProcessor& rhs );
117 * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
118 * its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
120 void UpdateDetection();
123 * Creates a PanGesture and asks the specified detector to emit its detected signal.
124 * @param[in] actor The actor that has been panned.
125 * @param[in] gestureDetectors The gesture detector container that should emit the signal.
126 * @param[in] panEvent The panEvent received from the adaptor.
127 * @param[in] localCurrent Current position relative to the actor attached to the detector.
128 * @param[in] state The state of the gesture.
129 * @param[in] renderTask The renderTask to use.
131 void EmitPanSignal( Dali::Actor actor,
132 PanGestureDetectorContainer& gestureDetectors,
133 const Integration::PanGestureEvent& panEvent,
134 Vector2 localCurrent,
135 Gesture::State state,
136 Dali::RenderTask renderTask );
138 // GestureProcessor overrides
141 * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
143 void OnGesturedActorStageDisconnection();
148 Integration::GestureManager& mGestureManager;
149 PanGestureDetectorContainer mGestureDetectors;
150 PanGestureDetectorContainer mCurrentPanEmitters;
151 Dali::RenderTask mCurrentRenderTask;
152 Vector2 mPossiblePanPosition;
154 unsigned int mMinTouchesRequired;
155 unsigned int mMaxTouchesRequired;
157 Vector2 mLastVelocity; ///< The last recorded velocity in local actor coordinates.
158 Vector2 mLastScreenVelocity; ///< The last recorded velocity in screen coordinates.
160 struct PanEventFunctor;
162 SceneGraph::PanGesture* mSceneObject; ///< Not owned, but we write to it directly
165 } // namespace Internal
169 #endif // __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__