remove (unnecessarily) exported signal and action names
[platform/core/uifw/dali-core.git] / dali / internal / event / events / tap-gesture-detector-impl.cpp
1 /*
2  * Copyright (c) 2014 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/tap-gesture-detector-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/events/tap-gesture.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/internal/event/events/gesture-event-processor.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace
34 {
35
36 // Signals
37 const char* const SIGNAL_TAP_DETECTED = "tap-detected";
38
39 BaseHandle Create()
40 {
41   return Dali::TapGestureDetector::New();
42 }
43
44 TypeRegistration mType( typeid(Dali::TapGestureDetector), typeid(Dali::GestureDetector), Create );
45
46 SignalConnectorType signalConnector1( mType, SIGNAL_TAP_DETECTED, &TapGestureDetector::DoConnectSignal );
47
48 }
49
50 TapGestureDetectorPtr TapGestureDetector::New()
51 {
52   return new TapGestureDetector;
53 }
54
55 TapGestureDetectorPtr TapGestureDetector::New(unsigned int tapsRequired, unsigned int touchesRequired)
56 {
57   return new TapGestureDetector(tapsRequired, touchesRequired);
58 }
59
60 TapGestureDetector::TapGestureDetector()
61 : GestureDetector(Gesture::Tap),
62   mTapsRequired(1),
63   mTouchesRequired(1)
64 {
65 }
66
67 TapGestureDetector::TapGestureDetector(unsigned int tapsRequired, unsigned int touchesRequired)
68 : GestureDetector(Gesture::Tap),
69   mTapsRequired(tapsRequired),
70   mTouchesRequired(touchesRequired)
71 {
72 }
73
74 TapGestureDetector::~TapGestureDetector()
75 {
76 }
77
78 void TapGestureDetector::SetTapsRequired(unsigned int taps)
79 {
80   DALI_ASSERT_ALWAYS(taps > 0 && "Can only set a positive number of taps" );
81
82   if (mTapsRequired != taps)
83   {
84     mTapsRequired = taps;
85
86     if (!mAttachedActors.empty())
87     {
88       mGestureEventProcessor.GestureDetectorUpdated(this);
89     }
90   }
91 }
92
93 void TapGestureDetector::SetTouchesRequired(unsigned int touches)
94 {
95   DALI_ASSERT_ALWAYS(touches > 0 && "Can only set a positive number of touches" );
96
97   if (mTouchesRequired != touches)
98   {
99     mTouchesRequired = touches;
100
101     if (!mAttachedActors.empty())
102     {
103       mGestureEventProcessor.GestureDetectorUpdated(this);
104     }
105   }
106 }
107
108 unsigned int TapGestureDetector::GetTapsRequired() const
109 {
110   return mTapsRequired;
111 }
112
113 unsigned int TapGestureDetector::GetTouchesRequired() const
114 {
115   return mTouchesRequired;
116 }
117
118 void TapGestureDetector::EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap)
119 {
120   // Guard against destruction during signal emission
121   Dali::TapGestureDetector handle( this );
122
123   mDetectedSignal.Emit( tappedActor, tap );
124 }
125
126 bool TapGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
127 {
128   bool connected( true );
129   TapGestureDetector* gesture = dynamic_cast<TapGestureDetector*>(object);
130
131   if ( 0 == strcmp( signalName.c_str(), SIGNAL_TAP_DETECTED ) )
132   {
133     gesture->DetectedSignal().Connect( tracker, functor );
134   }
135   else
136   {
137     // signalName does not match any signal
138     connected = false;
139   }
140
141   return connected;
142 }
143
144 void TapGestureDetector::OnActorAttach(Actor& actor)
145 {
146   // Do nothing
147 }
148
149 void TapGestureDetector::OnActorDetach(Actor& actor)
150 {
151   // Do nothing
152 }
153
154 void TapGestureDetector::OnActorDestroyed(Object& object)
155 {
156   // Do nothing
157 }
158
159 } // namespace Internal
160
161 } // namespace Dali