X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali%2Finternal%2Fevent%2Fevents%2Fpan-gesture-detector-impl.cpp;h=77bb5bb22a9fe864a59ec906d00ac96752366042;hb=62a036e95cc8447bba0ef068948c8feb15de76b2;hp=3aa90ca0e350921d749970d9364e4f3f40863d3e;hpb=df59eea2434495c32414fcf9ffafe4cb7dff5324;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture-detector-impl.cpp index 3aa90ca..77bb5bb 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture-detector-impl.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -34,8 +35,11 @@ namespace Dali const Property::Index PanGestureDetector::SCREEN_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT; const Property::Index PanGestureDetector::SCREEN_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 1; -const Property::Index PanGestureDetector::LOCAL_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 2; -const Property::Index PanGestureDetector::LOCAL_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 3; +const Property::Index PanGestureDetector::SCREEN_VELOCITY = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 2; +const Property::Index PanGestureDetector::LOCAL_POSITION = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 3; +const Property::Index PanGestureDetector::LOCAL_DISPLACEMENT = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 4; +const Property::Index PanGestureDetector::LOCAL_VELOCITY = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 5; +const Property::Index PanGestureDetector::PANNING = Internal::DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT + 6; namespace Internal { @@ -45,22 +49,17 @@ namespace // Properties -const std::string DEFAULT_PROPERTY_NAMES[] = +PropertyDetails DEFAULT_PROPERTIES[] = { - "screen-position", - "screen-displacement", - "local-position", - "local-displacement", -}; -const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( std::string ); - -const Property::Type DEFAULT_PROPERTY_TYPES[DEFAULT_PROPERTY_COUNT] = -{ - Property::VECTOR2, // SCREEN_POSITION - Property::VECTOR2, // SCREEN_DISPLACEMENT - Property::VECTOR2, // LOCAL_POSITION - Property::VECTOR2, // LOCAL_DISPLACEMENT + { "screen-position", Property::VECTOR2, false, false, true }, + { "screen-displacement", Property::VECTOR2, false, false, true }, + { "screen-velocity", Property::VECTOR2, false, false, true }, + { "local-position", Property::VECTOR2, false, false, true }, + { "local-displacement", Property::VECTOR2, false, false, true }, + { "local-velocity", Property::VECTOR2, false, false, true }, + { "panning", Property::BOOLEAN, false, false, true }, }; +const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTIES ) / sizeof( DEFAULT_PROPERTIES[0] ); BaseHandle Create() { @@ -104,8 +103,6 @@ float GetOppositeAngle( float angle ) } // unnamed namespace -PanGestureDetector::DefaultPropertyLookup* PanGestureDetector::mDefaultPropertyLookup = NULL; - PanGestureDetectorPtr PanGestureDetector::New() { return new PanGestureDetector; @@ -117,15 +114,6 @@ PanGestureDetector::PanGestureDetector() mMaximumTouches(1), mSceneObject(NULL) { - if( !mDefaultPropertyLookup ) - { - mDefaultPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - ( *mDefaultPropertyLookup )[ DEFAULT_PROPERTY_NAMES[i] ] = i + start; - } - } } PanGestureDetector::~PanGestureDetector() @@ -336,11 +324,6 @@ void PanGestureDetector::OnActorDestroyed(Object& object) // Do nothing } -bool PanGestureDetector::IsSceneObjectRemovable() const -{ - return false; -} - unsigned int PanGestureDetector::GetDefaultPropertyCount() const { return DEFAULT_PROPERTY_COUNT; @@ -357,18 +340,16 @@ void PanGestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& in } } -const std::string& PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const +const char* PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const { index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT; if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) { - return DEFAULT_PROPERTY_NAMES[ index ]; + return DEFAULT_PROPERTIES[ index ].name; } else { - // Index out-of-range... return empty string. - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -376,15 +357,16 @@ Property::Index PanGestureDetector::GetDefaultPropertyIndex(const std::string& n { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultPropertyLookup ); - // Look for name in default properties - DefaultPropertyLookup::const_iterator result = mDefaultPropertyLookup->find( name ); - if ( mDefaultPropertyLookup->end() != result ) + for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { - index = result->second; + const Internal::PropertyDetails* property = &DEFAULT_PROPERTIES[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i; + break; + } } - return index; } @@ -411,7 +393,7 @@ Property::Type PanGestureDetector::GetDefaultPropertyType(Property::Index index) index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT; if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) { - return DEFAULT_PROPERTY_TYPES[ index ]; + return DEFAULT_PROPERTIES[ index ].type; } else { @@ -425,11 +407,6 @@ void PanGestureDetector::SetDefaultProperty( Property::Index index, const Proper // None of our properties should be settable from Public API } -void PanGestureDetector::SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value ) -{ - // None of our properties should be settable from Public API -} - Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) const { Property::Value value; @@ -462,6 +439,19 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co break; } + case Dali::PanGestureDetector::SCREEN_VELOCITY: + { + if(mSceneObject) + { + value = mSceneObject->GetScreenVelocityProperty().Get(); + } + else + { + value = Vector2(); + } + break; + } + case Dali::PanGestureDetector::LOCAL_POSITION: { if(mSceneObject) @@ -488,6 +478,32 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co break; } + case Dali::PanGestureDetector::LOCAL_VELOCITY: + { + if(mSceneObject) + { + value = mSceneObject->GetLocalVelocityProperty().Get(); + } + else + { + value = Vector2(); + } + break; + } + + case Dali::PanGestureDetector::PANNING: + { + if(mSceneObject) + { + value = mSceneObject->GetPanningProperty().Get(); + } + else + { + value = false; + } + break; + } + default: { DALI_ASSERT_ALWAYS(false && "PanGestureDetector Property index invalid" ); // should not come here @@ -498,12 +514,6 @@ Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) co return value; } -void PanGestureDetector::InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) -{ - // We do not want the user to install custom properties - DALI_ASSERT_ALWAYS(false && "PanGestureDetector does not allow custom properties" ); -} - const SceneGraph::PropertyOwner* PanGestureDetector::GetSceneObject() const { // This method should only return an object connected to the scene-graph @@ -530,11 +540,9 @@ const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Proper if ( index >= DEFAULT_PROPERTY_MAX_COUNT ) { - CustomPropertyLookup::const_iterator entry = GetCustomPropertyLookup().find( index ); - - DALI_ASSERT_ALWAYS( GetCustomPropertyLookup().end() != entry && "property index is invalid" ); - - property = entry->second.GetSceneGraphProperty(); + CustomProperty* custom = FindCustomProperty( index ); + DALI_ASSERT_ALWAYS( custom && "Property index is invalid" ); + property = custom->GetSceneGraphProperty(); } else { @@ -552,6 +560,12 @@ const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Proper break; } + case Dali::PanGestureDetector::SCREEN_VELOCITY: + { + property = &mSceneObject->GetScreenVelocityProperty(); + break; + } + case Dali::PanGestureDetector::LOCAL_POSITION: { property = &mSceneObject->GetLocalPositionProperty(); @@ -564,6 +578,18 @@ const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Proper break; } + case Dali::PanGestureDetector::LOCAL_VELOCITY: + { + property = &mSceneObject->GetLocalVelocityProperty(); + break; + } + + case Dali::PanGestureDetector::PANNING: + { + property = &mSceneObject->GetPanningProperty(); + break; + } + default: break; }