From 0bc90c0b7bc6898a299e411aa88b5a0118f9c7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 22 Dec 2018 03:34:57 -0300 Subject: [PATCH] Clean up. --HG-- branch : dev-stateful-drawable --- include/eepp/scene/nodeattribute.hpp | 16 ++++++ src/eepp/scene/nodeattribute.cpp | 60 ++++++++++++++++++++ src/eepp/ui/uiimage.cpp | 2 +- src/eepp/ui/uilistbox.cpp | 10 ++-- src/eepp/ui/uiloader.cpp | 2 +- src/eepp/ui/uiprogressbar.cpp | 10 ++-- src/eepp/ui/uipushbutton.cpp | 2 +- src/eepp/ui/uiselectbutton.cpp | 2 +- src/eepp/ui/uitabwidget.cpp | 16 +++--- src/eepp/ui/uitextureregion.cpp | 2 +- src/eepp/ui/uitextview.cpp | 16 +++--- src/eepp/ui/uiwidget.cpp | 85 ++++++++-------------------- 12 files changed, 130 insertions(+), 93 deletions(-) diff --git a/include/eepp/scene/nodeattribute.hpp b/include/eepp/scene/nodeattribute.hpp index 9daef6504..54fb9808c 100644 --- a/include/eepp/scene/nodeattribute.hpp +++ b/include/eepp/scene/nodeattribute.hpp @@ -3,6 +3,13 @@ #include #include +#include +#include +#include + +using namespace EE::System; +using namespace EE::Math; +using namespace EE::Graphics; namespace EE { namespace Scene { @@ -42,6 +49,15 @@ class NodeAttribute { bool asBool( bool defaultValue = false ) const; + Color asColor() const; + + Float asDpDimension( const std::string& defaultValue = "" ) const; + + int asDpDimensionI( const std::string& defaultValue = "" ) const; + + OriginPoint asOriginPoint() const; + + BlendMode asBlendMode() const; protected: std::string mName; std::string mValue; diff --git a/src/eepp/scene/nodeattribute.cpp b/src/eepp/scene/nodeattribute.cpp index 1148c2cbb..f6f73a1c2 100644 --- a/src/eepp/scene/nodeattribute.cpp +++ b/src/eepp/scene/nodeattribute.cpp @@ -1,4 +1,5 @@ #include +#include namespace EE { namespace Scene { @@ -66,4 +67,63 @@ bool NodeAttribute::asBool( bool defaultValue ) const { return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y'); } +Color NodeAttribute::asColor() const { + return Color::fromString( mValue ); +} + +Float NodeAttribute::asDpDimension( const std::string& defaultValue ) const { + return Graphics::PixelDensity::toDpFromString( asString( defaultValue ) ); +} + +int NodeAttribute::asDpDimensionI( const std::string& defaultValue ) const { + return Graphics::PixelDensity::toDpFromStringI( asString( defaultValue ) ); +} + +static OriginPoint toOriginPoint( std::string val ) { + String::toLowerInPlace( val ); + + if ( "center" == val ) { + return OriginPoint::OriginCenter; + } else if ( "topleft" == val ) { + return OriginPoint::OriginTopLeft; + } else { + std::vector parts = String::split( val, ',' ); + + if ( parts.size() == 2 ) { + Float x = 0; + Float y = 0; + + bool Res1 = String::fromString( x, parts[0] ); + bool Res2 = String::fromString( y, parts[1] ); + + if ( Res1 && Res2 ) { + return OriginPoint( x, y ); + } + } + } + + return OriginPoint::OriginCenter; +} + +static BlendMode toBlendMode( std::string val ) { + String::toLowerInPlace( val ); + + BlendMode blendMode; + + if ( val == "add" ) blendMode = BlendAdd; + else if ( val == "alpha" ) blendMode = BlendAlpha; + else if ( val == "multiply" ) blendMode = BlendMultiply; + else if ( val == "none" ) blendMode = BlendNone; + + return blendMode; +} + +OriginPoint NodeAttribute::asOriginPoint() const { + return toOriginPoint( mValue ); +} + +BlendMode NodeAttribute::asBlendMode() const { + return toBlendMode( mValue ); +} + }} diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index 08715d0ee..f3095647b 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -207,7 +207,7 @@ bool UIImage::setAttribute( const NodeAttribute& attribute ) { setScaleType( UIScaleType::None ); } } else if ( "tint" == name ) { - setColor( Color::fromString( attribute.asString() ) ); + setColor( attribute.asColor() ); } else { return UIWidget::setAttribute( attribute ); } diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index db1321939..df1a1f67e 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -989,15 +989,15 @@ bool UIListBox::setAttribute( const NodeAttribute& attribute ) { if ( "rowheight" == name ) { setRowHeight( attribute.asInt() ); } else if ( "textcolor" == name ) { - setFontColor( Color::fromString( attribute.asString() ) ); + setFontColor( attribute.asColor() ); } else if ( "textshadowcolor" == name ) { - mFontStyleConfig.ShadowColor = ( Color::fromString( attribute.asString() ) ); + mFontStyleConfig.ShadowColor = ( attribute.asColor() ); } else if ( "textovercolor" == name ) { - setFontOverColor( Color::fromString( attribute.asString() ) ); + setFontOverColor( attribute.asColor() ); } else if ( "textselectedcolor" == name ) { - setFontSelectedColor( Color::fromString( attribute.asString() ) ); + setFontSelectedColor( attribute.asColor() ); } else if ( "textselectionbackcolor" == name ) { - mFontStyleConfig.FontSelectionBackColor = ( Color::fromString( attribute.asString() ) ); + mFontStyleConfig.FontSelectionBackColor = ( attribute.asColor() ); } else if ( "fontfamily" == name || "fontname" == name ) { Font * font = FontManager::instance()->getByName( attribute.asString() ); diff --git a/src/eepp/ui/uiloader.cpp b/src/eepp/ui/uiloader.cpp index 0b5046c31..b2d539574 100644 --- a/src/eepp/ui/uiloader.cpp +++ b/src/eepp/ui/uiloader.cpp @@ -194,7 +194,7 @@ bool UILoader::setAttribute( const NodeAttribute& attribute ) { } else if ( "progress" == name ) { setProgress( attribute.asFloat() ); } else if ( "fillcolor" == name ) { - setFillColor( Color::fromString( attribute.asString() ) ); + setFillColor( attribute.asColor() ); } else if ( "radius" == name ) { setRadius( attribute.asFloat() ); } else if ( "outlinethickness" == name ) { diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index a1452ccd5..186feb383 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -225,16 +225,16 @@ bool UIProgressBar::setAttribute( const NodeAttribute& attribute ) { } else if ( "displaypercent" == name ) { setDisplayPercent( attribute.asBool() ); } else if ( "fillerpadding" == name ) { - Float val = PixelDensity::toDpFromString( attribute.asString() ); + Float val = attribute.asDpDimension(); setFillerPadding( Rectf( val, val, val, val ) ); } else if ( "fillerpaddingleft" == name ) { - setFillerPadding( Rectf( PixelDensity::toDpFromString( attribute.asString() ), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) ); + setFillerPadding( Rectf( attribute.asDpDimension(), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) ); } else if ( "fillerpaddingright" == name ) { - setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, PixelDensity::toDpFromString( attribute.asString() ), mStyleConfig.FillerPadding.Bottom ) ); + setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, attribute.asDpDimension(), mStyleConfig.FillerPadding.Bottom ) ); } else if ( "fillerpaddingtop" == name ) { - setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, PixelDensity::toDpFromString( attribute.asString() ), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) ); + setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, attribute.asDpDimension(), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) ); } else if ( "fillerpaddingbottom" == name ) { - setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, PixelDensity::toDpFromString( attribute.asString() ) ) ); + setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, attribute.asDpDimension() ) ); } else { return UIWidget::setAttribute( attribute ); } diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index 2fc3ecd6d..9c2d25ea3 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -376,7 +376,7 @@ bool UIPushButton::setAttribute( const NodeAttribute& attribute ) { if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) setText( static_cast( mSceneNode )->getTranslatorString( attribute.asString() ) ); } else if ( "textovercolor" == name ) { - setFontOverColor( Color::fromString( attribute.asString() ) ); + setFontOverColor( attribute.asColor() ); } else if ( "icon" == name ) { std::string val = attribute.asString(); Drawable * icon = NULL; diff --git a/src/eepp/ui/uiselectbutton.cpp b/src/eepp/ui/uiselectbutton.cpp index 5453efeb6..e7467477a 100644 --- a/src/eepp/ui/uiselectbutton.cpp +++ b/src/eepp/ui/uiselectbutton.cpp @@ -93,7 +93,7 @@ bool UISelectButton::setAttribute( const NodeAttribute& attribute ) { const std::string& name = attribute.getName(); if ( "textselectedcolor" == name ) { - setFontSelectedColor( Color::fromString( attribute.asString() ) ); + setFontSelectedColor( attribute.asColor() ); } else { return UIPushButton::setAttribute( attribute ); } diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 7aa60e649..e45258391 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -190,20 +190,20 @@ bool UITabWidget::setAttribute( const NodeAttribute& attribute ) { const std::string& name = attribute.getName(); if ( "textcolor" == name ) { - setFontColor( Color::fromString( attribute.asString() ) ); + setFontColor( attribute.asColor() ); } else if ( "textshadowcolor" == name ) { - setFontShadowColor( Color::fromString( attribute.asString() ) ); + setFontShadowColor( attribute.asColor() ); } else if ( "textovercolor" == name ) { - setFontOverColor( Color::fromString( attribute.asString() ) ); + setFontOverColor( attribute.asColor() ); } else if ( "textselectedcolor" == name ) { - setFontSelectedColor( Color::fromString( attribute.asString() ) ); + setFontSelectedColor( attribute.asColor() ); } else if ( "fontfamily" == name || "fontname" == name ) { Font * font = FontManager::instance()->getByName( attribute.asString() ); if ( NULL != font ) setFont( font ); } else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) { - setCharacterSize( PixelDensity::toDpFromStringI( attribute.asString() ) ); + setCharacterSize( attribute.asDpDimensionI() ); } else if ( "textstyle" == name || "fontstyle" == name ) { std::string valStr = attribute.asString(); String::toLowerInPlace( valStr ); @@ -230,9 +230,9 @@ bool UITabWidget::setAttribute( const NodeAttribute& attribute ) { setFontStyle( flags ); } } else if ( "fontoutlinethickness" == name ) { - setOutlineThickness( PixelDensity::toDpFromString( attribute.asString() ) ); + setOutlineThickness( attribute.asDpDimension() ); } else if ( "fontoutlinecolor" == name ) { - setOutlineColor( Color::fromString( attribute.asString() ) ); + setOutlineColor( attribute.asColor() ); } else if ( "maxtextlength" == name ) { setMaxTextLength( attribute.asUint(1) ); } else if ( "mintabwidth" == name ) { @@ -246,7 +246,7 @@ bool UITabWidget::setAttribute( const NodeAttribute& attribute ) { } else if ( "drawlinebelowtabs" == name ) { setDrawLineBelowTabs( attribute.asBool() ); } else if ( "linebelowtabscolor" == name ) { - setLineBelowTabsColor( Color::fromString( attribute.asString() ) ); + setLineBelowTabsColor( attribute.asColor() ); } else if ( "linebelowtabsyoffset" == name ) { setLineBelowTabsYOffset( attribute.asInt() ); } else { diff --git a/src/eepp/ui/uitextureregion.cpp b/src/eepp/ui/uitextureregion.cpp index f189876a8..b9cdc01f7 100644 --- a/src/eepp/ui/uitextureregion.cpp +++ b/src/eepp/ui/uitextureregion.cpp @@ -213,7 +213,7 @@ bool UITextureRegion::setAttribute( const NodeAttribute& attribute ) { setScaleType( UIScaleType::None ); } } else if ( "tint" == name ) { - setColor( Color::fromString( attribute.asString() ) ); + setColor( attribute.asColor() ); } else { return UIWidget::setAttribute( attribute ); } diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index 19c4e5afc..5319ff7d0 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -539,22 +539,22 @@ bool UITextView::setAttribute( const NodeAttribute& attribute ) { if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) setText( static_cast( mSceneNode )->getTranslatorString( attribute.asString() ) ); } else if ( "textcolor" == name ) { - setFontColor( Color::fromString( attribute.asString() ) ); + setFontColor( attribute.asColor() ); } else if ( "textshadowcolor" == name ) { - setFontShadowColor( Color::fromString( attribute.asString() ) ); + setFontShadowColor( attribute.asColor() ); } else if ( "textovercolor" == name ) { - mFontStyleConfig.FontOverColor = Color::fromString( attribute.asString() ); + mFontStyleConfig.FontOverColor = attribute.asColor(); } else if ( "textselectedcolor" == name ) { - mFontStyleConfig.FontSelectedColor = Color::fromString( attribute.asString() ); + mFontStyleConfig.FontSelectedColor = attribute.asColor(); } else if ( "textselectionbackcolor" == name ) { - setSelectionBackColor( Color::fromString( attribute.asString() ) ); + setSelectionBackColor( attribute.asColor() ); } else if ( "fontfamily" == name || "fontname" == name ) { Font * font = FontManager::instance()->getByName( attribute.asString() ); if ( NULL != font ) setFont( font ); } else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) { - setCharacterSize( PixelDensity::toDpFromStringI( attribute.asString() ) ); + setCharacterSize( attribute.asDpDimensionI() ); } else if ( "textstyle" == name || "fontstyle" == name ) { std::string valStr = attribute.asString(); String::toLowerInPlace( valStr ); @@ -585,9 +585,9 @@ bool UITextView::setAttribute( const NodeAttribute& attribute ) { setFontStyle( flags ); } } else if ( "fontoutlinethickness" == name ) { - setOutlineThickness( PixelDensity::toDpFromString( attribute.asString() ) ); + setOutlineThickness( attribute.asDpDimension() ); } else if ( "fontoutlinecolor" == name ) { - setOutlineColor( Color::fromString( attribute.asString() ) ); + setOutlineColor( attribute.asColor() ); } else if ( "textselection" == name ) { mFlags|= UI_TEXT_SELECTION_ENABLED; } else { diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 369dbb902..a2661a99f 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -433,45 +433,6 @@ void UIWidget::endAttributesTransaction() { } } -static OriginPoint toOriginPoint( std::string val ) { - String::toLowerInPlace( val ); - - if ( "center" == val ) { - return OriginPoint::OriginCenter; - } else if ( "topleft" == val ) { - return OriginPoint::OriginTopLeft; - } else { - std::vector parts = String::split( val, ',' ); - - if ( parts.size() == 2 ) { - Float x = 0; - Float y = 0; - - bool Res1 = String::fromString( x, parts[0] ); - bool Res2 = String::fromString( y, parts[1] ); - - if ( Res1 && Res2 ) { - return OriginPoint( x, y ); - } - } - } - - return OriginPoint::OriginCenter; -} - -static BlendMode toBlendMode( std::string val ) { - String::toLowerInPlace( val ); - - BlendMode blendMode; - - if ( val == "add" ) blendMode = BlendAdd; - else if ( val == "alpha" ) blendMode = BlendAlpha; - else if ( val == "multiply" ) blendMode = BlendMultiply; - else if ( val == "none" ) blendMode = BlendNone; - - return blendMode; -} - bool UIWidget::setAttribute( const std::string& name, const std::string& value ) { return setAttribute( NodeAttribute( name, value ) ); } @@ -484,14 +445,14 @@ bool UIWidget::setAttribute(const NodeAttribute & attribute) { if ( "id" == name ) { setId( attribute.value() ); } else if ( "x" == name ) { - setInternalPosition( Vector2f( PixelDensity::toDpFromString( attribute.asString() ), mDpPos.y ) ); + setInternalPosition( Vector2f( attribute.asDpDimension(), mDpPos.y ) ); } else if ( "y" == name ) { - setInternalPosition( Vector2f( mDpPos.x, PixelDensity::toDpFromString( attribute.asString() ) ) ); + setInternalPosition( Vector2f( mDpPos.x, attribute.asDpDimension() ) ); } else if ( "width" == name ) { - setInternalWidth( PixelDensity::toDpFromStringI( attribute.asString() ) ); + setInternalWidth( attribute.asDpDimensionI() ); notifyLayoutAttrChange(); } else if ( "height" == name ) { - setInternalHeight( PixelDensity::toDpFromStringI( attribute.asString() ) ); + setInternalHeight( attribute.asDpDimensionI() ); notifyLayoutAttrChange(); } else if ( "background" == name ) { Drawable * res = NULL; @@ -499,30 +460,30 @@ bool UIWidget::setAttribute(const NodeAttribute & attribute) { const std::string attributeName( attribute.asString() ); if ( String::startsWith( attributeName, "#" ) ) { - setBackgroundColor( Color::fromString( attribute.asString() ) ); + setBackgroundColor( attribute.asColor() ); } else if ( NULL != ( res = DrawableSearcher::searchByName( attributeName ) ) ) { setBackgroundDrawable( res, res->getDrawableType() == Drawable::SPRITE ); } } else if ( "backgroundcolor" == name ) { - setBackgroundColor( Color::fromString( attribute.asString() ) ); + setBackgroundColor( attribute.asColor() ); } else if ( "foreground" == name ) { Drawable * res = NULL; const std::string attributeName( attribute.asString() ); if ( String::startsWith( attributeName, "#" ) ) { - setForegroundColor( Color::fromString( attribute.asString() ) ); + setForegroundColor( attribute.asColor() ); } else if ( NULL != ( res = DrawableSearcher::searchByName( attributeName ) ) ) { setForegroundDrawable( res, res->getDrawableType() == Drawable::SPRITE ); } } else if ( "foregroundcolor" == name ) { - setForegroundColor( Color::fromString( attribute.asString() ) ); + setForegroundColor( attribute.asColor() ); } else if ( "foregroundcorners" == name ) { setForegroundCorners( attribute.asUint() ); } else if ( "bordercolor" == name ) { - setBorderColor( Color::fromString( attribute.asString() ) ); + setBorderColor( attribute.asColor() ); } else if ( "borderwidth" == name ) { - setBorderWidth( PixelDensity::toDpFromStringI( attribute.asString("1") ) ); + setBorderWidth( attribute.asDpDimensionI("1") ); } else if ( "bordercorners" == name || "backgroundcorners" == name ) { setBackgroundCorners( attribute.asUint() ); } else if ( "visible" == name ) { @@ -595,16 +556,16 @@ bool UIWidget::setAttribute(const NodeAttribute & attribute) { } } } else if ( "layout_margin" == name ) { - int val = PixelDensity::toDpFromStringI( attribute.asString() ); + int val = attribute.asDpDimensionI(); setLayoutMargin( Rect( val, val, val, val ) ); } else if ( "layout_marginleft" == name ) { - setLayoutMargin( Rect( PixelDensity::toDpFromStringI( attribute.asString() ), mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) ); + setLayoutMargin( Rect( attribute.asDpDimensionI(), mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) ); } else if ( "layout_marginright" == name ) { - setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, PixelDensity::toDpFromStringI( attribute.asString() ), mLayoutMargin.Bottom ) ); + setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, attribute.asDpDimensionI(), mLayoutMargin.Bottom ) ); } else if ( "layout_margintop" == name ) { - setLayoutMargin( Rect( mLayoutMargin.Left, PixelDensity::toDpFromStringI( attribute.asString() ), mLayoutMargin.Right, mLayoutMargin.Bottom ) ); + setLayoutMargin( Rect( mLayoutMargin.Left, attribute.asDpDimensionI(), mLayoutMargin.Right, mLayoutMargin.Bottom ) ); } else if ( "layout_marginbottom" == name ) { - setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, PixelDensity::toDpFromStringI( attribute.asString() ) ) ); + setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, attribute.asDpDimensionI() ) ); } else if ( "tooltip" == name ) { setTooltipText( attribute.asString() ); } else if ( "layout_weight" == name ) { @@ -699,22 +660,22 @@ bool UIWidget::setAttribute(const NodeAttribute & attribute) { } else if ( "scale" == name ) { setScale( attribute.asFloat() ); } else if ( "rotationoriginpoint" == name ) { - setRotationOriginPoint( toOriginPoint( attribute.asString() ) ); + setRotationOriginPoint( attribute.asOriginPoint() ); } else if ( "scaleoriginpoint" == name ) { - setScaleOriginPoint( toOriginPoint( attribute.asString() ) ); + setScaleOriginPoint( attribute.asOriginPoint() ); } else if ( "blendmode" == name ) { - setBlendMode( toBlendMode( attribute.asString() ) ); + setBlendMode( attribute.asBlendMode() ); } else if ( "padding" == name ) { - int val = PixelDensity::toDpFromStringI( attribute.asString() ); + int val = attribute.asDpDimensionI(); setPadding( Rectf( val, val, val, val ) ); } else if ( "paddingleft" == name ) { - setPadding( Rectf( PixelDensity::toDpFromString( attribute.asString() ), mPadding.Top, mPadding.Right, mPadding.Bottom ) ); + setPadding( Rectf( attribute.asDpDimension(), mPadding.Top, mPadding.Right, mPadding.Bottom ) ); } else if ( "paddingright" == name ) { - setPadding( Rectf( mPadding.Left, mPadding.Top, PixelDensity::toDpFromString( attribute.asString() ), mPadding.Bottom ) ); + setPadding( Rectf( mPadding.Left, mPadding.Top, attribute.asDpDimension(), mPadding.Bottom ) ); } else if ( "paddingtop" == name ) { - setPadding( Rectf( mPadding.Left, PixelDensity::toDpFromString( attribute.asString() ), mPadding.Right, mPadding.Bottom ) ); + setPadding( Rectf( mPadding.Left, attribute.asDpDimension(), mPadding.Right, mPadding.Bottom ) ); } else if ( "paddingbottom" == name ) { - setPadding( Rectf( mPadding.Left, mPadding.Top, mPadding.Right, PixelDensity::toDpFromString( attribute.asString() ) ) ); + setPadding( Rectf( mPadding.Left, mPadding.Top, mPadding.Right, attribute.asDpDimension() ) ); } else { attributeSet = false; }