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