X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-set-property.cpp;h=367c527ab8bd033571961aeb9c18e79bbee99196;hb=078278a2ea58db1f07114513bf21783eb689f63a;hp=d17a3920d1b30da140ab57e5623edabc3e0f11db;hpb=602711f643eed100940eb0b54c1dacacce2ae27e;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/builder/builder-set-property.cpp b/dali-toolkit/internal/builder/builder-set-property.cpp index d17a392..367c527 100644 --- a/dali-toolkit/internal/builder/builder-set-property.cpp +++ b/dali-toolkit/internal/builder/builder-set-property.cpp @@ -19,13 +19,13 @@ #include #include #include -#include // INTERNAL INCLUDES #include #include #include - +#include +#include namespace Dali { @@ -36,80 +36,16 @@ namespace Toolkit namespace Internal { -/* - * Set a property value from a tree node. - * This function determines the type of the property from the format of the string in the node. - * This is not always possible and if the type cannot be determined then then the type will default to Array. - * @param node The node string to convert from - * @param value The property value to set - */ -void DeterminePropertyFromNode( const TreeNode& node, Property::Value& value ); - -/* - * Set a property value from a tree node as SetPropertyFromNode() above - * This function determines the type of the property from the format of the string in the node. - * This is not always possible and if the type cannot be determined then then the type will default to Array. - * @param node The node string to convert from - * @param value The property value to set - * @param replacement The overriding replacement map (if any) - */ -void DeterminePropertyFromNode( const TreeNode& node, Property::Value& value, - const Replacement& replacement ); - -/* - * Set a property value as the given type from a tree node. - * @param node The node string to convert from - * @param type The property type to convert to. - * @param value The property value to set - * @return true if the string could be converted to the correct type. - */ -bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value ); - -/* - * Set a property value as the given type from a tree node as SetPropertyFromNode() above - * @param node The node string to convert from - * @param type The property type to convert to. - * @param value The property value to set - * @param replacement The overriding replacement map (if any) - * @return true if the string could be converted to the correct type. - */ -bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, - const Replacement& replacement ); - - -namespace -{ - -/** - * Converts a HTML style 'color' hex string ("#FF0000" for bright red) to a Vector4. - * The Vector4 alpha component will be set to 1.0f - * @param hexString The HTML style hex string - * @return a Vector4 containing the new color value - */ -Vector4 HexStringToVector4( const char* s ) -{ - unsigned int value(0u); - std::istringstream( s ) >> std::hex >> value; - return Vector4( ((value >> 16 ) & 0xff ) / 255.0f, - ((value >> 8 ) & 0xff ) / 255.0f, - (value & 0xff ) / 255.0f, - 1.0f ); -} - -} // anon namespace - - /** * A property value type can be forced when its unknown by a disambiguation convention in the json * ie "myarray": [1,2,3,4] ; would be a vector but * "myarray": {"typeCast":"array", "value":[1,2,3,4]} would be an array - * @param child The node whos string to search for a disambiguated type + * @param child The node whose string to search for a disambiguated type * @param value The value to set - * @param overrideMap The user overriding constant map - * @param defaultMap The default map. + * @param replacement The user overriding constant map * @return True if child contained a disambiguated string that could be converted. */ -bool Disambiguated(const TreeNode& child, // ConstantLut& constantLut, +bool Disambiguated(const TreeNode& child, Dali::Property::Value& value, const Replacement& replacement ) { @@ -161,6 +97,10 @@ bool Disambiguated(const TreeNode& child, // ConstantLut& constantLut, { return DeterminePropertyFromNode( *childValue, Dali::Property::ARRAY, value, replacement); } + else if(*childType == "extents") + { + return DeterminePropertyFromNode( *childValue, Dali::Property::EXTENTS, value, replacement); + } } // else we failed to disambiguate @@ -175,7 +115,7 @@ bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Prope } bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, - const Replacement& replacer ) + const Replacement& replacer ) { bool done = false; @@ -235,17 +175,9 @@ bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Prope } else if( OptionalString s = replacer.IsString(node) ) { - if( (*s)[0] == '#' && 7 == (*s).size() ) - { - value = HexStringToVector4( &(*s)[1] ); - done = true; - } - else if( Dali::ColorController::Get() ) - { - Vector4 color; - done = Dali::ColorController::Get().RetrieveColor( *s, color ); - value = color; - } + Vector4 color; + done = ConvertStringToColor( *s, color ); + value = color; } else if( TreeNode::OBJECT == node.GetType() ) { @@ -389,6 +321,15 @@ bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Prope } break; } + case Property::EXTENTS: + { + if( OptionalExtents v = replacer.IsExtents(node) ) + { + value = *v; + done = true; + } + break; + } case Property::NONE: { break; @@ -406,7 +347,7 @@ void DeterminePropertyFromNode( const TreeNode& node, Property::Value& value ) } void DeterminePropertyFromNode( const TreeNode& node, Property::Value& value, - const Replacement& replacer ) + const Replacement& replacer ) { TreeNode::NodeType nodeType = node.GetType(); @@ -517,7 +458,6 @@ void DeterminePropertyFromNode( const TreeNode& node, Property::Value& value, } else { - // string always succeeds with the current json parser so its last value = *aString; } } // if aBool