X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fanimation%2Flinear-constrainer-impl.cpp;h=8d174145ab5066961f80e3fd7b9fe2f3dfe6cb07;hb=cd0ce6e412df8961b1a5e28b496369fa49fd72d7;hp=3a793b7ba2987b6a7057d91b5247369d5f45a28e;hpb=87dd02c448ac263d947dca5bb0f2b08572b30f59;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/animation/linear-constrainer-impl.cpp b/dali/internal/event/animation/linear-constrainer-impl.cpp index 3a793b7..8d17414 100644 --- a/dali/internal/event/animation/linear-constrainer-impl.cpp +++ b/dali/internal/event/animation/linear-constrainer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ // INTERNAL INCLUDES #include #include +#include + namespace Dali { @@ -64,11 +66,11 @@ unsigned int LinearConstrainer::GetDefaultPropertyCount() const void LinearConstrainer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const { - indices.reserve( DEFAULT_PROPERTY_COUNT ); + indices.Reserve( DEFAULT_PROPERTY_COUNT ); - for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) + for ( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { - indices.push_back( i ); + indices.PushBack( i ); } } @@ -88,7 +90,7 @@ Property::Index LinearConstrainer::GetDefaultPropertyIndex(const std::string& na Property::Index index = Property::INVALID_INDEX; // Look for name in default properties - for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) + for( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; if( 0 == strcmp( name.c_str(), property->name ) ) @@ -113,55 +115,70 @@ Property::Type LinearConstrainer::GetDefaultPropertyType(Property::Index index) Property::Value LinearConstrainer::GetDefaultProperty( Property::Index index ) const { - Property::Value value; if( index == Dali::LinearConstrainer::Property::VALUE ) { - Property::Array propertyArray; - value = Property::Value(propertyArray); + Property::Value value( Property::ARRAY ); + Property::Array* array = value.GetArray(); size_t count( mValue.Size() ); - for( size_t i( 0 ); i != count; ++i ) + + if( array ) { - value.AppendItem( mValue[i] ); + array->Reserve( count ); + for( size_t i( 0 ); i != count; ++i ) + { + array->PushBack( mValue[i] ); + } } + return value; } else if( index == Dali::LinearConstrainer::Property::PROGRESS ) { - Property::Array propertyArray; - value = Property::Value(propertyArray); - size_t count( mValue.Size() ); - for( size_t i( 0 ); i != count; ++i ) + Property::Value value( Property::ARRAY ); + Property::Array* array = value.GetArray(); + size_t count( mProgress.Size() ); + + if( array ) { - value.AppendItem( mProgress[i] ); + array->Reserve( count ); + for( size_t i( 0 ); i != count; ++i ) + { + array->PushBack( mProgress[i] ); + } } + return value; } - return value; + return Property::Value(); } -void LinearConstrainer::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) +Property::Value LinearConstrainer::GetDefaultPropertyCurrentValue( Property::Index index ) const { - if( index == Dali::LinearConstrainer::Property::VALUE ) - { - Property::Array propertyArray; - propertyValue.Get(propertyArray); + return GetDefaultProperty( index ); // Event-side only properties +} - size_t propertyArrayCount = propertyArray.size(); - mValue.Resize( propertyArrayCount ); - for( size_t i(0); i!=propertyArrayCount; ++i ) +void LinearConstrainer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) +{ + const Property::Array* array = propertyValue.GetArray(); + if( array ) + { + size_t propertyArrayCount = array->Count(); + if( index == Dali::LinearConstrainer::Property::VALUE ) { - propertyArray[i].Get( mValue[i]); + mValue.Clear(); // remove old values + mValue.Resize( propertyArrayCount ); + for( size_t i(0); i != propertyArrayCount; ++i ) + { + array->GetElementAt( i ).Get( mValue[ i ] ); + } } - } - else if( index == Dali::LinearConstrainer::Property::PROGRESS ) - { - Property::Array propertyArray; - propertyValue.Get(propertyArray); - - size_t propertyArrayCount = propertyArray.size(); - mProgress.Resize( propertyArrayCount ); - for( size_t i(0); i!=propertyArrayCount; ++i ) + else if( index == Dali::LinearConstrainer::Property::PROGRESS ) { - propertyArray[i].Get( mProgress[i]); + mProgress.Clear(); // remove old values + mProgress.Resize( propertyArrayCount ); + for( size_t i(0); i != propertyArrayCount; ++i ) + { + array->GetElementAt( i ).Get( mProgress[ i ] ); + } } } } @@ -201,11 +218,10 @@ void LinearConstrainer::Apply( Property target, Property source, const Vector2& Dali::Constraint constraint = Dali::Constraint::New( target.object, target.propertyIndex, LinearConstraintFunctor( mValue, mProgress, range, wrap ) ); constraint.AddSource( Dali::Source(source.object, source.propertyIndex ) ); - constraint.SetTag( reinterpret_cast( this ) ); + constraint.SetTag( static_cast( reinterpret_cast( this ) ) ); // taking 32bits of this as tag constraint.SetRemoveAction( Dali::Constraint::Discard ); constraint.Apply(); - //Start observing the object Observe( target.object ); }