[dali_1.0.32] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture-detector-impl.h
1 #ifndef __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_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/events/pinch-gesture-detector.h>
23 #include <dali/internal/event/events/gesture-detector-impl.h>
24
25 namespace Dali
26 {
27
28 struct PinchGesture;
29
30 namespace Internal
31 {
32
33 class PinchGestureDetector;
34
35 typedef IntrusivePtr<PinchGestureDetector> PinchGestureDetectorPtr;
36 typedef DerivedGestureDetectorContainer<PinchGestureDetector>::type PinchGestureDetectorContainer;
37
38 /**
39  * @copydoc Dali::PinchGestureDetector
40  */
41 class PinchGestureDetector : 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 PinchGestureDetectorPtr New();
50
51   /**
52    * Construct a new GestureDetector.
53    */
54   PinchGestureDetector();
55
56 public:
57
58   /**
59    * Called by the PinchGestureProcessor when a pinch gesture event occurs within the bounds of our
60    * attached actor.
61    * @param[in]  actor  The pinched actor.
62    * @param[in]  pinch  The pinch gesture.
63    */
64   void EmitPinchGestureSignal(Dali::Actor actor, const PinchGesture& pinch);
65
66 public: // Signals
67
68   /**
69    * @copydoc Dali::PinchGestureDetector::DetectedSignal()
70    */
71   Dali::PinchGestureDetector::DetectedSignalType& DetectedSignal()
72   {
73     return mDetectedSignal;
74   }
75
76   /**
77    * Connects a callback function with the object's signals.
78    * @param[in] object The object providing the signal.
79    * @param[in] tracker Used to disconnect the signal.
80    * @param[in] signalName The signal to connect to.
81    * @param[in] functor A newly allocated FunctorDelegate.
82    * @return True if the signal was connected.
83    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
84    */
85   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
86
87 protected:
88
89   /**
90    * A reference counted object may only be deleted by calling Unreference()
91    */
92   virtual ~PinchGestureDetector();
93
94 private:
95
96   // Undefined
97   PinchGestureDetector(const PinchGestureDetector&);
98   PinchGestureDetector& operator=(const PinchGestureDetector& rhs);
99
100 private: // GestureDetector overrides
101
102   /**
103    * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
104    */
105   virtual void OnActorAttach(Actor& actor);
106
107   /**
108    * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
109    */
110   virtual void OnActorDetach(Actor& actor);
111
112   /**
113    * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
114    */
115   virtual void OnActorDestroyed(Object& object);
116
117 private:
118
119   Dali::PinchGestureDetector::DetectedSignalType mDetectedSignal;
120 };
121
122 } // namespace Internal
123
124 // Helpers for public-api forwarding methods
125
126 inline Internal::PinchGestureDetector& GetImplementation(Dali::PinchGestureDetector& detector)
127 {
128   DALI_ASSERT_ALWAYS( detector && "PinchGestureDetector handle is empty" );
129
130   BaseObject& handle = detector.GetBaseObject();
131
132   return static_cast<Internal::PinchGestureDetector&>(handle);
133 }
134
135 inline const Internal::PinchGestureDetector& GetImplementation(const Dali::PinchGestureDetector& detector)
136 {
137   DALI_ASSERT_ALWAYS( detector && "PinchGestureDetector handle is empty" );
138
139   const BaseObject& handle = detector.GetBaseObject();
140
141   return static_cast<const Internal::PinchGestureDetector&>(handle);
142 }
143
144 } // namespace Dali
145
146 #endif // __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__