From 6fc6385718c4a653ff7db830c46a411d71be5df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 23 Nov 2019 19:41:58 -0300 Subject: [PATCH] Edge offsets values support for background-position. --HG-- branch : dev --- bin/assets/layouts/test.xml | 2 +- src/eepp/ui/uinodedrawable.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bin/assets/layouts/test.xml b/bin/assets/layouts/test.xml index dd07112d1..7843d1a1a 100644 --- a/bin/assets/layouts/test.xml +++ b/bin/assets/layouts/test.xml @@ -54,7 +54,7 @@ + backgroundPosition="bottom 10% right 10%"> diff --git a/src/eepp/ui/uinodedrawable.cpp b/src/eepp/ui/uinodedrawable.cpp index 4327e8d17..c3942dd07 100644 --- a/src/eepp/ui/uinodedrawable.cpp +++ b/src/eepp/ui/uinodedrawable.cpp @@ -403,6 +403,33 @@ void UINodeDrawable::LayerDrawable::update() { CSS::StyleSheetLength yl( CSS::StyleSheetLength::fromString( pos[1] ) ); mOffset.x = mContainer->getOwner()->lengthAsPixels( xl, mDrawableSize, true ); mOffset.y = mContainer->getOwner()->lengthAsPixels( yl, mDrawableSize, false ); + } else if ( pos.size() > 2 ) { + if ( pos.size() == 3 ) { + pos.push_back( "0dp" ); + } + + int xFloatIndex = 0; + int yFloatIndex = 2; + + if ( "bottom" == pos[0] || "top" == pos[0] ) { + xFloatIndex = 2; + yFloatIndex = 0; + } + + CSS::StyleSheetLength xl1( CSS::StyleSheetLength::fromString( pos[xFloatIndex] ) ); + CSS::StyleSheetLength xl2( CSS::StyleSheetLength::fromString( pos[xFloatIndex+1] ) ); + CSS::StyleSheetLength yl1( CSS::StyleSheetLength::fromString( pos[yFloatIndex] ) ); + CSS::StyleSheetLength yl2( CSS::StyleSheetLength::fromString( pos[yFloatIndex+1] ) ); + + mOffset.x = mContainer->getOwner()->lengthAsPixels( xl1, mDrawableSize, true ); + + Float xl2Val = mContainer->getOwner()->lengthAsPixels( xl2, mDrawableSize, true ); + mOffset.x += ( pos[xFloatIndex] == "right" ) ? -xl2Val : xl2Val; + + mOffset.y = mContainer->getOwner()->lengthAsPixels( yl1, mDrawableSize, false ); + + Float yl2Val = mContainer->getOwner()->lengthAsPixels( yl2, mDrawableSize, false ); + mOffset.y += ( pos[yFloatIndex] == "bottom" ) ? -yl2Val : yl2Val; } mUpdatePosEq = false;