Add an environment variable for long press gesture
[platform/core/uifw/dali-core.git] / dali / internal / event / events / long-press-gesture / 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) 2019 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/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 Internal
30 {
31
32 class Stage;
33 class Scene;
34
35 struct GestureEvent;
36 struct LongPressGestureEvent;
37
38 /**
39  * Long Press Gesture Event Processing:
40  *
41  * When we receive a long press gesture event, we do the following:
42  * - Find the actor that requires a long-press at the long press position.
43  * - Emit the gesture if the event satisfies the detector conditions.
44  */
45 class LongPressGestureProcessor : public GestureProcessor, public RecognizerObserver<LongPressGestureEvent>
46 {
47 public:
48
49   /**
50    * Create a long press gesture processor.
51    */
52   LongPressGestureProcessor();
53
54   /**
55    * Non-virtual destructor; LongPressGestureProcessor is not a base class
56    */
57   ~LongPressGestureProcessor();
58
59 public: // To be called by GestureEventProcessor
60
61   /**
62    * This method is called whenever a long press gesture event occurs.
63    * @param[in] scene The scene the long press gesture event occurs in.
64    * @param[in] longPressEvent The event that has occurred.
65    */
66   void Process( Scene& scene, const LongPressGestureEvent& longPressEvent );
67
68   /**
69    * Adds a gesture detector to this gesture processor.
70    * If this is the first gesture detector being added, then this method registers the required
71    * gesture with the adaptor.
72    * @param[in]  gestureDetector  The gesture detector being added.
73    * @param[in] scene The scene the long press gesture event occurs in.
74    */
75   void AddGestureDetector( LongPressGestureDetector* gestureDetector, Scene& scene );
76
77   /**
78    * Removes the specified gesture detector from this gesture processor.  If, after removing this
79    * gesture detector, there are no more gesture detectors registered, then this method unregisters
80    * the gesture from the adaptor.
81    * @param[in]  gestureDetector  The gesture detector being removed.
82    */
83   void RemoveGestureDetector( LongPressGestureDetector* gestureDetector );
84
85   /**
86    * This method updates the gesture detection parameters.
87    * @param[in]  gestureDetector  The gesture detector that has been updated.
88    */
89   void GestureDetectorUpdated(LongPressGestureDetector* gestureDetector);
90
91   /**
92    * @brief This method sets the minimum holding time required to be recognized as a long press gesture
93    *
94    * @param[in] value The time value in milliseconds
95    */
96   void SetMinimumHoldingTime( uint32_t time );
97
98   /**
99    * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
100    */
101   uint32_t GetMinimumHoldingTime() const;
102
103 private:
104
105   // Undefined
106   LongPressGestureProcessor( const LongPressGestureProcessor& );
107   LongPressGestureProcessor& operator=( const LongPressGestureProcessor& rhs );
108
109 private:
110
111   /**
112    * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
113    * its detection policy.  If it does, it sends the appropriate gesture update request to adaptor.
114    */
115   void UpdateDetection();
116
117   // GestureProcessor overrides
118
119   /**
120    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
121    */
122   void OnGesturedActorStageDisconnection();
123
124   /**
125    * @copydoc GestureProcessor::CheckGestureDetector()
126    */
127   bool CheckGestureDetector( GestureDetector* detector, Actor* actor );
128
129   /**
130    * @copydoc GestureProcessor::EmitGestureSignal()
131    */
132   void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates );
133
134 private:
135
136   LongPressGestureDetectorContainer mLongPressGestureDetectors;
137
138   GestureDetectorContainer mCurrentEmitters;
139   RenderTaskPtr mCurrentRenderTask;
140
141   uint32_t mMinTouchesRequired;
142   uint32_t mMaxTouchesRequired;
143
144   const LongPressGestureEvent* mCurrentLongPressEvent; ///< Pointer to current longPressEvent, used when calling ProcessAndEmit()
145
146   uint32_t mMinimumHoldingTime;
147 };
148
149 } // namespace Internal
150
151 } // namespace Dali
152
153 #endif // DALI_INTERNAL_LONG_PRESS_GESTURE_EVENT_PROCESSOR_H