From 3a1fbaec4977e73c28565f4458d77d0d3cd4b4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 6 Feb 2019 01:41:40 -0300 Subject: [PATCH] UINode border fixes. --HG-- branch : dev-css --- src/eepp/graphics/rectangledrawable.cpp | 8 +++--- src/eepp/ui/uinode.cpp | 36 +++++++------------------ 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/eepp/graphics/rectangledrawable.cpp b/src/eepp/graphics/rectangledrawable.cpp index 8b2024e7e..3e4290182 100644 --- a/src/eepp/graphics/rectangledrawable.cpp +++ b/src/eepp/graphics/rectangledrawable.cpp @@ -94,9 +94,11 @@ Uint32 RectangleDrawable::getCorners() const { } void RectangleDrawable::setCorners(const Uint32 & corners) { - mCorners = corners; - mNeedsUpdate = true; - mRecreateVertexBuffer = true; + if ( corners != mCorners ) { + mCorners = corners; + mNeedsUpdate = true; + mRecreateVertexBuffer = true; + } } RectColors RectangleDrawable::getRectColors() const { diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 8e44547f2..17ae3e878 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -417,37 +417,28 @@ Color UINode::getBackgroundColor() const { } UINode * UINode::setBorderRadius( const unsigned int& corners ) { + setBorderEnabled( true )->setCorners( corners ); + UISkin * background = setBackgroundFillEnabled( true ); Drawable * stateDrawable = background->getStateDrawable( UIState::StateFlagNormal ); if ( NULL == stateDrawable ) { - setBackgroundColor( Color::Black ); + setBackgroundColor( Color::Transparent ); stateDrawable = background->getStateDrawable( UIState::StateFlagNormal ); } if ( stateDrawable->getDrawableType() == Drawable::RECTANGLE ) { - RectangleDrawable * rectangleDrawable = static_cast( stateDrawable ); - - rectangleDrawable->setCorners( corners ); + static_cast( stateDrawable )->setCorners( corners ); } return this; } Uint32 UINode::getBorderRadius() const { - if ( NULL != mBackgroundState && NULL != mBackgroundState->getSkin() ) { - Drawable * stateDrawable = mBackgroundState->getSkin()->getStateDrawable( UIState::StateFlagNormal ); - - if ( NULL != stateDrawable ) { - if ( stateDrawable->getDrawableType() == Drawable::RECTANGLE ) { - RectangleDrawable * rectangleDrawable = static_cast( stateDrawable ); - - return rectangleDrawable->getCorners(); - } - } - } + if ( NULL != mBorder ) + return mBorder->getCorners(); return 0; } @@ -574,7 +565,7 @@ UINode * UINode::unsetFlags(const Uint32 & flags) { return this; } -UINode *UINode::resetFlags( Uint32 newFlags ) { +UINode * UINode::resetFlags( Uint32 newFlags ) { mFlags = newFlags; return this; } @@ -593,18 +584,8 @@ void UINode::drawForeground() { void UINode::drawBorder() { if ( ( mFlags & UI_BORDER ) && NULL != mBorder ) { - if ( NULL != mBorder && NULL != mBackgroundState && NULL != mBackgroundState->getSkin() ) { - Drawable * backDrawable = mBackgroundState->getSkin()->getStateDrawable( mBackgroundState->getCurrentState() ); - - if ( NULL != backDrawable && backDrawable->getDrawableType() == Drawable::RECTANGLE ) { - RectangleDrawable * backgroundDrawable = static_cast( backDrawable ); - - getBorder()->setCorners( backgroundDrawable->getCorners() ); - } - } - Uint8 alpha = mBorder->getAlpha(); - mBorder->setAlpha( eemax( mAlpha * alpha / 255.f, 255 ) ); + mBorder->setAlpha( eemin( mAlpha * alpha / 255.f, 255 ) ); mBorder->draw( Vector2f( mScreenPosi.x, mScreenPosi.y ), Sizef( eefloor(mSize.getWidth()), eefloor(mSize.getHeight()) ) ); mBorder->setAlpha( alpha ); } @@ -658,6 +639,7 @@ UISkin * UINode::getForeground() { RectangleDrawable * UINode::getBorder() { if ( NULL == mBorder ) { mBorder = RectangleDrawable::New(); + mBorder->setColor( Color::Transparent ); mBorder->setFillMode( PrimitiveFillMode::DRAW_LINE ); mBorder->setLineWidth( PixelDensity::dpToPx(1) ); }