2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/events/tap-gesture-detector-impl.h>
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>
37 return Dali::TapGestureDetector::New();
40 TypeRegistration mType( typeid(Dali::TapGestureDetector), typeid(Dali::GestureDetector), Create );
42 SignalConnectorType signalConnector1( mType, Dali::TapGestureDetector::SIGNAL_TAP_DETECTED, &TapGestureDetector::DoConnectSignal );
46 TapGestureDetectorPtr TapGestureDetector::New()
48 return new TapGestureDetector;
51 TapGestureDetectorPtr TapGestureDetector::New(unsigned int tapsRequired, unsigned int touchesRequired)
53 return new TapGestureDetector(tapsRequired, touchesRequired);
56 TapGestureDetector::TapGestureDetector()
57 : GestureDetector(Gesture::Tap),
63 TapGestureDetector::TapGestureDetector(unsigned int tapsRequired, unsigned int touchesRequired)
64 : GestureDetector(Gesture::Tap),
65 mTapsRequired(tapsRequired),
66 mTouchesRequired(touchesRequired)
70 TapGestureDetector::~TapGestureDetector()
74 void TapGestureDetector::SetTapsRequired(unsigned int taps)
76 DALI_ASSERT_ALWAYS(taps > 0 && "Can only set a positive number of taps" );
78 if (mTapsRequired != taps)
82 if (!mAttachedActors.empty())
84 mGestureEventProcessor.GestureDetectorUpdated(this);
89 void TapGestureDetector::SetTouchesRequired(unsigned int touches)
91 DALI_ASSERT_ALWAYS(touches > 0 && "Can only set a positive number of touches" );
93 if (mTouchesRequired != touches)
95 mTouchesRequired = touches;
97 if (!mAttachedActors.empty())
99 mGestureEventProcessor.GestureDetectorUpdated(this);
104 unsigned int TapGestureDetector::GetTapsRequired() const
106 return mTapsRequired;
109 unsigned int TapGestureDetector::GetTouchesRequired() const
111 return mTouchesRequired;
114 void TapGestureDetector::EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap)
116 // Guard against destruction during signal emission
117 Dali::TapGestureDetector handle( this );
119 mDetectedSignal.Emit( tappedActor, tap );
122 bool TapGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
124 bool connected( true );
125 TapGestureDetector* gesture = dynamic_cast<TapGestureDetector*>(object);
127 if ( Dali::TapGestureDetector::SIGNAL_TAP_DETECTED == signalName )
129 gesture->DetectedSignal().Connect( tracker, functor );
133 // signalName does not match any signal
140 void TapGestureDetector::OnActorAttach(Actor& actor)
145 void TapGestureDetector::OnActorDetach(Actor& actor)
150 void TapGestureDetector::OnActorDestroyed(Object& object)
155 } // namespace Internal