[dali_1.0.28] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-event-processor.h
1 #ifndef __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__
2 #define __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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>
28
29 namespace Dali
30 {
31
32 struct Gesture;
33
34 namespace Integration
35 {
36 struct GestureEvent;
37 class GestureManager;
38 class RenderController;
39 }
40
41 namespace Internal
42 {
43
44 class Stage;
45
46 /**
47  * Gesture Event Processing:
48  *
49  * The GestureEventProcessor determines what type of gesture event we have received and sends it to
50  * the appropriate gesture processor for processing.
51  */
52 class GestureEventProcessor
53 {
54 public:
55
56   /**
57    * Create a gesture event processor.
58    * @param[in] stage The stage.
59    * @param[in] gestureManager The gesture manager
60    * @param[in] renderController The render controller
61    */
62   GestureEventProcessor(Stage& stage, Integration::GestureManager& gestureManager, Integration::RenderController& renderController);
63
64   /**
65    * Non-virtual destructor; GestureProcessor is not a base class
66    */
67   ~GestureEventProcessor();
68
69 public: // To be called by EventProcessor
70
71   /**
72    * This function is called by Core whenever a gesture event occurs.
73    * @param[in] event The event that has occurred.
74    */
75   void ProcessGestureEvent(const Integration::GestureEvent& event);
76
77 public: // To be called by gesture detectors
78
79   /**
80    * This method adds the specified gesture detector to the relevant gesture processor.
81    * @param[in]  gestureDetector  The gesture detector to add
82    */
83   void AddGestureDetector(GestureDetector* gestureDetector);
84
85   /**
86    * This method removes the specified gesture detector from the relevant gesture processor.
87    * @param[in]  gestureDetector  The gesture detector to remove.
88    */
89   void RemoveGestureDetector(GestureDetector* gestureDetector);
90
91   /**
92    * This method informs the appropriate processor that the gesture detector has been updated.
93    * @param[in]  gestureDetector  The gesture detector that has been updated.
94    */
95   void GestureDetectorUpdated(GestureDetector* gestureDetector);
96
97   /**
98    * This method is called by GestureDetectors on Started or Continue state events.
99    * Status is queried and reset by Core in ProcessEvents
100    */
101   void SetUpdateRequired();
102
103   /**
104    * Called by GestureDetectors to set the gesture properties in the update thread.
105    * @param[in]  gesture  The gesture whose values will be used in the Update object.
106    * @note If we are in the middle of processing the gesture being set, then this call is ignored.
107    */
108   void SetGestureProperties( const Gesture& gesture );
109
110 public: // Called by Core
111
112   /**
113    * Returns true if any GestureDetector requires a Core::Update. Clears
114    * the state flag after reading.
115    *
116    * @return true if any GestureDetector requires a Core::Update
117    */
118   bool NeedsUpdate();
119
120   /**
121    * Called to provide pan-gesture profiling information.
122    */
123   void EnablePanGestureProfiling();
124
125   /**
126    * @brief Called to set how pan gestures predict input
127    *
128    * @param[in] mode The prediction mode to use
129    */
130   void SetPanGesturePredictionMode( int mode );
131
132   /**
133    * @brief Sets the prediction amount of the pan gesture
134    *
135    * @param[in] amount The prediction amount in milliseconds
136    */
137   void SetPanGesturePredictionAmount( unsigned int amount );
138
139   /**
140    * @brief Sets the upper bound of the prediction amount for clamping
141    *
142    * @param[in] amount The prediction amount in milliseconds
143    */
144   void SetPanGestureMaximumPredictionAmount( unsigned int amount );
145
146   /**
147    * @brief Sets the lower bound of the prediction amount for clamping
148    *
149    * @param[in] amount The prediction amount in milliseconds
150    */
151   void SetPanGestureMinimumPredictionAmount( unsigned int amount );
152
153   /**
154    * @brief Sets the prediction amount to adjust when the pan velocity is changed.
155    * If the pan velocity is accelerating, the prediction amount will be increased
156    * by the specified amount until it reaches the upper bound. If the pan velocity
157    * is decelerating, the prediction amount will be decreased by the specified amount
158    * until it reaches the lower bound.
159    *
160    * @param[in] amount The prediction amount in milliseconds
161    */
162   void SetPanGesturePredictionAmountAdjustment( unsigned int amount );
163
164   /**
165    * @brief Called to set how pan gestures smooth input
166    *
167    * @param[in] mode The smoothing mode to use
168    */
169   void SetPanGestureSmoothingMode( int mode );
170
171   /**
172    * @brief Sets the prediction amount of the pan gesture
173    *
174    * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
175    */
176   void SetPanGestureSmoothingAmount( float amount );
177
178 private:
179
180   // Undefined
181   GestureEventProcessor(const GestureEventProcessor&);
182   GestureEventProcessor& operator=(const GestureEventProcessor& rhs);
183
184 private:
185
186   Stage& mStage;
187   Integration::GestureManager& mGestureManager;
188
189   LongPressGestureProcessor mLongPressGestureProcessor;
190   PanGestureProcessor mPanGestureProcessor;
191   PinchGestureProcessor mPinchGestureProcessor;
192   TapGestureProcessor mTapGestureProcessor;
193   Integration::RenderController& mRenderController;
194
195   bool mUpdateRequired;     ///< set to true by gesture detectors if they require a Core::Update
196 };
197
198 } // namespace Internal
199
200 } // namespace Dali
201
202 #endif // __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__