Renaming of enum values for coding standards compliance.
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / linear-constrainer-impl.cpp
index 41f6248..c357e41 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
 #include <cstring> // for strcmp
 
 // 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>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/internal/event/common/property-helper.h>
 
 
 namespace Dali
@@ -41,7 +42,14 @@ namespace
 DALI_PROPERTY_TABLE_BEGIN
 DALI_PROPERTY( "value",        ARRAY,     true,    false,       false,        Dali::LinearConstrainer::Property::VALUE )
 DALI_PROPERTY( "progress",     ARRAY,     true,    false,       false,        Dali::LinearConstrainer::Property::PROGRESS )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
+DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, LinearConstrainerDefaultProperties )
+
+BaseHandle Create()
+{
+  return Dali::LinearConstrainer::New();
+}
+
+TypeRegistration mType( typeid( Dali::LinearConstrainer ), typeid( Dali::Handle ), Create, LinearConstrainerDefaultProperties );
 
 } //Unnamed namespace
 
@@ -59,72 +67,18 @@ LinearConstrainer::~LinearConstrainer()
 {
 }
 
-unsigned int LinearConstrainer::GetDefaultPropertyCount() const
-{
-  return DEFAULT_PROPERTY_COUNT;
-}
-
-void LinearConstrainer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
-  indices.Reserve( DEFAULT_PROPERTY_COUNT );
-
-  for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
-  {
-    indices.PushBack( i );
-  }
-}
-
-const char* LinearConstrainer::GetDefaultPropertyName(Property::Index index) const
-{
-  if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].name;
-  }
-
-  // index out of range
-  return NULL;
-}
-
-Property::Index LinearConstrainer::GetDefaultPropertyIndex(const std::string& name) const
-{
-  Property::Index index = Property::INVALID_INDEX;
-
-  // Look for name in default properties
-  for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
-  {
-    const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
-    if( 0 == strcmp( name.c_str(), property->name ) )
-    {
-      index = i;
-      break;
-    }
-  }
-  return index;
-}
-
-Property::Type LinearConstrainer::GetDefaultPropertyType(Property::Index index) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].type;
-  }
-
-  // index out of range
-  return Property::NONE;
-}
-
 Property::Value LinearConstrainer::GetDefaultProperty( Property::Index index ) const
 {
   if( index == Dali::LinearConstrainer::Property::VALUE )
   {
     Property::Value value( Property::ARRAY );
     Property::Array* array = value.GetArray();
-    size_t count( mValue.Size() );
+    uint32_t count = static_cast<uint32_t>( mValue.Size() );
 
     if( array )
     {
       array->Reserve( count );
-      for( size_t i( 0 ); i != count; ++i )
+      for( uint32_t i( 0 ); i != count; ++i )
       {
         array->PushBack( mValue[i] );
       }
@@ -135,12 +89,12 @@ Property::Value LinearConstrainer::GetDefaultProperty( Property::Index index ) c
   {
     Property::Value value( Property::ARRAY );
     Property::Array* array = value.GetArray();
-    size_t count( mProgress.Size() );
+    uint32_t count = static_cast<uint32_t>( mProgress.Size() );
 
     if( array )
     {
       array->Reserve( count );
-      for( size_t i( 0 ); i != count; ++i )
+      for( uint32_t i( 0 ); i != count; ++i )
       {
         array->PushBack( mProgress[i] );
       }
@@ -161,12 +115,12 @@ void LinearConstrainer::SetDefaultProperty( Property::Index index, const Propert
   const Property::Array* array = propertyValue.GetArray();
   if( array )
   {
-    size_t propertyArrayCount = array->Count();
+    uint32_t propertyArrayCount = static_cast<uint32_t>( array->Count() );
     if( index == Dali::LinearConstrainer::Property::VALUE  )
     {
       mValue.Clear(); // remove old values
       mValue.Resize( propertyArrayCount );
-      for( size_t i(0); i != propertyArrayCount; ++i )
+      for( uint32_t i(0); i != propertyArrayCount; ++i )
       {
         array->GetElementAt( i ).Get( mValue[ i ] );
       }
@@ -175,7 +129,7 @@ void LinearConstrainer::SetDefaultProperty( Property::Index index, const Propert
     {
       mProgress.Clear(); // remove old values
       mProgress.Resize( propertyArrayCount );
-      for( size_t i(0); i != propertyArrayCount; ++i )
+      for( uint32_t i(0); i != propertyArrayCount; ++i )
       {
         array->GetElementAt( i ).Get( mProgress[ i ] );
       }
@@ -183,46 +137,15 @@ void LinearConstrainer::SetDefaultProperty( Property::Index index, const Propert
   }
 }
 
-bool LinearConstrainer::IsDefaultPropertyWritable(Property::Index index) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].writable;
-  }
-
-  return false;
-}
-
-bool LinearConstrainer::IsDefaultPropertyAnimatable(Property::Index index) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].animatable;
-  }
-
-  return false;
-}
-
-bool LinearConstrainer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].constraintInput;
-  }
-
-  return false;
-}
-
 void LinearConstrainer::Apply( Property target, Property source, const Vector2& range, const Vector2& wrap)
 {
   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.SetRemoveAction( Dali::Constraint::Discard );
+  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 );
 }