1 #ifndef __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/events/long-press-gesture-detector.h>
23 #include <dali/internal/event/events/gesture-detector-impl.h>
28 struct LongPressGesture;
33 class LongPressGestureDetector;
35 typedef IntrusivePtr<LongPressGestureDetector> LongPressGestureDetectorPtr;
36 typedef DerivedGestureDetectorContainer<LongPressGestureDetector>::type LongPressGestureDetectorContainer;
39 * @copydoc Dali::LongPressGestureDetector
41 class LongPressGestureDetector : public GestureDetector
46 * Create a new gesture detector.
47 * @return A smart-pointer to the newly allocated detector.
49 static LongPressGestureDetectorPtr New();
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.
56 static LongPressGestureDetectorPtr New(unsigned int touchesRequired);
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.
64 static LongPressGestureDetectorPtr New(unsigned int minTouches, unsigned int maxTouches);
67 * Construct a new GestureDetector.
69 LongPressGestureDetector();
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.
76 LongPressGestureDetector(unsigned int minTouches, unsigned int maxTouches);
81 * @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int)
83 void SetTouchesRequired(unsigned int touches);
86 * @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int, unsigned int)
88 void SetTouchesRequired(unsigned int minTouches, unsigned int maxTouches);
91 * @copydoc Dali::LongPressGestureDetector::GetMinimumTouchesRequired()
93 unsigned int GetMinimumTouchesRequired() const;
96 * @copydoc Dali::LongPressGestureDetector::GetMaximumTouchesRequired()
98 unsigned int GetMaximumTouchesRequired() const;
103 * Called by the LongPressGestureProcessor when a tap gesture event occurs within the bounds of our
105 * @param[in] pressedActor The pressed actor.
106 * @param[in] longPress The long press
108 void EmitLongPressGestureSignal(Dali::Actor pressedActor, const LongPressGesture& longPress);
113 * @copydoc Dali::LongPressGestureDetector::DetectedSignal()
115 Dali::LongPressGestureDetector::DetectedSignalType& DetectedSignal()
117 return mDetectedSignal;
121 * Connects a callback function with the object's signals.
122 * @param[in] object The object providing the signal.
123 * @param[in] tracker Used to disconnect the signal.
124 * @param[in] signalName The signal to connect to.
125 * @param[in] functor A newly allocated FunctorDelegate.
126 * @return True if the signal was connected.
127 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
129 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
134 * A reference counted object may only be deleted by calling Unreference()
136 virtual ~LongPressGestureDetector();
141 LongPressGestureDetector(const LongPressGestureDetector&);
142 LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
144 private: // GestureDetector overrides
147 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
149 virtual void OnActorAttach(Actor& actor);
152 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
154 virtual void OnActorDetach(Actor& actor);
157 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
159 virtual void OnActorDestroyed(Object& object);
163 Dali::LongPressGestureDetector::DetectedSignalType mDetectedSignal;
165 unsigned int mMinimumTouchesRequired;
166 unsigned int mMaximumTouchesRequired;
169 } // namespace Internal
171 // Helpers for public-api forwarding methods
173 inline Internal::LongPressGestureDetector& GetImplementation(Dali::LongPressGestureDetector& detector)
175 DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
177 BaseObject& handle = detector.GetBaseObject();
179 return static_cast<Internal::LongPressGestureDetector&>(handle);
182 inline const Internal::LongPressGestureDetector& GetImplementation(const Dali::LongPressGestureDetector& detector)
184 DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
186 const BaseObject& handle = detector.GetBaseObject();
188 return static_cast<const Internal::LongPressGestureDetector&>(handle);
193 #endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__