Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / path-impl.cpp
index 9722198..c891349 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.
@@ -22,9 +22,9 @@
 #include <cstring> // for strcmp
 
 // INTERNAL INCLUDES
-#include <dali/internal/event/common/property-helper.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 +41,7 @@ namespace
 DALI_PROPERTY_TABLE_BEGIN
 DALI_PROPERTY( "points",         ARRAY, true, false, false,   Dali::Path::Property::POINTS         )
 DALI_PROPERTY( "controlPoints",  ARRAY, true, false, false,   Dali::Path::Property::CONTROL_POINTS )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
+DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, PathDefaultProperties )
 
 /**
  * These coefficient arise from the cubic polynomial equations for
@@ -67,7 +67,7 @@ Dali::BaseHandle Create()
   return Dali::Path::New();
 }
 
-Dali::TypeRegistration mType( typeid(Dali::Path), typeid(Dali::Handle), Create );
+TypeRegistration mType( typeid(Dali::Path), typeid(Dali::Handle), Create, PathDefaultProperties );
 
 inline bool PathIsComplete(const Dali::Vector<Vector3>& point, const Dali::Vector<Vector3>& controlPoint)
 {
@@ -82,13 +82,11 @@ Path* Path::New()
 }
 
 Path::Path()
-: Object()
+: Object( nullptr ) // we don't have our own scene object
 {
 }
 
-Path::~Path()
-{
-}
+Path::~Path() = default;
 
 Path* Path::Clone(const Path& path)
 {
@@ -99,60 +97,6 @@ Path* Path::Clone(const Path& path)
   return clone;
 }
 
-unsigned int Path::GetDefaultPropertyCount() const
-{
-  return DEFAULT_PROPERTY_COUNT;
-}
-
-void Path::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
-  indices.Reserve( DEFAULT_PROPERTY_COUNT );
-
-  for ( Property::Index i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
-  {
-    indices.PushBack( i );
-  }
-}
-
-const char* Path::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 Path::GetDefaultPropertyIndex(const std::string& name) const
-{
-  Property::Index index = Property::INVALID_INDEX;
-
-  // Look for name in default properties
-  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 ) ) // dont want to convert rhs to string
-    {
-      index = i;
-      break;
-    }
-  }
-  return index;
-}
-
-Property::Type Path::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 Path::GetDefaultProperty( Property::Index index ) const
 {
   if( index == Dali::Path::Property::POINTS )
@@ -191,11 +135,6 @@ Property::Value Path::GetDefaultProperty( Property::Index index ) const
   return Property::Value();
 }
 
-Property::Value Path::GetDefaultPropertyCurrentValue( Property::Index index ) const
-{
-  return GetDefaultProperty( index ); // Event-side only properties
-}
-
 void Path::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
 {
   const Property::Array* array = propertyValue.GetArray();
@@ -225,36 +164,6 @@ void Path::SetDefaultProperty(Property::Index index, const Property::Value& prop
   }
 }
 
-bool Path::IsDefaultPropertyWritable(Property::Index index) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].writable;
-  }
-
-  return false;
-}
-
-bool Path::IsDefaultPropertyAnimatable(Property::Index index) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].animatable;
-  }
-
-  return false;
-}
-
-bool Path::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
-  if( index < DEFAULT_PROPERTY_COUNT )
-  {
-    return DEFAULT_PROPERTY_DETAILS[index].constraintInput;
-  }
-
-  return false;
-}
-
 void Path::AddPoint(const Vector3& point )
 {
   mPoint.PushBack( point );
@@ -265,20 +174,20 @@ void Path::AddControlPoint(const Vector3& point )
   mControlPoint.PushBack( point );
 }
 
-unsigned int Path::GetNumberOfSegments() const
+uint32_t Path::GetNumberOfSegments() const
 {
-  return static_cast<unsigned int>( (mPoint.Size()>1) ? mPoint.Size()-1 : 0 );
+  return static_cast<uint32_t>( (mPoint.Size()>1) ? mPoint.Size()-1 : 0 );
 }
 
 void Path::GenerateControlPoints( float curvature )
 {
-  unsigned int numSegments = GetNumberOfSegments();
+  uint32_t numSegments = GetNumberOfSegments();
   DALI_ASSERT_ALWAYS( numSegments > 0 && "Need at least 1 segment to generate control points" ); // need at least 1 segment
 
   mControlPoint.Resize( numSegments * 2);
 
   //Generate two control points for each segment
-  for( unsigned int i(0); i<numSegments; ++i )
+  for( uint32_t i(0); i<numSegments; ++i )
   {
     //Segment end-points
     Vector3 p1 = mPoint[i];
@@ -329,10 +238,10 @@ void Path::GenerateControlPoints( float curvature )
   }
 }
 
-void Path::FindSegmentAndProgress( float t, unsigned int& segment, float& tLocal ) const
+void Path::FindSegmentAndProgress( float t, uint32_t& segment, float& tLocal ) const
 {
   //Find segment and local progress
-  unsigned int numSegs = GetNumberOfSegments();
+  uint32_t numSegs = GetNumberOfSegments();
 
   if( t <= 0.0f || numSegs == 0 )
   {
@@ -346,7 +255,7 @@ void Path::FindSegmentAndProgress( float t, unsigned int& segment, float& tLocal
   }
   else
   {
-    segment = static_cast<unsigned int>( t * static_cast<float>( numSegs ) );
+    segment = static_cast<uint32_t>( t * static_cast<float>( numSegs ) );
     float segLength = 1.0f / static_cast<float>( numSegs );
     float segStart  = static_cast<float>( segment ) * segLength;
     tLocal = (t - segStart) * static_cast<float>( numSegs );
@@ -367,7 +276,7 @@ bool Path::SampleAt( float t, Vector3& position, Vector3& tangent ) const
 
   if( PathIsComplete(mPoint, mControlPoint) )
   {
-    unsigned int segment;
+    uint32_t segment;
     float tLocal;
     FindSegmentAndProgress( t, segment, tLocal );
 
@@ -436,7 +345,7 @@ bool Path::SamplePosition( float t, Vector3& position ) const
 
   if( PathIsComplete(mPoint, mControlPoint) )
   {
-    unsigned int segment;
+    uint32_t segment;
     float tLocal;
     FindSegmentAndProgress( t, segment, tLocal );
 
@@ -488,7 +397,7 @@ bool Path::SampleTangent( float t, Vector3& tangent ) const
 
   if( PathIsComplete(mPoint, mControlPoint) )
   {
-    unsigned int segment;
+    uint32_t segment;
     float tLocal;
     FindSegmentAndProgress( t, segment, tLocal );
 
@@ -535,23 +444,23 @@ bool Path::SampleTangent( float t, Vector3& tangent ) const
   return done;
 }
 
-Vector3& Path::GetPoint( size_t index )
+Vector3& Path::GetPoint( uint32_t index )
 {
   DALI_ASSERT_ALWAYS( index < mPoint.Size() && "Path: Point index out of bounds" );
 
   return mPoint[index];
 }
 
-Vector3& Path::GetControlPoint( size_t index )
+Vector3& Path::GetControlPoint( uint32_t index )
 {
   DALI_ASSERT_ALWAYS( index < mControlPoint.Size() && "Path: Control Point index out of bounds" );
 
   return mControlPoint[index];
 }
 
-size_t Path::GetPointCount() const
+uint32_t Path::GetPointCount() const
 {
-  return mPoint.Size();
+  return static_cast<uint32_t>( mPoint.Size() );
 }
 
 void Path::ClearPoints()