/*
- * 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.
// INTERNAL INCLUDES
#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/object/property-array.h>
+
namespace Dali
{
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 );
}
}
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 ) )
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 ] );
+ }
}
}
}
Dali::Constraint constraint = Dali::Constraint::New<float>( target.object, target.propertyIndex, LinearConstraintFunctor( mValue, mProgress, range, wrap ) );
constraint.AddSource( Dali::Source(source.object, source.propertyIndex ) );
- constraint.SetTag( reinterpret_cast<size_t>( this ) );
+ constraint.SetTag( static_cast<uint32_t>( reinterpret_cast<uintptr_t>( this ) ) ); // taking 32bits of this as tag
constraint.SetRemoveAction( Dali::Constraint::Discard );
constraint.Apply();
-
//Start observing the object
Observe( target.object );
}