Pan Gesture Prediction - Added DALI_PAN_GESTURE_PREDICTION_AMOUNT environment variable
[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 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
10 //
11 //     http://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/actors/actor.h>
22 #include <dali/internal/event/events/gesture-detector-impl.h>
23 #include <dali/internal/event/events/long-press-gesture-processor.h>
24 #include <dali/internal/event/events/pan-gesture-processor.h>
25 #include <dali/internal/event/events/pinch-gesture-processor.h>
26 #include <dali/internal/event/events/tap-gesture-processor.h>
27
28 namespace Dali
29 {
30
31 struct Gesture;
32
33 namespace Integration
34 {
35 struct GestureEvent;
36 class GestureManager;
37 class RenderController;
38 }
39
40 namespace Internal
41 {
42
43 class Stage;
44
45 /**
46  * Gesture Event Processing:
47  *
48  * The GestureEventProcessor determines what type of gesture event we have received and sends it to
49  * the appropriate gesture processor for processing.
50  */
51 class GestureEventProcessor
52 {
53 public:
54
55   /**
56    * Create a gesture event processor.
57    * @param[in] stage The stage.
58    * @param[in] gestureManager The gesture manager
59    * @param[in] renderController The render controller
60    */
61   GestureEventProcessor(Stage& stage, Integration::GestureManager& gestureManager, Integration::RenderController& renderController);
62
63   /**
64    * Non-virtual destructor; GestureProcessor is not a base class
65    */
66   ~GestureEventProcessor();
67
68 public: // To be called by EventProcessor
69
70   /**
71    * This function is called by Core whenever a gesture event occurs.
72    * @param[in] event The event that has occurred.
73    */
74   void ProcessGestureEvent(const Integration::GestureEvent& event);
75
76 public: // To be called by gesture detectors
77
78   /**
79    * This method adds the specified gesture detector to the relevant gesture processor.
80    * @param[in]  gestureDetector  The gesture detector to add
81    */
82   void AddGestureDetector(GestureDetector* gestureDetector);
83
84   /**
85    * This method removes the specified gesture detector from the relevant gesture processor.
86    * @param[in]  gestureDetector  The gesture detector to remove.
87    */
88   void RemoveGestureDetector(GestureDetector* gestureDetector);
89
90   /**
91    * This method informs the appropriate processor that the gesture detector has been updated.
92    * @param[in]  gestureDetector  The gesture detector that has been updated.
93    */
94   void GestureDetectorUpdated(GestureDetector* gestureDetector);
95
96   /**
97    * This method is called by GestureDetectors on Started or Continue state events.
98    * Status is queried and reset by Core in ProcessEvents
99    */
100   void SetUpdateRequired();
101
102   /**
103    * Called by GestureDetectors to set the gesture properties in the update thread.
104    * @param[in]  gesture  The gesture whose values will be used in the Update object.
105    * @note If we are in the middle of processing the gesture being set, then this call is ignored.
106    */
107   void SetGestureProperties( const Gesture& gesture );
108
109 public: // Called by Core
110
111   /**
112    * Returns true if any GestureDetector requires a Core::Update. Clears
113    * the state flag after reading.
114    *
115    * @return true if any GestureDetector requires a Core::Update
116    */
117   bool NeedsUpdate();
118
119   /**
120    * Called to provide pan-gesture profiling information.
121    */
122   void EnablePanGestureProfiling();
123
124   /**
125    * @brief Called to set how pan gestures predict and smooth input
126    *
127    * @param[in] mode The prediction mode to use
128    */
129   void SetPanGesturePredictionMode( int mode );
130
131   /**
132    * @brief Sets the prediction amount of the pan gesture
133    *
134    * @param[in] amount The prediction amount, 0.0f being next vsync and each 1.0f on top is another vsync ahead, can be divisions of (0.5f)
135    */
136   void SetPanGesturePredictionAmount( float amount );
137
138 private:
139
140   // Undefined
141   GestureEventProcessor(const GestureEventProcessor&);
142   GestureEventProcessor& operator=(const GestureEventProcessor& rhs);
143
144 private:
145
146   Stage& mStage;
147   Integration::GestureManager& mGestureManager;
148
149   LongPressGestureProcessor mLongPressGestureProcessor;
150   PanGestureProcessor mPanGestureProcessor;
151   PinchGestureProcessor mPinchGestureProcessor;
152   TapGestureProcessor mTapGestureProcessor;
153   Integration::RenderController& mRenderController;
154
155   bool mUpdateRequired;     ///< set to true by gesture detectors if they require a Core::Update
156 };
157
158 } // namespace Internal
159
160 } // namespace Dali
161
162 #endif // __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__