From f30ee4fb3eb971dd387e99869d82b2f6c7f39dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 15 May 2019 00:38:51 -0300 Subject: [PATCH] Minor changes. --HG-- branch : dev-css --- include/eepp/scene/nodeattribute.hpp | 2 +- src/eepp/scene/nodeattribute.cpp | 2 +- src/eepp/ui/uiwidget.cpp | 36 +++++++++++++++------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/eepp/scene/nodeattribute.hpp b/include/eepp/scene/nodeattribute.hpp index 7ed311d21..c89015908 100644 --- a/include/eepp/scene/nodeattribute.hpp +++ b/include/eepp/scene/nodeattribute.hpp @@ -62,7 +62,7 @@ class NodeAttribute { const std::string& getName() const; - const std::vector getParameters() const; + const std::vector& getParameters() const; bool isEmpty() const; protected: diff --git a/src/eepp/scene/nodeattribute.cpp b/src/eepp/scene/nodeattribute.cpp index 4672c61d6..663985522 100644 --- a/src/eepp/scene/nodeattribute.cpp +++ b/src/eepp/scene/nodeattribute.cpp @@ -365,7 +365,7 @@ const std::string& NodeAttribute::FunctionType::getName() const { return name; } -const std::vector NodeAttribute::FunctionType::getParameters() const { +const std::vector& NodeAttribute::FunctionType::getParameters() const { return parameters; } diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 4056e0ce8..3b324d2f6 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -791,31 +791,33 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state RectangleDrawable * drawable = RectangleDrawable::New(); RectColors rectColors; - if ( Color::isColorString( functionType.getParameters().at(0) ) ) { - rectColors.TopLeft = rectColors.TopRight = Color::fromString( functionType.getParameters().at(0) ); - rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( functionType.getParameters().at(1) ); - } else if ( functionType.getParameters().size() >= 3 ) { - std::string direction = functionType.getParameters().at(0); + const std::vector& params( functionType.getParameters() ); + + if ( Color::isColorString( params.at(0) ) ) { + rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at(0) ); + rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( params.at(1) ); + } else if ( params.size() >= 3 ) { + std::string direction = params.at(0); String::toLowerInPlace( direction ); if ( direction == "to bottom" ) { - rectColors.TopLeft = rectColors.TopRight = Color::fromString( functionType.getParameters().at(1) ); - rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( functionType.getParameters().at(2) ); + rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at(1) ); + rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( params.at(2) ); } else if ( direction == "to left" ) { - rectColors.TopLeft = rectColors.BottomLeft = Color::fromString( functionType.getParameters().at(2) ); - rectColors.TopRight = rectColors.BottomRight = Color::fromString( functionType.getParameters().at(1) ); + rectColors.TopLeft = rectColors.BottomLeft = Color::fromString( params.at(2) ); + rectColors.TopRight = rectColors.BottomRight = Color::fromString( params.at(1) ); } else if ( direction == "to right" ) { - rectColors.TopLeft = rectColors.BottomLeft = Color::fromString( functionType.getParameters().at(1) ); - rectColors.TopRight = rectColors.BottomRight = Color::fromString( functionType.getParameters().at(2) ); + rectColors.TopLeft = rectColors.BottomLeft = Color::fromString( params.at(1) ); + rectColors.TopRight = rectColors.BottomRight = Color::fromString( params.at(2) ); } else if ( direction == "to top" ) { - rectColors.TopLeft = rectColors.TopRight = Color::fromString( functionType.getParameters().at(2) ); - rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( functionType.getParameters().at(1) ); + rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at(2) ); + rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( params.at(1) ); } else { - rectColors.TopLeft = rectColors.TopRight = Color::fromString( functionType.getParameters().at(1) ); - rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( functionType.getParameters().at(2) ); + rectColors.TopLeft = rectColors.TopRight = Color::fromString( params.at(1) ); + rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( params.at(2) ); } } else { - return setAttribute( "backgroundcolor", functionType.getParameters().at(0) ); + return setAttribute( "backgroundcolor", params.at(0) ); } drawable->setRectColors( rectColors ); @@ -826,7 +828,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } else if ( "foreground" == name ) { Drawable * res = NULL; - if ( String::startsWith( attribute.getValue(), "#" ) ) { + if ( Color::isColorString( attribute.getValue() ) ) { setAttribute( NodeAttribute( "foregroundcolor", attribute.getValue() ) ); } else if ( NULL != ( res = DrawableSearcher::searchByName( attribute.getValue() ) ) ) { setForegroundDrawable( res, res->getDrawableType() == Drawable::SPRITE );