utc-Dali-PinchGestureDetector.cpp
utc-Dali-Pixel.cpp
utc-Dali-PropertyMap.cpp
+ utc-Dali-PropertyArray.cpp
utc-Dali-PropertyNotification.cpp
utc-Dali-PropertyValue.cpp
utc-Dali-Quaternion.cpp
PathConstrainer.SetProperty( Dali::PathConstrainer::Property::FORWARD, Vector3(1.0f,0.0f,0.0f) );
Dali::Property::Array points;
- points.resize(3);
+ points.Resize(3);
points[0] = Vector3( 30.0, 80.0, 0.0);
points[1] = Vector3( 70.0, 120.0, 0.0);
points[2] = Vector3(100.0, 100.0, 0.0);
PathConstrainer.SetProperty( Dali::PathConstrainer::Property::POINTS, points );
- points.resize(4);
+ points.Resize(4);
points[0] = Vector3( 39.0, 90.0, 0.0);
points[1] = Vector3( 56.0, 119.0, 0.0);
points[2] = Vector3( 78.0, 120.0, 0.0);
static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
{
Dali::Property::Array points;
- points.resize(3);
+ points.Resize(3);
points[0] = 0.0f;
points[1] = 1.0f;
points[2] = 0.0f;
static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer)
{
Dali::Property::Array points;
- points.resize(3);
+ points.Resize(3);
points[0] = 0.0f;
points[1] = 1.0f;
points[2] = 0.0f;
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+void utc_dali_property_array_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_property_array_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliPropertyArrayPushBackP(void)
+{
+ Property::Array array;
+
+ DALI_TEST_CHECK( 0 == array.Size() );
+
+ array.PushBack( 1 );
+
+ DALI_TEST_CHECK( 1 == array.Size() );
+
+ DALI_TEST_CHECK( array[0].Get<int>() == 1 );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayCapacityP(void)
+{
+ Property::Array array;
+ DALI_TEST_CHECK( array.Empty() );
+
+ array.Reserve(3);
+
+ DALI_TEST_CHECK( 3 == array.Capacity() );
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayReserveP(void)
+{
+ Property::Array array;
+ DALI_TEST_CHECK( array.Empty() );
+
+ array.Reserve(3);
+
+ DALI_TEST_CHECK( 3 == array.Capacity() );
+ DALI_TEST_CHECK( 0 == array.Size() );
+
+ array.PushBack( 1 );
+ array.PushBack( "world" );
+ array.PushBack( 3 );
+ END_TEST;
+}
+
+int UtcDaliPropertyArraySizeP(void)
+{
+ Property::Array array;
+ DALI_TEST_CHECK( 0 == array.Capacity() );
+ DALI_TEST_CHECK( 0 == array.Size() );
+
+ array.Reserve(3);
+
+ DALI_TEST_CHECK( 3 == array.Capacity() );
+ DALI_TEST_CHECK( 0 == array.Size() );
+
+ array.PushBack( 1 );
+ array.PushBack( "world" );
+ array.PushBack( 3 );
+
+ DALI_TEST_CHECK( 3 == array.Size() );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayCountP(void)
+{
+ Property::Array array;
+ DALI_TEST_CHECK( 0 == array.Capacity() );
+ DALI_TEST_CHECK( 0 == array.Count() );
+
+ array.Reserve(3);
+
+ DALI_TEST_CHECK( 3 == array.Capacity() );
+ DALI_TEST_CHECK( 0 == array.Count() );
+
+ array.PushBack( 1 );
+ array.PushBack( "world" );
+ array.PushBack( 3 );
+
+ DALI_TEST_CHECK( 3 == array.Count() );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayEmptyP(void)
+{
+ Property::Array array;
+ DALI_TEST_CHECK( array.Empty() );
+
+ array.Reserve(3);
+
+ DALI_TEST_CHECK( array.Empty() );
+
+ array.PushBack( 1 );
+ array.PushBack( "world" );
+ array.PushBack( 3 );
+
+ DALI_TEST_CHECK( !array.Empty() );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayClearP(void)
+{
+ Property::Array array;
+ DALI_TEST_CHECK( array.Empty() );
+
+ array.Reserve(3);
+
+ DALI_TEST_CHECK( array.Empty() );
+
+ array.PushBack( 1 );
+ array.PushBack( "world" );
+ array.PushBack( 3 );
+
+ DALI_TEST_CHECK( !array.Empty() );
+
+ array.Clear();
+
+ DALI_TEST_CHECK( array.Empty() );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayIndexOperatorP(void)
+{
+ Property::Array array;
+
+ array.Reserve(3);
+ array.PushBack( 1 );
+ array.PushBack( "world" );
+ array.PushBack( 3 );
+
+ DALI_TEST_CHECK( array[0].Get<int>() == 1 );
+ DALI_TEST_CHECK( array[1].Get<std::string>() == "world" );
+ DALI_TEST_CHECK( array[2].Get<int>() == 3 );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayConstIndexOperatorP(void)
+{
+ Property::Array anArray;
+
+ anArray.Reserve(3);
+ anArray.PushBack( 1 );
+ anArray.PushBack( "world" );
+ anArray.PushBack( 3 );
+
+ const Property::Array array(anArray);
+
+ DALI_TEST_CHECK( array[0].Get<int>() == 1 );
+ DALI_TEST_CHECK( array[1].Get<std::string>() == "world" );
+ DALI_TEST_CHECK( array[2].Get<int>() == 3 );
+
+ END_TEST;
+}
+
+int UtcDaliPropertyArrayAssignmentOperatorP(void)
+{
+ Property::Array anArray;
+
+ anArray.Reserve(3);
+ anArray.PushBack( 1 );
+ anArray.PushBack( "world" );
+ anArray.PushBack( 3 );
+
+ Property::Array array = anArray;
+
+ DALI_TEST_CHECK( array[0].Get<int>() == 1 );
+ DALI_TEST_CHECK( array[1].Get<std::string>() == "world" );
+ DALI_TEST_CHECK( array[2].Get<int>() == 3 );
+
+ END_TEST;
+}
child1Map[ "position" ] = Vector3::YAXIS;
Property::Array childArray;
- childArray.push_back( child1Map );
+ childArray.PushBack( child1Map );
map[ "actors" ] = childArray;
// Create
DALI_TEST_CHECK( value.HasKey( "actors" ) );
Property::Array children( value.GetValue( "actors").Get< Property::Array >() );
- DALI_TEST_CHECK( !children.empty() );
+ DALI_TEST_CHECK( !children.Empty() );
Property::Map childMap( children[0].Get< Property::Map >() );
DALI_TEST_CHECK( !childMap.Empty() );
Property::Value childValue( childMap );
Property::Value value;
if( index == Dali::LinearConstrainer::Property::VALUE )
{
- Property::Array propertyArray;
- value = Property::Value(propertyArray);
+ value = Property::Value(Property::ARRAY);
size_t count( mValue.Size() );
for( size_t i( 0 ); i != count; ++i )
{
}
else if( index == Dali::LinearConstrainer::Property::PROGRESS )
{
- Property::Array propertyArray;
- value = Property::Value(propertyArray);
+ value = Property::Value(Property::ARRAY);
size_t count( mValue.Size() );
for( size_t i( 0 ); i != count; ++i )
{
{
if( index == Dali::LinearConstrainer::Property::VALUE )
{
- Property::Array propertyArray;
- propertyValue.Get(propertyArray);
-
- size_t propertyArrayCount = propertyArray.size();
+ size_t propertyArrayCount = propertyValue.GetSize();
mValue.Resize( propertyArrayCount );
- for( size_t i(0); i!=propertyArrayCount; ++i )
+ for( size_t i(0); i != propertyArrayCount; ++i )
{
- propertyArray[i].Get( mValue[i]);
+ propertyValue.GetItem(i).Get( mValue[i] );
}
}
else if( index == Dali::LinearConstrainer::Property::PROGRESS )
{
- Property::Array propertyArray;
- propertyValue.Get(propertyArray);
-
- size_t propertyArrayCount = propertyArray.size();
+ size_t propertyArrayCount = propertyValue.GetSize();
mProgress.Resize( propertyArrayCount );
- for( size_t i(0); i!=propertyArrayCount; ++i )
+ for( size_t i(0); i != propertyArrayCount; ++i )
{
- propertyArray[i].Get( mProgress[i]);
+ propertyValue.GetItem(i).Get( mProgress[i] );
}
}
}
// 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
{
}
else if( index == Dali::PathConstrainer::Property::POINTS )
{
- Property::Array propertyArray;
- value = Property::Value(propertyArray);
+ value = Property::Value(Property::ARRAY);
const Dali::Vector<Vector3>& point = mPath->GetPoints();
size_t pointCount( point.Size() );
for( size_t i( 0 ); i != pointCount; ++i )
}
else if( index == Dali::PathConstrainer::Property::CONTROL_POINTS )
{
- Property::Array propertyArray;
- value = Property::Value(propertyArray);
+ value = Property::Value(Property::ARRAY);
const Dali::Vector<Vector3>& point = mPath->GetControlPoints();
size_t pointCount( point.Size() );
for( size_t i( 0 ); i != pointCount; ++i )
}
else if( index == Dali::PathConstrainer::Property::POINTS )
{
- Property::Array propertyArray;
- propertyValue.Get(propertyArray);
-
- size_t propertyArrayCount = propertyArray.size();
+ size_t propertyArrayCount = propertyValue.GetSize();
Dali::Vector<Vector3> point;
point.Resize( propertyArrayCount );
- for( size_t i(0); i!=propertyArrayCount; ++i )
+ for( size_t i(0); i != propertyArrayCount; ++i )
{
- propertyArray[i].Get( point[i]);
+ propertyValue.GetItem(i).Get( point[i] );
}
mPath->SetPoints( point );
}
else if( index == Dali::PathConstrainer::Property::CONTROL_POINTS )
{
- Property::Array propertyArray;
- propertyValue.Get(propertyArray);
-
- size_t propertyArrayCount = propertyArray.size();
+ size_t propertyArrayCount = propertyValue.GetSize();
Dali::Vector<Vector3> point;
point.Resize( propertyArrayCount );
- for( size_t i(0); i!=propertyArrayCount; ++i )
+ for( size_t i(0); i != propertyArrayCount; ++i )
{
- propertyArray[i].Get( point[i]);
+ propertyValue.GetItem(i).Get( point[i] );
}
mPath->SetControlPoints( point );
}
// INTERNAL INCLUDES
#include <dali/internal/event/common/property-helper.h>
+#include <dali/public-api/object/property-array.h>
namespace Dali
{
Property::Array propertyArray;
propertyValue.Get(propertyArray);
- size_t propertyArrayCount = propertyArray.size();
+ size_t propertyArrayCount = propertyArray.Size();
mPoint.Resize( propertyArrayCount );
for( size_t i(0); i!=propertyArrayCount; ++i )
{
Property::Array propertyArray;
propertyValue.Get(propertyArray);
- size_t propertyArrayCount = propertyArray.size();
+ size_t propertyArrayCount = propertyArray.Size();
mControlPoint.Resize( propertyArrayCount );
for( size_t i(0); i!=propertyArrayCount; ++i )
{
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/handle.h>
#include <dali/public-api/object/object-registry.h>
+#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/property-conditions.h>
#include <dali/public-api/object/property-index-ranges.h>
#include <dali/public-api/object/property-input.h>
$(public_api_src_dir)/object/base-object.cpp \
$(public_api_src_dir)/object/object-registry.cpp \
$(public_api_src_dir)/object/property.cpp \
+ $(public_api_src_dir)/object/property-array.cpp \
$(public_api_src_dir)/object/property-conditions.cpp \
$(public_api_src_dir)/object/property-input.cpp \
$(public_api_src_dir)/object/property-map.cpp \
$(public_api_src_dir)/object/base-object.h \
$(public_api_src_dir)/object/handle.h \
$(public_api_src_dir)/object/object-registry.h \
+ $(public_api_src_dir)/object/property-array.h \
$(public_api_src_dir)/object/property-conditions.h \
$(public_api_src_dir)/object/property-index-ranges.h \
$(public_api_src_dir)/object/property-input.h \
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/object/property-array.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+
+namespace Dali
+{
+
+namespace
+{
+}; // unnamed namespace
+
+struct Property::Array::Impl
+{
+ typedef std::vector<Value> Array;
+
+ Array mArray;
+};
+
+Property::Array::Array()
+: mImpl( new Impl )
+{
+}
+
+Property::Array::Array( const Property::Array& other )
+: mImpl( new Impl )
+{
+ mImpl->mArray = other.mImpl->mArray;
+}
+
+Property::Array::~Array()
+{
+ delete mImpl;
+}
+
+
+unsigned int Property::Array::Size() const
+{
+ return mImpl->mArray.size();
+}
+
+unsigned int Property::Array::Count() const
+{
+ return Size();
+}
+
+void Property::Array::PushBack(const Value& value)
+{
+ mImpl->mArray.push_back( value );
+}
+
+bool Property::Array::Empty() const
+{
+ return mImpl->mArray.empty();
+}
+
+void Property::Array::Clear()
+{
+ mImpl->mArray.clear();
+}
+
+void Property::Array::Reserve(size_t size)
+{
+ mImpl->mArray.reserve(size);
+}
+
+void Property::Array::Resize(size_t size)
+{
+ mImpl->mArray.resize(size);
+}
+
+size_t Property::Array::Capacity()
+{
+ return mImpl->mArray.capacity();
+}
+
+const Property::Value& Property::Array::operator[]( const std::size_t index ) const
+{
+ return mImpl->mArray[ index ];
+}
+
+Property::Value& Property::Array::operator[]( const std::size_t index )
+{
+ return mImpl->mArray[ index ];
+}
+
+Property::Array& Property::Array::operator=( const Property::Array& other )
+{
+ if( this != &other )
+ {
+ delete mImpl;
+ mImpl = new Impl;
+ mImpl->mArray = other.mImpl->mArray;
+ }
+ return *this;
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_PROPERTY_ARRAY_H__
+#define __DALI_PROPERTY_ARRAY_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/property-value.h>
+#include <dali/public-api/object/property.h>
+
+namespace Dali
+{
+
+/**
+ * @brief A Array of property values.
+ */
+class DALI_IMPORT_API Property::Array
+{
+public:
+
+ /**
+ * @brief Default constructor.
+ */
+ Array();
+
+ /**
+ * @brief Copy Constructor.
+ *
+ * @param[in] other The Array to copy from.
+ */
+ Array( const Array& other );
+
+ /**
+ * @brief Non-virtual destructor.
+ */
+ ~Array();
+
+ /**
+ * @brief Retrieve the number of elements in the array.
+ *
+ * @return The number of elements in the array.
+ */
+ unsigned int Size() const;
+
+ /**
+ * @brief Retrieve the number of elements in the array.
+ *
+ * @return The number of elements in the array.
+ */
+ unsigned int Count() const;
+
+ /**
+ * @brief Returns whether the array is empty.
+ *
+ * @return true if empty, false otherwise
+ */
+ bool Empty() const;
+
+ /**
+ * @brief Clears the array.
+ */
+ void Clear();
+
+ /**
+ * @brief Increase the capcity of the array.
+ */
+ void Reserve(size_t size);
+
+ /**
+ * @brief Resize to size.
+ */
+ void Resize(size_t size);
+
+ /**
+ * @brief Retrieve the capacity of the array.
+ *
+ * @return The allocated capacity of the array
+ */
+ size_t Capacity();
+
+ /**
+ * @brief Add an element to the array.
+ *
+ * @param[in] value The value to add to the end of the array
+ *
+ * @return The a reference to the element.
+ *
+ */
+ void PushBack(const Value& value);
+
+ /**
+ * @brief Const operator to access an element.
+ *
+ * @param[in] index The element index to access. No bounds checking is performed.
+ *
+ * @return The a reference to the element.
+ *
+ */
+ const Value& operator[]( const size_t index ) const;
+
+ /**
+ * @brief Operator to access an element.
+ *
+ * @param[in] index The element index to access. No bounds checking is performed.
+ *
+ * @return The a reference to the element.
+ *
+ */
+ Value& operator[]( const size_t index );
+
+ /**
+ * @brief Assignment Operator
+ *
+ * @param[in] other The array to copy from.
+ *
+ * @return The copied array.
+ */
+ Array& operator=( const Array& other );
+
+private:
+ struct DALI_INTERNAL Impl; ///< Private data
+ Impl* mImpl; ///< Pointer to private data
+};
+
+} // namespace Dali
+
+#endif // __DALI_PROPERTY_ARRAY_H__
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/quaternion.h>
#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/property-types.h>
#include <dali/integration-api/debug.h>
case Property::ARRAY:
{
- int i = 0;
Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
if(container)
{
- DALI_ASSERT_ALWAYS(index < static_cast<int>(container->size()) && "Property array index invalid");
+ DALI_ASSERT_ALWAYS(index < static_cast<int>(container->Size()) && "Property array index invalid");
DALI_ASSERT_ALWAYS(index >= 0 && "Property array index invalid");
- for(Property::Array::iterator iter = container->begin(); iter != container->end(); ++iter)
- {
- if(i++ == index)
- {
- return *iter;
- }
- }
+ return (*container)[index];
}
}
break;
case Property::ARRAY:
{
Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
- if( container && index < static_cast<int>(container->size()) )
+ if( container && index < static_cast<int>(container->Size()) )
{
(*container)[index] = value;
}
if(container)
{
- container->push_back(value);
- return container->size() - 1;
+ container->PushBack(value);
+ return container->Size() - 1;
}
else
{
Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
if(container)
{
- ret = container->size();
+ ret = container->Size();
}
}
break;
/**
* @brief An Array of property values.
*/
- typedef std::vector<Value> Array;
+ class Array;
/**
* @brief The property types supported.
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/property-array.h>
#include <dali/internal/common/image-attributes.h>
#include <dali/internal/event/images/resource-image-impl.h>
#include <dali/internal/event/images/frame-buffer-image-impl.h>
// Create children
Property::Array actorArray = value.Get< Property::Array >();
- for ( Property::Array::iterator arrayIter = actorArray.begin(), arrayEndIter = actorArray.end(); arrayIter != arrayEndIter; ++arrayIter )
+ for ( size_t i = 0; i < actorArray.Size(); ++i)
{
- actor.Add( NewActor( arrayIter->Get< Property::Map >() ) );
+ actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
}
}
else if ( key == "signals" )
{
Property::Map childMap;
CreatePropertyMap( actor.GetChildAt( child ), childMap );
- childArray.push_back( childMap );
+ childArray.PushBack( childMap );
}
map[ "actors" ] = childArray;
}