Remove dali-any from Property::Value 58/41358/2
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 12 Jun 2015 19:12:00 +0000 (20:12 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Mon, 15 Jun 2015 09:59:43 +0000 (02:59 -0700)
- reimplement multivalue using more efficient union inside value
- remove unnecessary asserts when types dont match
- cleanup and sanitize scripting
- remove unnecessary templates from GetEnum, added error handling

Change-Id: I6fce541ca017feab5f569e64d9d98c3427926245

16 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp
automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/builder/builder-set-property.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/table-view/table-view-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h

index 7d1ef18..e23dbe3 100644 (file)
@@ -689,53 +689,5 @@ int UtcDaliPushButtonProperties(void)
   DALI_TEST_CHECK( button.IsSelected() ) ;
   DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::SELECTED ) );
 
-  //  Button::PROPERTY_NORMAL_STATE_ACTOR
-  {
-    button.SetButtonImage( ResourceImage::New( "IMAGE_PATH_1") );
-    DALI_TEST_EQUALS( "IMAGE_PATH_1", button.GetProperty( Button::Property::NORMAL_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "ImageActor";
-
-    button.SetProperty( Button::Property::NORMAL_STATE_ACTOR, map );
-    DALI_TEST_EQUALS( "ImageActor", button.GetProperty( Button::Property::NORMAL_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-  }
-
-  //  Button::PROPERTY_SELECTED_STATE_ACTOR
-  {
-    button.SetSelectedImage( ResourceImage::New( "IMAGE_PATH_2") );
-    DALI_TEST_EQUALS( "IMAGE_PATH_2", button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "Actor";
-
-    button.SetProperty( Button::Property::SELECTED_STATE_ACTOR, map );
-    DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-    DALI_TEST_CHECK( "ImageActor" != button.GetProperty( Button::Property::SELECTED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >() );
-  }
-
-  //  Button::PROPERTY_DISABLED_STATE_ACTOR
-  {
-    button.SetDisabledImage( ResourceImage::New( "IMAGE_PATH_3") );
-    DALI_TEST_EQUALS( "IMAGE_PATH_3", button.GetProperty( Button::Property::DISABLED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "Actor";
-
-    button.SetProperty( Button::Property::DISABLED_STATE_ACTOR, map );
-    DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::DISABLED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-  }
-
-  //  Button::PROPERTY_LABEL_ACTOR
-  {
-    button.SetLabel( "LABEL_TEXT_CUSTOM" );
-    DALI_TEST_EQUALS( "TextLabel", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-
-    Property::Map map;
-    map[ "type" ] = "Actor";
-
-    button.SetProperty( Button::Property::LABEL_ACTOR, map );
-    DALI_TEST_EQUALS( "Actor", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
-  }
   END_TEST;
 }
index 3223daa..722f0a8 100644 (file)
@@ -428,17 +428,15 @@ int UtcDaliControlBackgroundProperties(void)
 
   Property::Map imageMap;
   imageMap[ "filename" ] = "TestImage";
-  Property::Map map;
-  map[ "image" ] = imageMap;
-  control.SetProperty( Control::Property::BACKGROUND_IMAGE, map );
+  control.SetProperty( Control::Property::BACKGROUND_IMAGE, imageMap );
   DALI_TEST_CHECK( control.GetChildCount() > 0 );
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::RED, TEST_LOCATION );
 
   Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
-  DALI_TEST_CHECK( propValue.HasKey( "image" ) );
-  DALI_TEST_CHECK( propValue.GetValue( "image" ).HasKey( "filename" ) );
-  DALI_TEST_CHECK( propValue.GetValue( "image" ).GetValue( "filename" ).Get< std::string>() == "TestImage" );
+  Property::Map* resultMap = propValue.GetMap();
+  DALI_TEST_CHECK( resultMap->Find( "filename" ) );
+  DALI_TEST_CHECK( resultMap->Find( "filename" )->Get< std::string>() == "TestImage" );
 
   Property::Map emptyMap;
   control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
index 9985106..6254e7a 100644 (file)
@@ -646,12 +646,14 @@ int UtcDaliTableViewSetGetProperty(void)
   Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
 
   DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION );
-  DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(), layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+  Property::Map* childMap =layoutRowsGet.GetValue(1).GetMap();
+  DALI_TEST_CHECK( childMap->Find( "policy" )->Get<std::string>().compare("fixed") == 0 );
+  DALI_TEST_EQUALS( childMap->Find( "value" )->Get<float>(), 30.f, TEST_LOCATION );
 
+  childMap =layoutRowsGet.GetValue(3).GetMap();
   DALI_TEST_CHECK( layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0 );
-  DALI_TEST_CHECK( layoutRowsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get<float>(), layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+  DALI_TEST_CHECK( childMap->Find( "policy" )->Get<std::string>().compare("relative") == 0 );
+  DALI_TEST_EQUALS( childMap->Find( "value" )->Get<float>(), 0.2f, TEST_LOCATION );
 
   // Test "layout-columns" property
   DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
@@ -673,12 +675,13 @@ int UtcDaliTableViewSetGetProperty(void)
 
   Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
   DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 );
-  DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
-
+  childMap =layoutColumnsGet.GetValue(2).GetMap();
+  DALI_TEST_CHECK( childMap->Find( "policy" )->Get<std::string>().compare("relative") == 0 );
+  DALI_TEST_EQUALS( childMap->Find( "value" )->Get<float>(), 0.2f, TEST_LOCATION );
+  childMap =layoutColumnsGet.GetValue(3).GetMap();
   DALI_TEST_CHECK( layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0 );
-  DALI_TEST_CHECK( layoutColumnsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+  DALI_TEST_CHECK( childMap->Find( "policy" )->Get<std::string>().compare("fixed") == 0 );
+  DALI_TEST_EQUALS( childMap->Find( "value" )->Get<float>(),30.f, TEST_LOCATION );
 
   END_TEST;
 }
index d19b3a1..21d7a3a 100644 (file)
@@ -155,33 +155,6 @@ int UtcDaliTextFieldNewP(void)
   END_TEST;
 }
 
-int UtcDaliTextFieldGetPropertyN(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliToolkitTextFieldGetPropertyN");
-  TextField field = TextField::New();
-  DALI_TEST_CHECK( field );
-
-  bool assert = false;
-  try
-  {
-    Property::Value value = field.GetProperty<bool>( 0 );
-  }
-  catch ( ... )
-  {
-    assert = true;
-  }
-  if ( assert )
-  {
-    tet_result(TET_PASS);
-  }
-  else
-  {
-    tet_result(TET_FAIL);
-  }
-  END_TEST;
-}
-
 // Positive test case for a method
 int UtcDaliTextFieldGetPropertyP(void)
 {
@@ -263,34 +236,6 @@ int UtcDaliTextFieldSetPropertyP(void)
   END_TEST;
 }
 
-// Negative test case for a method
-int UtcDaliTextFieldSetPropertyN(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliToolkitTextFieldSetPropertyN");
-  TextField field = TextField::New();
-  DALI_TEST_CHECK( field );
-
-  bool assert = false;
-  try
-  {
-    field.SetProperty( 0, true );
-  }
-  catch ( ... )
-  {
-    assert = true;
-  }
-  if ( assert )
-  {
-    tet_result(TET_PASS);
-  }
-  else
-  {
-    tet_result(TET_FAIL);
-  }
-  END_TEST;
-}
-
 // Positive Basic Text Renderer test
 int utcDaliTextFieldBasicRenderP(void)
 {
index c0e4bec..8f59dd7 100644 (file)
@@ -125,33 +125,6 @@ int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
   END_TEST;
 }
 
-int UtcDaliToolkitTextLabelGetPropertyN(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliToolkitTextLabelGetPropertyN");
-  TextLabel label = TextLabel::New("Test Text");
-  DALI_TEST_CHECK( label );
-
-  bool assert = false;
-  try
-  {
-    Property::Value value = label.GetProperty<bool>( 0 );
-  }
-  catch ( ... )
-  {
-    assert = true;
-  }
-  if ( assert )
-  {
-    tet_result(TET_PASS);
-  }
-  else
-  {
-    tet_result(TET_FAIL);
-  }
-  END_TEST;
-}
-
 // Positive test case for a method
 int UtcDaliToolkitTextLabelGetPropertyP(void)
 {
@@ -186,33 +159,6 @@ int UtcDaliToolkitTextLabelGetPropertyP(void)
   END_TEST;
 }
 
-int UtcDaliToolkitTextLabelSetPropertyN(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliToolkitTextLabelSetPropertyN");
-  TextLabel label = TextLabel::New("Test Text");
-  DALI_TEST_CHECK( label );
-
-  bool assert = false;
-  try
-  {
-    label.SetProperty( 0, true );
-  }
-  catch ( ... )
-  {
-    assert = true;
-  }
-  if ( assert )
-  {
-    tet_result(TET_PASS);
-  }
-  else
-  {
-    tet_result(TET_FAIL);
-  }
-  END_TEST;
-}
-
 int UtcDaliToolkitTextLabelSetPropertyP(void)
 {
   ToolkitTestApplication application;
index aedd849..988eabb 100644 (file)
@@ -17,8 +17,6 @@
 
 #include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
 
-#define STRINGIFY(...) #__VA_ARGS__
-
 namespace Dali
 {
 
index 6046ddd..ca264ab 100644 (file)
@@ -721,11 +721,12 @@ FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Re
     {
       if( OptionalChild image = IsChild( *images, name ) )
       {
-        Dali::Property::Value propertyMap(Property::MAP);
-        if( SetPropertyFromNode( *image, Property::MAP, propertyMap, constant ) )
+        Dali::Property::Value property(Property::MAP);
+        if( SetPropertyFromNode( *image, Property::MAP, property, constant ) )
         {
-          propertyMap.SetValue(KEYNAME_TYPE, Property::Value(std::string("FrameBufferImage")));
-          ret = FrameBufferImage::DownCast( Dali::Scripting::NewImage( propertyMap ) );
+          Property::Map* map = property.GetMap();
+          (*map)[ KEYNAME_TYPE ] = Property::Value(std::string("FrameBufferImage") );
+          ret = FrameBufferImage::DownCast( Dali::Scripting::NewImage( property ) );
           mFrameBufferImageLut[ name ] = ret;
         }
       }
index cd90217..d1ce450 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * 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.
@@ -17,6 +17,8 @@
 
 // EXTERNAL INCLUDES
 #include <sstream>
+#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/property-map.h>
 #include <dali/devel-api/adaptor-framework/color-controller.h>
 
 // INTERNAL INCLUDES
@@ -352,18 +354,19 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::V
       else if(node.Size())
       {
         value = Property::Value(Property::ARRAY);
+        Property::Array* array = value.GetArray();
         unsigned int i = 0;
         TreeNode::ConstIterator iter(node.CBegin());
         for( ; i < node.Size(); ++i, ++iter)
         {
-          Property::Value v;
-          if( SetPropertyFromNode( (*iter).second, v, replacer ) )
+          Property::Value childValue;
+          if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
           {
-            value.AppendItem(v);
+            array->PushBack( childValue );
           }
         }
 
-        if( value.GetSize() == static_cast<int>(node.Size()) )
+        if( array->Count() == node.Size() )
         {
           done = true;
         }
@@ -383,18 +386,19 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::V
       else if(node.Size())
       {
         value = Property::Value(Property::MAP);
+        Property::Map* map = value.GetMap();
         unsigned int i = 0;
         TreeNode::ConstIterator iter(node.CBegin());
         for( ; i < node.Size(); ++i, ++iter)
         {
-          Property::Value v;
-          if( SetPropertyFromNode( (*iter).second, v, replacer ) )
+          Property::Value childValue;
+          if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
           {
-            value.SetValue( (*iter).first, v );
+            map->Insert( (*iter).first, childValue );
           }
         }
 
-        if( value.GetSize() == static_cast<int>(node.Size()) )
+        if( map->Count() == node.Size() )
         {
           done = true;
         }
@@ -490,13 +494,14 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
         else
         {
           value = Property::Value(Property::ARRAY);
-          Property::Value v;
+          Property::Array* array = value.GetArray();
 
           for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
           {
-            if( SetPropertyFromNode( (*iter).second, v, replacer ) )
+            Property::Value childValue;
+            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
             {
-              value.AppendItem(v);
+              array->PushBack( childValue );
               done = true;
             }
           }
@@ -514,12 +519,13 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
         if( ((*iter).first) == 0 )
         {
           value = Property::Value(Property::ARRAY);
-          Property::Value v;
+          Property::Array* array = value.GetArray();
           for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
           {
-            if( SetPropertyFromNode( (*iter).second, v, replacer ) )
+            Property::Value childValue;
+            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
             {
-              value.AppendItem(v);
+              array->PushBack( childValue );
               done = true;
             }
           }
@@ -527,12 +533,13 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
         else
         {
           value = Property::Value(Property::MAP);
-          Property::Value v;
+          Property::Map* map = value.GetMap();
           for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
           {
-            if( SetPropertyFromNode( (*iter).second, v, replacer ) )
+            Property::Value childValue;
+            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
             {
-              value.SetValue((*iter).first, v);
+              map->Insert( (*iter).first, childValue );
               done = true;
             }
           }
index f65e77e..998289b 100755 (executable)
 
 // EXTERNAL INCLUDES
 #include <cstring> // for strcmp
-#include <dali/integration-api/debug.h>
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/animation/constraints.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/devel-api/object/type-registry-helper.h>
-#include <dali/public-api/images/resource-image.h>
+#include <dali/integration-api/debug.h>
+
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h>
@@ -600,16 +602,19 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr
       }
       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
       {
-        Dali::Vector<float> positions;
-        size_t positionCount = value.GetSize();
-        positions.Resize( positionCount );
-
-        for( size_t i = 0; i != positionCount; ++i )
+        Property::Array* array = value.GetArray();
+        if( array )
         {
-          value.GetItem(i).Get( positions[i] );
+          Dali::Vector<float> positions;
+          size_t positionCount = array->Count();
+          positions.Resize( positionCount );
+          for( size_t i = 0; i != positionCount; ++i )
+          {
+            array->GetElementAt( i ).Get( positions[i] );
+          }
+
+          scrollBarImpl.SetScrollPositionIntervals(positions);
         }
-
-        scrollBarImpl.SetScrollPositionIntervals(positions);
         break;
       }
     }
@@ -654,12 +659,13 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde
       }
       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
       {
-        Property::Value value;
+        Property::Value value( Property::ARRAY );
+        Property::Array* array = value.GetArray();
         Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
-        size_t positionCount( positions.Size() );
+        size_t positionCount( array->Count() );
         for( size_t i( 0 ); i != positionCount; ++i )
         {
-          value.AppendItem( positions[i] );
+          array->PushBack( positions[i] );
         }
         break;
       }
index 439dd8f..f12b873 100644 (file)
 // CLASS HEADER
 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.h>
 
-//INTERNAL INCLUDES
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/property-array.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
 
 namespace Dali
@@ -47,9 +50,10 @@ ScrollViewPagePathEffect::ScrollViewPagePathEffect(Path path, const Vector3& for
 
   //Create linear constrainer
   pointsProperty = Property::Value(Property::ARRAY);
-  pointsProperty.AppendItem(0.0f);
-  pointsProperty.AppendItem(1.0f);
-  pointsProperty.AppendItem(0.0f);
+  Property::Array* array = pointsProperty.GetArray();
+  array->PushBack(0.0f);
+  array->PushBack(1.0f);
+  array->PushBack(0.0f);
   mLinearConstrainer = Dali::LinearConstrainer::New();
   mLinearConstrainer.SetProperty( LinearConstrainer::Property::VALUE, pointsProperty );
 }
index 8ff89c3..a037767 100755 (executable)
@@ -725,7 +725,7 @@ float Slider::MarkFilter( float value )
   const float MARK_TOLERANCE = GetMarkTolerance();
 
   float mark;
-  for( std::size_t i = 0; i < mMarks.Size(); ++i)
+  for( MarkList::SizeType i = 0; i < mMarks.Count(); ++i)
   {
     const Property::Value& propertyValue = mMarks[i];
     propertyValue.Get( mark );
@@ -747,7 +747,7 @@ float Slider::SnapToMark( float value )
   float closestDist = std::numeric_limits<float>::max();
 
   float mark;
-  for( std::size_t i = 0; i < mMarks.Size(); ++i)
+  for( MarkList::SizeType  i = 0; i < mMarks.Count(); ++i)
   {
     const Property::Value& propertyValue = mMarks[i];
     propertyValue.Get( mark );
index 3e9eaf1..742ef5e 100644 (file)
@@ -137,7 +137,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-columns", MAP,
 
 DALI_TYPE_REGISTRATION_END()
 
-const Scripting::StringEnum< Toolkit::TableView::LayoutPolicy > LAYOUT_POLICY_STRING_TABLE[] =
+const Scripting::StringEnum LAYOUT_POLICY_STRING_TABLE[] =
 {
  { "fixed",    Toolkit::TableView::FIXED    },
  { "relative", Toolkit::TableView::RELATIVE },
@@ -1050,27 +1050,38 @@ void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl,
                                          void(TableView::*funcRelative)(unsigned int, float),
                                          const Property::Value& value )
 {
-  if( Property::MAP == value.GetType() )
+  Property::Map* map = value.GetMap();
+  if( map )
   {
-    Property::Map map = value.Get<Property::Map>();
     unsigned int rowIndex(0);
-    for ( unsigned int i = 0, count = map.Count(); i < count; ++i )
+    for ( unsigned int i = 0, count = map->Count(); i < count; ++i )
     {
-      Property::Value& item = map.GetValue(i);
+      Property::Value& item = map->GetValue(i);
+      Property::Map* childMap = item.GetMap();
 
-      if( std::istringstream(map.GetKey(i)) >> rowIndex  // the key is a number
-          && Property::MAP == item.GetType())
+      std::istringstream( map->GetKey(i) ) >> rowIndex;
+      if( childMap )
       {
-        if( item.HasKey( "policy" ) && item.HasKey( "value" ) )
+        Property::Value* policy = childMap->Find( "policy" );
+        Property::Value* value = childMap->Find( "value" );
+        if( policy && value )
         {
-          Toolkit::TableView::LayoutPolicy policy = Scripting::GetEnumeration< Toolkit::TableView::LayoutPolicy >( item.GetValue("policy").Get<std::string>().c_str(), LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT );
-          if( policy == Toolkit::TableView::FIXED )
+          std::string policyValue;
+          policy->Get( policyValue );
+          Toolkit::TableView::LayoutPolicy policy;
+          if( Scripting::GetEnumeration< Toolkit::TableView::LayoutPolicy >( policyValue.c_str(),
+                                                                             LAYOUT_POLICY_STRING_TABLE,
+                                                                             LAYOUT_POLICY_STRING_TABLE_COUNT,
+                                                                             policy ) )
           {
-            (tableViewImpl.*funcFixed)( rowIndex, item.GetValue("value").Get<float>() );
-          }
-          else if( policy == Toolkit::TableView::RELATIVE )
-          {
-            (tableViewImpl.*funcRelative)( rowIndex, item.GetValue("value").Get<float>() );
+            if( policy == Toolkit::TableView::FIXED )
+            {
+              (tableViewImpl.*funcFixed)( rowIndex, value->Get<float>() );
+            }
+            else if( policy == Toolkit::TableView::RELATIVE )
+            {
+              (tableViewImpl.*funcRelative)( rowIndex, value->Get<float>() );
+            }
           }
         }
       }
@@ -1094,8 +1105,22 @@ Property::Value TableView::GetColumnWidthsPropertyValue()
 
 void TableView::GetMapPropertyValue( const RowColumnArray& data, Property::Map& map )
 {
-  std::string fixedPolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIXED, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
-  std::string relativePolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::RELATIVE, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
+  const char* name = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIXED,
+                                                                                        LAYOUT_POLICY_STRING_TABLE,
+                                                                                        LAYOUT_POLICY_STRING_TABLE_COUNT );
+  std::string fixedPolicy;
+  if( name )
+  {
+    fixedPolicy = name;
+  }
+  name = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::RELATIVE,
+                                                                            LAYOUT_POLICY_STRING_TABLE,
+                                                                            LAYOUT_POLICY_STRING_TABLE_COUNT );
+  std::string relativePolicy;
+  if( name )
+  {
+    relativePolicy = name;
+  }
 
   const RowColumnArray::SizeType count = data.Size();
   for( RowColumnArray::SizeType i = 0; i < count; i++ )
index 43de0d9..6f868e6 100644 (file)
@@ -62,7 +62,7 @@ namespace // unnamed namespace
 namespace
 {
 
-const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
+const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
   { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
@@ -70,7 +70,7 @@ const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment >
 };
 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
 
-const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
+const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
   { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
@@ -251,11 +251,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
           const std::string alignStr = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %f\n", impl.mController.Get(), alignStr.c_str() );
 
-          const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
-                                                                                                                        HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                        HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
-
-          impl.mController->SetHorizontalAlignment( alignment );
+          LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
+          if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
+                                                                              HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                              HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                              alignment ) )
+          {
+            impl.mController->SetHorizontalAlignment( alignment );
+          }
         }
         break;
       }
@@ -266,11 +269,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
           const std::string alignStr = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %f\n", impl.mController.Get(), alignStr.c_str() );
 
-          LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(),
-                                                                                                                    VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                    VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
-
-          impl.mController->SetVerticalAlignment( alignment );
+          LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
+          if( Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(),
+                                                                            VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                            VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                            alignment ) )
+          {
+            impl.mController->SetVerticalAlignment( alignment );
+          }
         }
         break;
       }
@@ -612,9 +618,13 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
-                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
+                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+          if( name )
+          {
+            value = std::string( name );
+          }
         }
         break;
       }
@@ -622,9 +632,13 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
-                                                                                                                  VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                  VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
+                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+          if( name )
+          {
+            value = std::string( name );
+          }
         }
         break;
       }
index 854ddbf..de713ac 100644 (file)
@@ -50,7 +50,7 @@ namespace
 namespace
 {
 
-const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
+const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
   { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
@@ -58,7 +58,7 @@ const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment >
 };
 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
 
-const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
+const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
   { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
@@ -189,11 +189,14 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
-                                                                                                                                             HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                                             HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
-
-          impl.mController->SetHorizontalAlignment( alignment );
+          LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
+          if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
+                                                                                             HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                             HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                                             alignment ) )
+          {
+            impl.mController->SetHorizontalAlignment( alignment );
+          }
         }
         break;
       }
@@ -201,11 +204,14 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
-                                                                                                                                         VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                                         VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
-
-          impl.mController->SetVerticalAlignment( alignment );
+          LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
+          if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
+                                                                                           VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                           VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                                           alignment ) )
+          {
+            impl.mController->SetVerticalAlignment( alignment );
+          }
         }
         break;
       }
@@ -356,9 +362,13 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
-                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+          if( name )
+          {
+            value = std::string( name );
+          }
         }
         break;
       }
@@ -366,9 +376,13 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
-                                                                                                                VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
+                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+          if( name )
+          {
+            value = std::string( name );
+          }
         }
         break;
       }
index 0d7a2f0..ee5d0fd 100644 (file)
@@ -348,17 +348,12 @@ public:
 
         case Toolkit::Control::Property::BACKGROUND_IMAGE:
         {
-          if ( value.HasKey( "image" ) )
+          Image image = Scripting::NewImage( value );
+          if ( image )
           {
-            Property::Map imageMap = value.GetValue( "image" ).Get< Property::Map >();
-            Image image = Scripting::NewImage( imageMap );
-
-            if ( image )
-            {
-              controlImpl.SetBackgroundImage( image );
-            }
+            controlImpl.SetBackgroundImage( image );
           }
-          else if ( value.Get< Property::Map >().Empty() )
+          else
           {
             // An empty map means the background is no longer required
             controlImpl.ClearBackground();
@@ -423,9 +418,7 @@ public:
             if ( imageActor )
             {
               Image image = imageActor.GetImage();
-              Property::Map imageMap;
-              Scripting::CreatePropertyMap( image, imageMap );
-              map[ "image" ] = imageMap;
+              Scripting::CreatePropertyMap( image, map );
             }
           }
 
index d30f809..5da66a5 100755 (executable)
@@ -66,12 +66,12 @@ public:
   {
     enum
     {
-      SCROLL_DIRECTION = PROPERTY_START_INDEX,        ///< name "scroll-direction",        @see SetScrollDirection(),       type std::string
-      INDICATOR_HEIGHT_POLICY,                        ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type std::string
-      INDICATOR_FIXED_HEIGHT,                         ///< name "indicator-fixed-height",  @see SetIndicatorFixedHeight(),  type float
-      INDICATOR_SHOW_DURATION,                        ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type float
-      INDICATOR_HIDE_DURATION,                        ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type float
-      SCROLL_POSITION_INTERVALS                       ///< name "scroll-position-intervals",                                type float
+      SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scroll-direction",         @see SetScrollDirection(),        type std::string
+      INDICATOR_HEIGHT_POLICY,                 ///< name "indicator-height-policy",  @see SetIndicatorHeightPolicy(),  type std::string
+      INDICATOR_FIXED_HEIGHT,                  ///< name "indicator-fixed-height",   @see SetIndicatorFixedHeight(),   type float
+      INDICATOR_SHOW_DURATION,                 ///< name "indicator-show-duration",  @see SetIndicatorShowDuration(),  type float
+      INDICATOR_HIDE_DURATION,                 ///< name "indicator-hide-duration",  @see SetIndicatorHideDuration(),  type float
+      SCROLL_POSITION_INTERVALS                ///< name "scroll-position-intervals",@see SetScrollPositionIntervals() type Property::Array
     };
   };