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