Refactor SceneGraphProperty handling code in event side to make RegisterProperty...
[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) 2018 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/internal/event/events/long-press-gesture-detector-impl.h>
23 #include <dali/internal/event/events/gesture-processor.h>
24 #include <dali/internal/event/render-tasks/render-task-impl.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  * - Find the actor that requires a long-press at the long press position.
46  * - Emit the gesture if the event satisfies the detector conditions.
47  */
48 class LongPressGestureProcessor : public GestureProcessor
49 {
50 public:
51
52   /**
53    * Create a long press gesture processor.
54    * @param[in] stage The stage.
55    * @param[in] gestureManager The gesture manager.
56    */
57   LongPressGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager );
58
59   /**
60    * Non-virtual destructor; LongPressGestureProcessor is not a base class
61    */
62   ~LongPressGestureProcessor();
63
64 public: // To be called by GestureEventProcessor
65
66   /**
67    * This method is called whenever a long press gesture event occurs.
68    * @param[in] longPressEvent The event that has occurred.
69    */
70   void Process( const Integration::LongPressGestureEvent& longPressEvent );
71
72   /**
73    * Adds a gesture detector to this gesture processor.
74    * If this is the first gesture detector being added, then this method registers the required
75    * gesture with the adaptor.
76    * @param[in]  gestureDetector  The gesture detector being added.
77    */
78   void AddGestureDetector( LongPressGestureDetector* gestureDetector );
79
80   /**
81    * Removes the specified gesture detector from this gesture processor.  If, after removing this
82    * gesture detector, there are no more gesture detectors registered, then this method unregisters
83    * the gesture from the adaptor.
84    * @param[in]  gestureDetector  The gesture detector being removed.
85    */
86   void RemoveGestureDetector( LongPressGestureDetector* gestureDetector );
87
88   /**
89    * This method updates the gesture detection parameters.
90    * @param[in]  gestureDetector  The gesture detector that has been updated.
91    */
92   void GestureDetectorUpdated(LongPressGestureDetector* gestureDetector);
93
94 private:
95
96   // Undefined
97   LongPressGestureProcessor( const LongPressGestureProcessor& );
98   LongPressGestureProcessor& operator=( const LongPressGestureProcessor& rhs );
99
100 private:
101
102   /**
103    * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
104    * its detection policy.  If it does, it sends the appropriate gesture update request to adaptor.
105    */
106   void UpdateDetection();
107
108   // GestureProcessor overrides
109
110   /**
111    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
112    */
113   void OnGesturedActorStageDisconnection();
114
115   /**
116    * @copydoc GestureProcessor::CheckGestureDetector()
117    */
118   bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
119
120   /**
121    * @copydoc GestureProcessor::EmitGestureSignal()
122    */
123   void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
124
125 private:
126
127   Stage& mStage;
128   Integration::GestureManager& mGestureManager;
129   LongPressGestureDetectorContainer mGestureDetectors;
130
131   GestureDetectorContainer mCurrentEmitters;
132   RenderTaskPtr mCurrentRenderTask;
133
134   uint32_t mMinTouchesRequired;
135   uint32_t mMaxTouchesRequired;
136
137   const Integration::LongPressGestureEvent* mCurrentLongPressEvent; ///< Pointer to current longPressEvent, used when calling ProcessAndEmit()
138 };
139
140 } // namespace Internal
141
142 } // namespace Dali
143
144 #endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_EVENT_PROCESSOR_H__