diff --git a/bin/assets/layouts/test.css b/bin/assets/layouts/test.css index 65e124d31..8252f829e 100644 --- a/bin/assets/layouts/test.css +++ b/bin/assets/layouts/test.css @@ -320,6 +320,18 @@ TabWidget { background-position: bottom right; } +#lvbox { + background-image: url(file://assets/icon/ee.png); + background-position: bottom right; + background-size: 128px 128px; + transition: all 1s; + clip: true; +} + +#lvbox:hover { + background-position: top right; +} + #rrl > #tmap { font-size: 24dp; padding: 12dp; diff --git a/include/eepp/math/vector2.hpp b/include/eepp/math/vector2.hpp index 4e7e000f2..88841f85c 100755 --- a/include/eepp/math/vector2.hpp +++ b/include/eepp/math/vector2.hpp @@ -96,6 +96,8 @@ class Vector2 { Vector2 floor(); + Vector2 abs(); + Vector2 asFloat(); Vector2 asInt(); @@ -433,6 +435,10 @@ Vector2 Vector2::floor() { return Vector2( eefloor( x ), eefloor( y ) ); } +template +Vector2 Vector2::abs() { + return Vector2( eeabs( x ), eeabs( y ) ); +} template Vector2 Vector2::asFloat() { diff --git a/include/eepp/ui/css/stylesheetlength.hpp b/include/eepp/ui/css/stylesheetlength.hpp index 4249e4223..db0a420a0 100644 --- a/include/eepp/ui/css/stylesheetlength.hpp +++ b/include/eepp/ui/css/stylesheetlength.hpp @@ -36,6 +36,8 @@ class StyleSheetLength { StyleSheetLength(); + StyleSheetLength( std::string val, const Float& defaultValue = 0 ); + StyleSheetLength( const StyleSheetLength& val ); void setValue( const Float& val, const Unit& units ); diff --git a/include/eepp/ui/uinodedrawable.hpp b/include/eepp/ui/uinodedrawable.hpp index f1794db36..01ec90e8b 100644 --- a/include/eepp/ui/uinodedrawable.hpp +++ b/include/eepp/ui/uinodedrawable.hpp @@ -86,6 +86,8 @@ class EE_API UINodeDrawable : public Drawable { const Vector2f& getOffset() const; + std::string getOffsetEq(); + void setPositionEq( const std::string& offset ); const std::string& getPositionEq() const { return mPositionEq; } @@ -111,7 +113,6 @@ class EE_API UINodeDrawable : public Drawable { MoveAction * getMoveAction() const; void setMoveAction(MoveAction * moveAction); - protected: UINodeDrawable * mContainer; Sizef mSize; diff --git a/src/eepp/ui/css/stylesheetlength.cpp b/src/eepp/ui/css/stylesheetlength.cpp index e94b3a0e4..8b4a68733 100644 --- a/src/eepp/ui/css/stylesheetlength.cpp +++ b/src/eepp/ui/css/stylesheetlength.cpp @@ -35,6 +35,10 @@ StyleSheetLength::StyleSheetLength() : mValue(0) {} +StyleSheetLength::StyleSheetLength( std::string val, const Float& defaultValue ) : + StyleSheetLength( fromString( val, defaultValue ) ) { +} + StyleSheetLength::StyleSheetLength(const StyleSheetLength& val) { mUnit = val.mUnit; mValue = val.mValue; diff --git a/src/eepp/ui/uinodedrawable.cpp b/src/eepp/ui/uinodedrawable.cpp index 388396d7b..ceb1450d9 100644 --- a/src/eepp/ui/uinodedrawable.cpp +++ b/src/eepp/ui/uinodedrawable.cpp @@ -371,18 +371,18 @@ Sizef UINodeDrawable::LayerDrawable::calcDrawableSize( const std::string& drawab size = mDrawable->getSize(); } } else if ( sizePart[0] != "auto" ) { - CSS::StyleSheetLength wl( CSS::StyleSheetLength::fromString( sizePart[0] ) ); + CSS::StyleSheetLength wl( sizePart[0] ); size.x = mContainer->getOwner()->lengthAsPixels( wl, Sizef::Zero, true ); if ( sizePart[1] == "auto" ) { Sizef drawableSize( mDrawable->getSize() ); size.y = drawableSize.getHeight() * ( size.getWidth() / drawableSize.getWidth() ); } else { - CSS::StyleSheetLength hl( CSS::StyleSheetLength::fromString( sizePart[1] ) ); + CSS::StyleSheetLength hl( sizePart[1] ); size.y = mContainer->getOwner()->lengthAsPixels( hl, Sizef::Zero, false ); } } else { - CSS::StyleSheetLength hl( CSS::StyleSheetLength::fromString( sizePart[1] ) ); + CSS::StyleSheetLength hl( sizePart[1] ); size.y = mContainer->getOwner()->lengthAsPixels( hl, Sizef::Zero, false ); Sizef drawableSize( mDrawable->getSize() ); @@ -410,8 +410,8 @@ Vector2f UINodeDrawable::LayerDrawable::calcPosition( const std::string& positio yFloatIndex = 0; } - CSS::StyleSheetLength xl( CSS::StyleSheetLength::fromString( pos[xFloatIndex] ) ); - CSS::StyleSheetLength yl( CSS::StyleSheetLength::fromString( pos[yFloatIndex] ) ); + CSS::StyleSheetLength xl( pos[xFloatIndex] ); + CSS::StyleSheetLength yl( pos[yFloatIndex] ); position.x = mContainer->getOwner()->lengthAsPixels( xl, mDrawableSize, true ); position.y = mContainer->getOwner()->lengthAsPixels( yl, mDrawableSize, false ); } else if ( pos.size() > 2 ) { @@ -427,10 +427,10 @@ Vector2f UINodeDrawable::LayerDrawable::calcPosition( const std::string& positio 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] ) ); + CSS::StyleSheetLength xl1( pos[xFloatIndex] ); + CSS::StyleSheetLength xl2( pos[xFloatIndex+1] ); + CSS::StyleSheetLength yl1( pos[yFloatIndex] ); + CSS::StyleSheetLength yl2( pos[yFloatIndex+1] ); position.x = mContainer->getOwner()->lengthAsPixels( xl1, mDrawableSize, true ); @@ -465,6 +465,10 @@ void UINodeDrawable::LayerDrawable::setOffset( const Vector2f& offset ) { mOffset = offset; } +std::string UINodeDrawable::LayerDrawable::getOffsetEq() { + return String::format( "%.fpx %.fpx", mOffset.x, mOffset.y ); +} + void UINodeDrawable::LayerDrawable::onPositionChange() { invalidate(); } diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 6a9368548..590d3dc88 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -887,7 +887,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( attribute.getName() ) ) { UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( attribute.getName() ) ); - Uint32 tag = String::hash("width"); + constexpr Uint32 tag = String::hash("width"); Action * action = Actions::ResizeWidth::New( getSize().getWidth(), newWidth, transitionInfo.duration, transitionInfo.timingFunction ); @@ -909,7 +909,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state Float newHeight = attribute.asDpDimensionI(); if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( attribute.getName() ) ) { - Uint32 tag = String::hash("height"); + constexpr Uint32 tag = String::hash("height"); UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( attribute.getName() ) ); Action * action = Actions::ResizeHeight::New( getSize().getHeight(), newHeight, transitionInfo.duration, transitionInfo.timingFunction ); @@ -956,7 +956,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state SAVE_NORMAL_STATE_ATTR( getBackground()->getLayer(0)->getPositionEq() ); /*if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( attribute.getName() ) ) { - Uint32 tag = String::hash( "background-position" ); + constexpr Uint32 tag = String::hash( "background-position" ); UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( attribute.getName() ) );