From: Kimmo Hoikka Date: Fri, 12 Jun 2015 19:12:00 +0000 (+0100) Subject: Remove dali-any from Property::Value X-Git-Tag: dali_1.0.45~6 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=36a298758d1b6244b7846a0102b528d76002dbda Remove dali-any from Property::Value - 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 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp index 7d1ef18..e23dbe3 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp @@ -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; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 3223daa..722f0a8 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -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 ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp index 9985106..6254e7a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp @@ -646,12 +646,14 @@ int UtcDaliTableViewSetGetProperty(void) Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get(); DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION ); - DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get()) == 0 ); - DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get(), layoutRows.GetValue(0).GetValue( "value" ).Get(), TEST_LOCATION ); + Property::Map* childMap =layoutRowsGet.GetValue(1).GetMap(); + DALI_TEST_CHECK( childMap->Find( "policy" )->Get().compare("fixed") == 0 ); + DALI_TEST_EQUALS( childMap->Find( "value" )->Get(), 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().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get()) == 0 ); - DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get(), layoutRows.GetValue(1).GetValue( "value" ).Get(), TEST_LOCATION ); + DALI_TEST_CHECK( childMap->Find( "policy" )->Get().compare("relative") == 0 ); + DALI_TEST_EQUALS( childMap->Find( "value" )->Get(), 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(); DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 ); - DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get()) == 0 ); - DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get(),layoutColumns.GetValue(0).GetValue( "value" ).Get(), TEST_LOCATION ); - + childMap =layoutColumnsGet.GetValue(2).GetMap(); + DALI_TEST_CHECK( childMap->Find( "policy" )->Get().compare("relative") == 0 ); + DALI_TEST_EQUALS( childMap->Find( "value" )->Get(), 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().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get()) == 0 ); - DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).GetValue( "value" ).Get(),layoutColumns.GetValue(1).GetValue( "value" ).Get(), TEST_LOCATION ); + DALI_TEST_CHECK( childMap->Find( "policy" )->Get().compare("fixed") == 0 ); + DALI_TEST_EQUALS( childMap->Find( "value" )->Get(),30.f, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index d19b3a1..21d7a3a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -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( 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) { diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index c0e4bec..8f59dd7 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -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( 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; diff --git a/dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp b/dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp index aedd849..988eabb 100644 --- a/dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp +++ b/dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp @@ -17,8 +17,6 @@ #include -#define STRINGIFY(...) #__VA_ARGS__ - namespace Dali { diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 6046ddd..ca264ab 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -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; } } diff --git a/dali-toolkit/internal/builder/builder-set-property.cpp b/dali-toolkit/internal/builder/builder-set-property.cpp index cd90217..d1ce450 100644 --- a/dali-toolkit/internal/builder/builder-set-property.cpp +++ b/dali-toolkit/internal/builder/builder-set-property.cpp @@ -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 +#include +#include #include // 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(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(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; } } diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index f65e77e..998289b 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -20,12 +20,14 @@ // EXTERNAL INCLUDES #include // for strcmp -#include #include #include +#include #include +#include #include -#include +#include + // INTERNAL INCLUDES #include @@ -600,16 +602,19 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS: { - Dali::Vector 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 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 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; } diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.cpp index 439dd8f..f12b873 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.cpp @@ -18,7 +18,10 @@ // CLASS HEADER #include -//INTERNAL INCLUDES +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES #include 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 ); } diff --git a/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp index 8ff89c3..a037767 100755 --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -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::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 ); diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp index 3e9eaf1..742ef5e 100644 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -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(); 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().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() ); - } - else if( policy == Toolkit::TableView::RELATIVE ) - { - (tableViewImpl.*funcRelative)( rowIndex, item.GetValue("value").Get() ); + if( policy == Toolkit::TableView::FIXED ) + { + (tableViewImpl.*funcFixed)( rowIndex, value->Get() ); + } + else if( policy == Toolkit::TableView::RELATIVE ) + { + (tableViewImpl.*funcRelative)( rowIndex, value->Get() ); + } } } } @@ -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++ ) diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 43de0d9..6f868e6 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -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; } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 854ddbf..de713ac 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -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; } diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 0d7a2f0..ee5d0fd 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -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 ); } } diff --git a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h index d30f809..5da66a5 100755 --- a/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h +++ b/dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h @@ -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 }; };