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/actor-gesture-data.h>
27 ActorGestureData::ActorGestureData()
28 : gesturesRequired( Gesture::Type( 0 ) ),
30 pinchDetectors( NULL ),
31 longPressDetectors( NULL ),
36 ActorGestureData::~ActorGestureData()
39 delete pinchDetectors;
40 delete longPressDetectors;
44 void ActorGestureData::AddGestureDetector( GestureDetector& detector )
46 const Gesture::Type type( detector.GetType() );
48 GestureDetectorContainer*& containerPtr( GetContainerPtr( type ) );
49 if ( NULL == containerPtr )
51 containerPtr = new GestureDetectorContainer;
53 containerPtr->push_back( &detector );
55 gesturesRequired = Gesture::Type( gesturesRequired | type );
58 void ActorGestureData::RemoveGestureDetector( GestureDetector& detector )
60 const Gesture::Type type( detector.GetType() );
62 GestureDetectorContainer*& containerPtr( GetContainerPtr( type ) );
63 DALI_ASSERT_DEBUG( containerPtr && "Container had not been created" );
65 GestureDetectorContainer& container( *containerPtr );
66 GestureDetectorContainer::iterator match( std::remove( container.begin(), container.end(), &detector ) );
67 DALI_ASSERT_DEBUG( match != container.end() && "Actor does not have the detector" );
68 container.erase( match, container.end() );
70 if ( container.empty() )
72 gesturesRequired = Gesture::Type( gesturesRequired & ~type );
78 GestureDetectorContainer& ActorGestureData::GetGestureDetectorContainer( Gesture::Type type )
80 return *GetContainerPtr( type );
83 GestureDetectorContainer*& ActorGestureData::GetContainerPtr( Gesture::Type type )
94 return pinchDetectors;
97 case Gesture::LongPress:
99 return longPressDetectors;
108 DALI_ASSERT_DEBUG( ! "Invalid Type" );
109 static GestureDetectorContainer* invalidType( NULL );
113 } // namespace Internal