2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 #include <dali/internal/event/events/tap-gesture-detector-impl.h>
21 #include <dali/public-api/events/tap-gesture.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/internal/event/events/gesture-event-processor.h>
36 return Dali::TapGestureDetector::New();
39 TypeRegistration mType( typeid(Dali::TapGestureDetector), typeid(Dali::GestureDetector), Create );
41 SignalConnectorType signalConnector1( mType, Dali::TapGestureDetector::SIGNAL_TAP_DETECTED, &TapGestureDetector::DoConnectSignal );
45 TapGestureDetectorPtr TapGestureDetector::New()
47 return new TapGestureDetector;
50 TapGestureDetectorPtr TapGestureDetector::New(unsigned int tapsRequired, unsigned int touchesRequired)
52 return new TapGestureDetector(tapsRequired, touchesRequired);
55 TapGestureDetector::TapGestureDetector()
56 : GestureDetector(Gesture::Tap),
62 TapGestureDetector::TapGestureDetector(unsigned int tapsRequired, unsigned int touchesRequired)
63 : GestureDetector(Gesture::Tap),
64 mTapsRequired(tapsRequired),
65 mTouchesRequired(touchesRequired)
69 TapGestureDetector::~TapGestureDetector()
73 void TapGestureDetector::SetTapsRequired(unsigned int taps)
75 DALI_ASSERT_ALWAYS(taps > 0 && "Can only set a positive number of taps" );
77 if (mTapsRequired != taps)
81 if (!mAttachedActors.empty())
83 mGestureEventProcessor.GestureDetectorUpdated(this);
88 void TapGestureDetector::SetTouchesRequired(unsigned int touches)
90 DALI_ASSERT_ALWAYS(touches > 0 && "Can only set a positive number of touches" );
92 if (mTouchesRequired != touches)
94 mTouchesRequired = touches;
96 if (!mAttachedActors.empty())
98 mGestureEventProcessor.GestureDetectorUpdated(this);
103 unsigned int TapGestureDetector::GetTapsRequired() const
105 return mTapsRequired;
108 unsigned int TapGestureDetector::GetTouchesRequired() const
110 return mTouchesRequired;
113 void TapGestureDetector::EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap)
115 // Guard against destruction during signal emission
116 Dali::TapGestureDetector handle( this );
118 mDetectedSignalV2.Emit( tappedActor, tap );
121 bool TapGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
123 bool connected( true );
124 TapGestureDetector* gesture = dynamic_cast<TapGestureDetector*>(object);
126 if ( Dali::TapGestureDetector::SIGNAL_TAP_DETECTED == signalName )
128 gesture->DetectedSignal().Connect( tracker, functor );
132 // signalName does not match any signal
139 void TapGestureDetector::OnActorAttach(Actor& actor)
144 void TapGestureDetector::OnActorDetach(Actor& actor)
149 void TapGestureDetector::OnActorDestroyed(Object& object)
154 } // namespace Internal