Conversion to Apache 2.0 license
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture-processor.h
1 #ifndef __DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H__
2 #define __DALI_INTERNAL_PINCH_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/pinch-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 PinchGestureEvent;
34 }
35
36 namespace Internal
37 {
38
39 class Stage;
40
41 /**
42  * Pinch Gesture Event Processing:
43  *
44  * When we receive a pinch gesture event, we do the following:
45  * - Determine the hit actor underneath the center of the pinch gesture event.
46  * - Determine whether this actor is, or is a child of, the actor attached to any of the detectors.
47  * - Emit the gesture when all the above conditions are met.
48  *
49  * The above is only checked when our gesture starts. We continue sending the pinch gesture to this
50  * detector until the pinch ends or is cancelled.
51  */
52 class PinchGestureProcessor : public GestureProcessor
53 {
54 public:
55
56   /**
57    * Create a pinch gesture processor.
58    * @param[in] stage The stage.
59    * @param[in] gestureManager The gesture manager
60    */
61   PinchGestureProcessor(Stage& stage, Integration::GestureManager& gestureManager);
62
63   /**
64    * Non-virtual destructor; PinchGestureProcessor is not a base class
65    */
66   ~PinchGestureProcessor();
67
68 public: // To be called by GestureEventProcessor
69
70   /**
71    * This method is called whenever a pinch gesture event occurs.
72    * @param[in] pinchEvent The event that has occurred.
73    */
74   void Process(const Integration::PinchGestureEvent& pinchEvent);
75
76   /**
77    * Adds a gesture detector to this gesture processor.
78    * If this is the first gesture detector being added, then this method registers the required
79    * gesture with the adaptor.
80    * @param[in]  gestureDetector  The gesture detector being added.
81    */
82   void AddGestureDetector(PinchGestureDetector* gestureDetector);
83
84   /**
85    * Removes the specified gesture detector from this gesture processor.  If, after removing this
86    * gesture detector, there are no more gesture detectors registered, then this method unregisters
87    * the gesture from the adaptor.
88    * @param[in]  gestureDetector  The gesture detector being removed.
89    */
90   void RemoveGestureDetector(PinchGestureDetector* gestureDetector);
91
92   /**
93    * This method updates the gesture detection parameters.
94    * @param[in]  gestureDetector  The gesture detector that has been updated.
95    */
96   void GestureDetectorUpdated(PinchGestureDetector* gestureDetector);
97
98 private:
99
100   // Undefined
101   PinchGestureProcessor(const PinchGestureProcessor&);
102   PinchGestureProcessor& operator=(const PinchGestureProcessor& rhs);
103
104 private:
105
106   // GestureProcessor overrides
107
108   /**
109    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
110    */
111   void OnGesturedActorStageDisconnection();
112
113 private:
114
115   Stage& mStage;
116   Integration::GestureManager& mGestureManager;
117   PinchGestureDetectorContainer mGestureDetectors;
118   PinchGestureDetectorContainer mCurrentPinchEmitters;
119   Dali::RenderTask mCurrentRenderTask;
120
121   struct PinchEventFunctor;
122 };
123
124 } // namespace Internal
125
126 } // namespace Dali
127
128 #endif // __DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H__