[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / internal / event / events / long-press-gesture-processor.h
1 #ifndef __DALI_INTERNAL_LONG_PRESS_GESTURE_EVENT_PROCESSOR_H__
2 #define __DALI_INTERNAL_LONG_PRESS_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/render-tasks/render-task.h>
22 #include <dali/internal/event/events/long-press-gesture-detector-impl.h>
23 #include <dali/internal/event/events/gesture-processor.h>
24
25 namespace Dali
26 {
27
28 namespace Integration
29 {
30 class GestureManager;
31 struct GestureEvent;
32 struct LongPressGestureEvent;
33 }
34
35 namespace Internal
36 {
37
38 class Stage;
39
40 /**
41  * Long Press Gesture Event Processing:
42  *
43  * When we receive a long press gesture event, we do the following:
44  * - Determine the hit actor underneath the long press gesture event.
45  * - Determine whether this actor is attached to any of the detectors or is a child of an actor
46  *   attached to one of the detectors.
47  * - Ensure the touches in the long press event match the requirements of the detector.
48  * - Emit the gesture when all the above conditions are met.
49  */
50 class LongPressGestureProcessor : public GestureProcessor
51 {
52 public:
53
54   /**
55    * Create a long press gesture processor.
56    * @param[in] stage The stage.
57    * @param[in] gestureManager The gesture manager.
58    */
59   LongPressGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager );
60
61   /**
62    * Non-virtual destructor; LongPressGestureProcessor is not a base class
63    */
64   ~LongPressGestureProcessor();
65
66 public: // To be called by GestureEventProcessor
67
68   /**
69    * This method is called whenever a long press gesture event occurs.
70    * @param[in] longPressEvent The event that has occurred.
71    */
72   void Process( const Integration::LongPressGestureEvent& longPressEvent );
73
74   /**
75    * Adds a gesture detector to this gesture processor.
76    * If this is the first gesture detector being added, then this method registers the required
77    * gesture with the adaptor.
78    * @param[in]  gestureDetector  The gesture detector being added.
79    */
80   void AddGestureDetector( LongPressGestureDetector* gestureDetector );
81
82   /**
83    * Removes the specified gesture detector from this gesture processor.  If, after removing this
84    * gesture detector, there are no more gesture detectors registered, then this method unregisters
85    * the gesture from the adaptor.
86    * @param[in]  gestureDetector  The gesture detector being removed.
87    */
88   void RemoveGestureDetector( LongPressGestureDetector* gestureDetector );
89
90   /**
91    * This method updates the gesture detection parameters.
92    * @param[in]  gestureDetector  The gesture detector that has been updated.
93    */
94   void GestureDetectorUpdated(LongPressGestureDetector* gestureDetector);
95
96 private:
97
98   // Undefined
99   LongPressGestureProcessor( const LongPressGestureProcessor& );
100   LongPressGestureProcessor& operator=( const LongPressGestureProcessor& rhs );
101
102 private:
103
104   /**
105    * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
106    * its detection policy.  If it does, it sends the appropriate gesture update request to adaptor.
107    */
108   void UpdateDetection();
109
110   // GestureProcessor overrides
111
112   /**
113    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
114    */
115   void OnGesturedActorStageDisconnection();
116
117 private:
118
119   Stage& mStage;
120   Integration::GestureManager& mGestureManager;
121   LongPressGestureDetectorContainer mGestureDetectors;
122
123   LongPressGestureDetectorContainer mCurrentEmitters;
124   Dali::RenderTask mCurrentRenderTask;
125
126   unsigned int mMinTouchesRequired;
127   unsigned int mMaxTouchesRequired;
128
129   struct LongPressEventFunctor;
130 };
131
132 } // namespace Internal
133
134 } // namespace Dali
135
136 #endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_EVENT_PROCESSOR_H__