Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture / pinch-gesture-detector-impl.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <cstring> // for strcmp
23
24 // INTERNAL INCLUDES
25 #include <dali/integration-api/debug.h>
26 #include <dali/internal/event/events/gesture-event-processor.h>
27 #include <dali/public-api/events/pinch-gesture.h>
28 #include <dali/public-api/object/type-registry.h>
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace
35 {
36 // Signals
37
38 const char* const SIGNAL_PINCH_DETECTED = "pinchDetected";
39
40 BaseHandle Create()
41 {
42   return Dali::PinchGestureDetector::New();
43 }
44
45 TypeRegistration mType(typeid(Dali::PinchGestureDetector), typeid(Dali::GestureDetector), Create);
46
47 SignalConnectorType signalConnector1(mType, SIGNAL_PINCH_DETECTED, &PinchGestureDetector::DoConnectSignal);
48
49 } // namespace
50
51 PinchGestureDetectorPtr PinchGestureDetector::New()
52 {
53   return new PinchGestureDetector;
54 }
55
56 PinchGestureDetector::PinchGestureDetector()
57 : GestureDetector(GestureType::PINCH)
58 {
59 }
60
61 PinchGestureDetector::~PinchGestureDetector() = default;
62
63 void PinchGestureDetector::EmitPinchGestureSignal(Dali::Actor actor, const Dali::PinchGesture& pinch)
64 {
65   // Guard against destruction during signal emission
66   Dali::PinchGestureDetector handle(this);
67
68   mDetectedSignal.Emit(actor, pinch);
69 }
70
71 bool PinchGestureDetector::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
72 {
73   bool                  connected(true);
74   PinchGestureDetector* gesture = static_cast<PinchGestureDetector*>(object); // TypeRegistry guarantees that this is the correct type.
75
76   if(0 == strcmp(signalName.c_str(), SIGNAL_PINCH_DETECTED))
77   {
78     gesture->DetectedSignal().Connect(tracker, functor);
79   }
80   else
81   {
82     // signalName does not match any signal
83     connected = false;
84   }
85
86   return connected;
87 }
88
89 void PinchGestureDetector::OnActorAttach(Actor& actor)
90 {
91   // Do nothing
92 }
93
94 void PinchGestureDetector::OnActorDetach(Actor& actor)
95 {
96   // Do nothing
97 }
98
99 void PinchGestureDetector::OnActorDestroyed(Object& object)
100 {
101   // Do nothing
102 }
103
104 } // namespace Internal
105
106 } // namespace Dali