Add an environment variable for long press gesture
[platform/core/uifw/dali-core.git] / dali / internal / event / events / long-press-gesture / long-press-gesture-detector-impl.h
1 #ifndef DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_H
2 #define DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_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/public-api/events/long-press-gesture-detector.h>
23 #include <dali/internal/event/events/gesture-detector-impl.h>
24
25 namespace Dali
26 {
27
28 struct LongPressGesture;
29
30 namespace Internal
31 {
32
33 class LongPressGestureDetector;
34
35 typedef IntrusivePtr<LongPressGestureDetector> LongPressGestureDetectorPtr;
36 typedef DerivedGestureDetectorContainer<LongPressGestureDetector>::type LongPressGestureDetectorContainer;
37
38 /**
39  * @copydoc Dali::LongPressGestureDetector
40  */
41 class LongPressGestureDetector : public GestureDetector
42 {
43 public: // Creation
44
45   /**
46    * Create a new gesture detector.
47    * @return A smart-pointer to the newly allocated detector.
48    */
49   static LongPressGestureDetectorPtr New();
50
51   /**
52    * Create a new gesture detector with the specified touches.
53    * @param[in]  touchesRequired  The number of touches required.
54    * @return A smart-pointer to the newly allocated detector.
55    */
56   static LongPressGestureDetectorPtr New(unsigned int touchesRequired);
57
58   /**
59    * Create a new gesture detector with the specified minimum and maximum touches.
60    * @param[in]  minTouches  The minimum number of touches required.
61    * @param[in]  maxTouches  The maximum number of touches required.
62    * @return A smart-pointer to the newly allocated detector.
63    */
64   static LongPressGestureDetectorPtr New(unsigned int minTouches, unsigned int maxTouches);
65
66   /**
67    * Construct a new GestureDetector.
68    */
69   LongPressGestureDetector();
70
71   /**
72    * Create a new gesture detector with the specified minimum and maximum touches.
73    * @param[in]  minTouches  The minimum number of touches required.
74    * @param[in]  maxTouches  The maximum number of touches required.
75    */
76   LongPressGestureDetector(unsigned int minTouches, unsigned int maxTouches);
77
78 public:
79
80   /**
81    * @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int)
82    */
83   void SetTouchesRequired(unsigned int touches);
84
85   /**
86    * @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int, unsigned int)
87    */
88   void SetTouchesRequired(unsigned int minTouches, unsigned int maxTouches);
89
90   /**
91    * @copydoc Dali::LongPressGestureDetector::GetMinimumTouchesRequired()
92    */
93   unsigned int GetMinimumTouchesRequired() const;
94
95   /**
96    * @copydoc Dali::LongPressGestureDetector::GetMaximumTouchesRequired()
97    */
98   unsigned int GetMaximumTouchesRequired() const;
99
100   /**
101    * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
102    */
103   uint32_t GetMinimumHoldingTime() const;
104
105 public:
106
107   /**
108    * Called by the LongPressGestureProcessor when a tap gesture event occurs within the bounds of our
109    * attached actor.
110    * @param[in]  pressedActor  The pressed actor.
111    * @param[in]  longPress     The long press
112    */
113   void EmitLongPressGestureSignal(Dali::Actor pressedActor, const LongPressGesture& longPress);
114
115 public: // Signals
116
117   /**
118    * @copydoc Dali::LongPressGestureDetector::DetectedSignal()
119    */
120   Dali::LongPressGestureDetector::DetectedSignalType& DetectedSignal()
121   {
122     return mDetectedSignal;
123   }
124
125   /**
126    * Connects a callback function with the object's signals.
127    * @param[in] object The object providing the signal.
128    * @param[in] tracker Used to disconnect the signal.
129    * @param[in] signalName The signal to connect to.
130    * @param[in] functor A newly allocated FunctorDelegate.
131    * @return True if the signal was connected.
132    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
133    */
134   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
135
136 protected:
137
138   /**
139    * A reference counted object may only be deleted by calling Unreference()
140    */
141   virtual ~LongPressGestureDetector();
142
143 private:
144
145   // Undefined
146   LongPressGestureDetector(const LongPressGestureDetector&);
147   LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
148
149 private: // GestureDetector overrides
150
151   /**
152    * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
153    */
154   virtual void OnActorAttach(Actor& actor);
155
156   /**
157    * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
158    */
159   virtual void OnActorDetach(Actor& actor);
160
161   /**
162    * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
163    */
164   virtual void OnActorDestroyed(Object& object);
165
166 private:
167
168   Dali::LongPressGestureDetector::DetectedSignalType mDetectedSignal;
169
170   unsigned int mMinimumTouchesRequired;
171   unsigned int mMaximumTouchesRequired;
172 };
173
174 } // namespace Internal
175
176 // Helpers for public-api forwarding methods
177
178 inline Internal::LongPressGestureDetector& GetImplementation(Dali::LongPressGestureDetector& detector)
179 {
180   DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
181
182   BaseObject& handle = detector.GetBaseObject();
183
184   return static_cast<Internal::LongPressGestureDetector&>(handle);
185 }
186
187 inline const Internal::LongPressGestureDetector& GetImplementation(const Dali::LongPressGestureDetector& detector)
188 {
189   DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
190
191   const BaseObject& handle = detector.GetBaseObject();
192
193   return static_cast<const Internal::LongPressGestureDetector&>(handle);
194 }
195
196 } // namespace Dali
197
198 #endif // DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_H