Added PropertyValue Array as a class 02/39402/3
authorLee Morgan <Lee.morgan@partner.samsung.com>
Tue, 12 May 2015 14:42:52 +0000 (15:42 +0100)
committerLee Morgan <Lee.morgan@partner.samsung.com>
Thu, 14 May 2015 13:20:46 +0000 (14:20 +0100)
Change-Id: I84de3a7feee2f19a2464a07be25859faefc26059

automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp
automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.cpp
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/controls/slider/slider-impl.h
plugins/dali-script-v8/src/object/property-value-wrapper.cpp

index d7edf06..a76c39d 100644 (file)
@@ -440,14 +440,14 @@ int UtcDaliScrollViewPagePathEffectTest(void)
 
   Dali::Path path = Dali::Path::New();
   Dali::Property::Array points;
-  points.resize(3);
+  points.Resize(3);
   points[0] = Vector3( xHalfSize, 0.0f,  -xHalfSize);
   points[1] = Vector3( 0.0f, 0.0f, 0.0f );
   points[2] = Vector3( -xHalfSize, 0.0f,  -xHalfSize);
   path.SetProperty( Path::Property::POINTS, points );
 
   Dali::Property::Array controlPoints;
-  controlPoints.resize(4);
+  controlPoints.Resize(4);
   controlPoints[0] = Vector3( xHalfSize, 0.0f, 0.0f );
   controlPoints[1] = Vector3( xHalfSize, 0.0f, 0.0f );
   controlPoints[2] = Vector3(-xHalfSize, 0.0f, 0.0f );
index 89090da..29b1ef6 100644 (file)
@@ -21,7 +21,6 @@
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 
-
 using namespace Dali;
 using namespace Dali::Toolkit;
 
@@ -134,7 +133,7 @@ int UtcDaliSliderSignals(void)
   Property::Array marks;
   for( int i = 0; i < NUM_MARKS; ++i )
   {
-    marks.push_back( MIN_BOUND + ( static_cast<float>(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) );
+    marks.PushBack( MIN_BOUND + ( static_cast<float>(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) );
   }
   slider.SetProperty( Slider::Property::MARKS, marks );
   slider.SetProperty( Slider::Property::MARK_TOLERANCE, 0.1f );
index be1993c..fd58ec3 100644 (file)
@@ -25,6 +25,7 @@
 #include <dali/public-api/render-tasks/render-task-list.h>
 #include <dali/public-api/object/type-info.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/property-array.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/actors/camera-actor.h>
@@ -167,7 +168,7 @@ std::string PropertyValueToString( const Property::Value& value )
     }
     case Property::ARRAY:
     {
-      ret = std::string("Array Size=") + ToString( value.Get<Property::Array>().size() );
+      ret = std::string("Array Size=") + ToString( value.Get<Property::Array>().Size() );
       break;
     }
     case Property::MAP:
index c74ef04..0fba6a4 100755 (executable)
@@ -600,16 +600,13 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr
       }
       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
       {
-        Property::Array propertyArray;
-        value.Get(propertyArray);
-
         Dali::Vector<float> positions;
-        size_t positionCount = propertyArray.size();
+        size_t positionCount = value.GetSize();
         positions.Resize( positionCount );
 
         for( size_t i = 0; i != positionCount; ++i )
         {
-          propertyArray[i].Get( positions[i]);
+          value.GetItem(i).Get( positions[i] );
         }
 
         scrollBarImpl.SetScrollPositionIntervals(positions);
index 50d57a1..439dd8f 100644 (file)
@@ -40,17 +40,13 @@ ScrollViewPagePathEffect::ScrollViewPagePathEffect(Path path, const Vector3& for
   mPathConstrainer.SetProperty( PathConstrainer::Property::FORWARD, forward );
 
   Dali::Property::Value pointsProperty = path.GetProperty(Path::Property::POINTS);
-  Property::Array points;
-  pointsProperty.Get(points);
-  mPathConstrainer.SetProperty( PathConstrainer::Property::POINTS, points );
+  mPathConstrainer.SetProperty( PathConstrainer::Property::POINTS, pointsProperty );
 
   pointsProperty = path.GetProperty(Path::Property::CONTROL_POINTS);
-  pointsProperty.Get(points);
-  mPathConstrainer.SetProperty( PathConstrainer::Property::CONTROL_POINTS, points );
+  mPathConstrainer.SetProperty( PathConstrainer::Property::CONTROL_POINTS, pointsProperty );
 
   //Create linear constrainer
-  Property::Array pointsLinearConstrainer;
-  pointsProperty = Property::Value(pointsLinearConstrainer);
+  pointsProperty = Property::Value(Property::ARRAY);
   pointsProperty.AppendItem(0.0f);
   pointsProperty.AppendItem(1.0f);
   pointsProperty.AppendItem(0.0f);
index 94d4bbe..92efa56 100755 (executable)
@@ -355,14 +355,7 @@ void Slider::DisplayValue( float value, bool raiseSignals )
 
 void Slider::SetMarks( const MarkList& marks )
 {
-  float value;
-  for( MarkList::const_iterator it = marks.begin(), itEnd = marks.end(); it != itEnd; ++it )
-  {
-    const Property::Value& propertyValue = *it;
-    propertyValue.Get( value );
-
-    mMarks.push_back( value );
-  }
+  mMarks = marks;
 }
 
 const Slider::MarkList& Slider::GetMarks() const
@@ -732,9 +725,9 @@ float Slider::MarkFilter( float value )
   const float MARK_TOLERANCE = GetMarkTolerance();
 
   float mark;
-  for( MarkList::iterator it = mMarks.begin(), itEnd = mMarks.end(); it != itEnd; ++it )
+  for( std::size_t i = 0; i < mMarks.Size(); ++i)
   {
-    const Property::Value& propertyValue = *it;
+    const Property::Value& propertyValue = mMarks[i];
     propertyValue.Get( mark );
     mark = MapValuePercentage( mark );
 
@@ -754,9 +747,9 @@ float Slider::SnapToMark( float value )
   float closestDist = std::numeric_limits<float>::max();
 
   float mark;
-  for( MarkList::iterator it = mMarks.begin(), itEnd = mMarks.end(); it != itEnd; ++it )
+  for( std::size_t i = 0; i < mMarks.Size(); ++i)
   {
-    const Property::Value& propertyValue = *it;
+    const Property::Value& propertyValue = mMarks[i];
     propertyValue.Get( mark );
     mark = MapValuePercentage( mark );
 
@@ -777,7 +770,7 @@ bool Slider::MarkReached( float value, int& outIndex )
 
   // Binary search
   int head = 0,
-      tail = mMarks.size() - 1;
+      tail = mMarks.Size() - 1;
   int current;
   float mark;
 
index a8003c7..b265d25 100755 (executable)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/object/property-array.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
index 60c5c55..b5595f8 100644 (file)
@@ -19,6 +19,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
+#include <dali/public-api/object/property-array.h>
 
 // INTERNAL INCLUDES
 #include <v8-utils.h>
@@ -89,7 +90,7 @@ void SetY( Dali::Property::Value &value, S& v)
 {
   T tmp = value.Get<T>();
   tmp.y = v;
-  value = tmp ;
+  value = tmp;
 }
 
 template <typename T, typename S>
@@ -97,7 +98,7 @@ void SetZ( Dali::Property::Value &value, S& v)
 {
   T tmp = value.Get<T>();
   tmp.z = v;
-  value = tmp ;
+  value = tmp;
 }
 
 template <typename T, typename S>
@@ -105,14 +106,14 @@ void SetW( Dali::Property::Value &value, S& v)
 {
   T tmp = value.Get<T>();
   tmp.w = v;
-  value = tmp ;
+  value = tmp;
 }
 template <typename T, typename S>
 void SetWidth( Dali::Property::Value &value, S& v)
 {
   T tmp = value.Get<T>();
   tmp.width = v;
-  value = tmp ;
+  value = tmp;
 }
 
 template <typename T, typename S>
@@ -120,7 +121,7 @@ void SetHeight( Dali::Property::Value &value, S& v)
 {
   T tmp = value.Get<T>();
   tmp.height = v;
-  value = tmp ;
+  value = tmp;
 }
 
 v8::Handle< v8::Value > GetV8ValueFrom( v8::Isolate* isolate,
@@ -142,13 +143,13 @@ v8::Handle< v8::Value > GetV8ValueFrom( v8::Isolate* isolate,
 
       if( field == "x" || field == "width" )
       {
-        Dali::Vector2 v2 = value.Get<Dali::Vector2>() ;
-        ret = v8::Number::New( isolate, v2.x) ;
+        Dali::Vector2 v2 = value.Get<Dali::Vector2>();
+        ret = v8::Number::New( isolate, v2.x);
       }
       else if(field == "y" || field == "height")
       {
-        Dali::Vector2 v2 = value.Get<Dali::Vector2>() ;
-        ret = v8::Number::New( isolate, v2.y) ;
+        Dali::Vector2 v2 = value.Get<Dali::Vector2>();
+        ret = v8::Number::New( isolate, v2.y);
       }
 
       break;
@@ -159,18 +160,18 @@ v8::Handle< v8::Value > GetV8ValueFrom( v8::Isolate* isolate,
 
       if(field == "x" || field == "width" || field == "r")
       {
-        Dali::Vector3 v3 = value.Get<Dali::Vector3>() ;
-        ret = v8::Number::New( isolate, v3.x) ;
+        Dali::Vector3 v3 = value.Get<Dali::Vector3>();
+        ret = v8::Number::New( isolate, v3.x);
       }
       else if(field == "y" || field == "height" || field == "g")
       {
-        Dali::Vector3 v3 = value.Get<Dali::Vector3>() ;
-        ret = v8::Number::New( isolate, v3.y) ;
+        Dali::Vector3 v3 = value.Get<Dali::Vector3>();
+        ret = v8::Number::New( isolate, v3.y);
       }
       else if(field == "z" || field == "depth" || field == "b")
       {
-        Dali::Vector3 v3 = value.Get<Dali::Vector3>() ;
-        ret = v8::Number::New( isolate, v3.z) ;
+        Dali::Vector3 v3 = value.Get<Dali::Vector3>();
+        ret = v8::Number::New( isolate, v3.z);
       }
       break;
     }
@@ -180,23 +181,23 @@ v8::Handle< v8::Value > GetV8ValueFrom( v8::Isolate* isolate,
 
       if(field == "x" || field == "s" || field == "r")
       {
-        Dali::Vector4 v4 = value.Get<Dali::Vector4>() ;
-        ret = v8::Number::New( isolate, v4.x) ;
+        Dali::Vector4 v4 = value.Get<Dali::Vector4>();
+        ret = v8::Number::New( isolate, v4.x);
       }
       else if(field == "y" || field == "g" || field == "t")
       {
-        Dali::Vector4 v4 = value.Get<Dali::Vector4>() ;
-        ret = v8::Number::New( isolate, v4.y) ;
+        Dali::Vector4 v4 = value.Get<Dali::Vector4>();
+        ret = v8::Number::New( isolate, v4.y);
       }
       else if(field == "z" || field == "r" || field == "b")
       {
-        Dali::Vector4 v4 = value.Get<Dali::Vector4>() ;
-        ret = v8::Number::New( isolate, v4.z) ;
+        Dali::Vector4 v4 = value.Get<Dali::Vector4>();
+        ret = v8::Number::New( isolate, v4.z);
       }
       else if(field == "w" || field == "a" || field == "q")
       {
-        Dali::Vector4 v4 = value.Get<Dali::Vector4>() ;
-        ret = v8::Number::New( isolate, v4.w) ;
+        Dali::Vector4 v4 = value.Get<Dali::Vector4>();
+        ret = v8::Number::New( isolate, v4.w);
       }
 
       break;
@@ -208,17 +209,17 @@ v8::Handle< v8::Value > GetV8ValueFrom( v8::Isolate* isolate,
       if(field == "roll")
       {
         Dali::Vector4 v4 = value.Get<Dali::Quaternion>().EulerAngles();
-        ret = v8::Number::New( isolate, v4.z) ;
+        ret = v8::Number::New( isolate, v4.z);
       }
       else if(field == "pitch")
       {
         Dali::Vector4 v4 = value.Get<Dali::Quaternion>().EulerAngles();
-        ret = v8::Number::New( isolate, v4.x) ;
+        ret = v8::Number::New( isolate, v4.x);
       }
       else if(field == "yaw")
       {
         Dali::Vector4 v4 = value.Get<Dali::Quaternion>().EulerAngles();
-        ret = v8::Number::New( isolate, v4.y) ;
+        ret = v8::Number::New( isolate, v4.y);
       }
 
        else if(field == "axis")
@@ -243,23 +244,23 @@ v8::Handle< v8::Value > GetV8ValueFrom( v8::Isolate* isolate,
 
       if(field == "x")
       {
-        Dali::Rect<int> r = value.Get<Dali::Rect<int> >() ;
-        ret = v8::Number::New( isolate, r.x) ;
+        Dali::Rect<int> r = value.Get<Dali::Rect<int> >();
+        ret = v8::Number::New( isolate, r.x);
       }
       else if(field == "y")
       {
-        Dali::Rect<int> r = value.Get<Dali::Rect<int> >() ;
-        ret = v8::Number::New( isolate, r.y) ;
+        Dali::Rect<int> r = value.Get<Dali::Rect<int> >();
+        ret = v8::Number::New( isolate, r.y);
       }
       else if(field == "width")
       {
-        Dali::Rect<int> r = value.Get<Dali::Rect<int> >() ;
-        ret = v8::Number::New( isolate, r.width) ;
+        Dali::Rect<int> r = value.Get<Dali::Rect<int> >();
+        ret = v8::Number::New( isolate, r.width);
       }
       else if(field == "height")
       {
-        Dali::Rect<int> r = value.Get<Dali::Rect<int> >() ;
-        ret = v8::Number::New( isolate, r.height) ;
+        Dali::Rect<int> r = value.Get<Dali::Rect<int> >();
+        ret = v8::Number::New( isolate, r.height);
       }
       break;
     }
@@ -319,11 +320,11 @@ void SetFromV8Value(v8::Isolate* isolate,
     {
       if(field == "x" || field == "width")
       {
-        SetX<Dali::Vector2>(value, asFloat) ;
+        SetX<Dali::Vector2>(value, asFloat);
       }
       else if(field == "y" || field == "height")
       {
-        SetY<Dali::Vector2>(value, asFloat) ;
+        SetY<Dali::Vector2>(value, asFloat);
       }
       else
       {
@@ -336,15 +337,15 @@ void SetFromV8Value(v8::Isolate* isolate,
     {
       if(field == "x" || field == "width" || field == "r")
       {
-        SetX<Dali::Vector3>(value, asFloat) ;
+        SetX<Dali::Vector3>(value, asFloat);
       }
       else if(field == "y" || field == "height" || field == "g")
       {
-        SetY<Dali::Vector3>(value, asFloat) ;
+        SetY<Dali::Vector3>(value, asFloat);
       }
       else if(field == "z" || field == "depth" || field == "b")
       {
-        SetZ<Dali::Vector3>(value, asFloat) ;
+        SetZ<Dali::Vector3>(value, asFloat);
       }
       else
       {
@@ -357,19 +358,19 @@ void SetFromV8Value(v8::Isolate* isolate,
     {
       if(field == "x" || field == "s" || field == "r")
       {
-        SetX<Dali::Vector4>(value, asFloat) ;
+        SetX<Dali::Vector4>(value, asFloat);
       }
       else if(field == "y" || field == "g" || field == "t")
       {
-        SetY<Dali::Vector4>(value, asFloat) ;
+        SetY<Dali::Vector4>(value, asFloat);
       }
       else if(field == "z" || field == "r" || field == "b")
       {
-        SetZ<Dali::Vector4>(value, asFloat) ;
+        SetZ<Dali::Vector4>(value, asFloat);
       }
       else if(field == "w" || field == "a" || field == "q")
       {
-        SetW<Dali::Vector4>(value, asFloat) ;
+        SetW<Dali::Vector4>(value, asFloat);
       }
       else
       {
@@ -441,15 +442,15 @@ void SetFromV8Value(v8::Isolate* isolate,
     {
       if(field == "x")
       {
-        SetX<Dali::Rect<int> >(value, asInt) ;
+        SetX<Dali::Rect<int> >(value, asInt);
       }
       else if(field == "y")
       {
-        SetY<Dali::Rect<int> >(value, asInt) ;
+        SetY<Dali::Rect<int> >(value, asInt);
       }
       else if(field == "width")
       {
-        SetWidth<Dali::Rect<int> >(value, asInt) ;
+        SetWidth<Dali::Rect<int> >(value, asInt);
       }
       else if(field == "height")
       {
@@ -496,7 +497,7 @@ v8::Local<v8::Object> CreateJavaScriptPrimitive( v8::Isolate* isolate, const Dal
 {
   v8::EscapableHandleScope handleScope( isolate );
 
-  v8::Local<v8::Value> v8Value ;
+  v8::Local<v8::Value> v8Value;
 
   switch( value.GetType() )
    {
@@ -605,12 +606,13 @@ Dali::Property::Value PropertyValueWrapper::ArrayFromV8Array( v8::Isolate* isola
   //Cast v8::Value to v8::Array
   v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast( v8Value );
   uint32_t elementCount = v8Array->Length();
-  Dali::Property::Array data( elementCount );
+  Dali::Property::Array data;
+  data.Reserve( elementCount );
   bool bFound(false);
   for( uint32_t i(0); i<elementCount; ++i )
   {
     //Get Property::Value for each element in the array
-    data[i] = V8Utils::GetPropertyValueFromObject( bFound, isolate, v8Array->Get(i) );
+    data.PushBack( V8Utils::GetPropertyValueFromObject( bFound, isolate, v8Array->Get(i) ) );
   }
 
   //return the Property::Value
@@ -789,7 +791,7 @@ void PropertyValueWrapper::NewRotation( const v8::FunctionCallbackInfo< v8::Valu
   }
   v8::Local<v8::Object > object;
 
-  float v[4] = {0.f,0.f,0.f,0.f} ;
+  float v[4] = {0.f,0.f,0.f,0.f};
 
   bool foundAllArguments(false);
   V8Utils::ReadFloatArguments( foundAllArguments, v, 4, args, 0.f );