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