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