diff --git a/bin/assets/layouts/test.css b/bin/assets/layouts/test.css index 071bf4da1..af4d0fab4 100644 --- a/bin/assets/layouts/test.css +++ b/bin/assets/layouts/test.css @@ -71,8 +71,8 @@ Tooltip { borderWidth: 2dp; borderColor: #66666666; backgroundColor: #33FF3333; - backgroundCorners: 12; - transition: scale 0.25s, rotation 0.25s 0.25s, borderColor 0.25s, backgroundColor 0.25s; + borderRadius: 12; + transition: scale 0.25s, rotation 0.25s 0.25s, borderColor 0.25s, backgroundColor 0.25s, borderRadius 0.25s; } #tpad:hover { @@ -80,7 +80,7 @@ Tooltip { rotation: -3; backgroundColor: #FF333333; borderColor: #99999999; - backgroundCorners: 12; + borderRadius: 4; } #tpad2 { @@ -95,6 +95,7 @@ Tooltip { layout_marginLeft: 8dp; padding: 28dp; opacity: 1; + borderRadius: 24; backgroundColor: #656; } diff --git a/bin/assets/layouts/test.xml b/bin/assets/layouts/test.xml index ff198188a..bac231621 100644 --- a/bin/assets/layouts/test.xml +++ b/bin/assets/layouts/test.xml @@ -46,7 +46,7 @@ - + diff --git a/bin/assets/layouts/test_widgets.xml b/bin/assets/layouts/test_widgets.xml index d4a333214..f89f09682 100644 --- a/bin/assets/layouts/test_widgets.xml +++ b/bin/assets/layouts/test_widgets.xml @@ -57,7 +57,7 @@ - + diff --git a/include/eepp/core/string.hpp b/include/eepp/core/string.hpp index fbb382a38..3f2d09445 100644 --- a/include/eepp/core/string.hpp +++ b/include/eepp/core/string.hpp @@ -173,7 +173,7 @@ class EE_API String { } /** Returning a std::string from a formated string */ - static std::string strFormated( const char* format, ... ) + static std::string format( const char* format, ... ) #ifdef __GNUC__ /* This attribute is nice: it even works through gettext invokation. For example, gcc will complain that StrFormat(_("%s"), 42) is ill-formed. */ @@ -182,7 +182,7 @@ class EE_API String { ; /** Format a char buffer */ - static void strFormat( char * Buffer, int BufferSize, const char * format, ... ); + static void formatBuffer( char * Buffer, int BufferSize, const char * format, ... ); /** @brief Construct from an UTF-8 string to UTF-32 according ** @param utf8String UTF-8 string to convert diff --git a/include/eepp/scene/actions/actions.hpp b/include/eepp/scene/actions/actions.hpp index 6b9948947..a55e6be55 100644 --- a/include/eepp/scene/actions/actions.hpp +++ b/include/eepp/scene/actions/actions.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #endif diff --git a/include/eepp/scene/actions/resizeborderradius.hpp b/include/eepp/scene/actions/resizeborderradius.hpp new file mode 100644 index 000000000..eaf01b4e4 --- /dev/null +++ b/include/eepp/scene/actions/resizeborderradius.hpp @@ -0,0 +1,28 @@ +#ifndef EE_SCENE_RESIZEBORDERRADIUS_HPP +#define EE_SCENE_RESIZEBORDERRADIUS_HPP + +#include +#include + +namespace EE { namespace Scene { namespace Actions { + +class EE_API ResizeBorderRadius : public ActionInterpolation1d { + public: + static ResizeBorderRadius * New( const Float& start, const Float& end, const Time& duration, const Ease::Interpolation& type = Ease::Linear ); + + Action * clone() const override; + + Action * reverse() const override; + protected: + ResizeBorderRadius(); + + ResizeBorderRadius( const Float & start, const Float & end, const Time & duration, const Ease::Interpolation & type ); + + void onStart() override; + + void onUpdate( const Time& time ) override; +}; + +}}} + +#endif diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index e26ae4098..ef8e6df0c 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -105,9 +105,13 @@ class EE_API UINode : public Node { Color getBackgroundColor(); - UINode * setBackgroundCorners( const Uint32 & state, const unsigned int& corners ); + UINode * setBorderRadius( const Uint32 & state, const unsigned int& corners ); - UINode * setBackgroundCorners( const unsigned int& corners ); + UINode * setBorderRadius( const unsigned int& corners ); + + Uint32 getBorderRadius( const Uint32& state ); + + Uint32 getBorderRadius(); UISkin * setForegroundFillEnabled( bool enabled ); @@ -123,9 +127,9 @@ class EE_API UINode : public Node { Color getForegroundColor(); - UINode * setForegroundCorners( const Uint32 & state, const unsigned int& corners ); + UINode * setForegroundRadius( const Uint32 & state, const unsigned int& corners ); - UINode * setForegroundCorners( const unsigned int& corners ); + UINode * setForegroundRadius( const unsigned int& corners ); RectangleDrawable * setBorderEnabled( bool enabled ); diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 9cd2674c7..ed9753d01 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -219,6 +219,7 @@ ../../include/eepp/scene/actions/move.hpp ../../include/eepp/scene/actions/paddingtransition.hpp ../../include/eepp/scene/actions/resize.hpp +../../include/eepp/scene/actions/resizeborderradius.hpp ../../include/eepp/scene/actions/resizeheight.hpp ../../include/eepp/scene/actions/resizewidth.hpp ../../include/eepp/scene/actions/rotate.hpp @@ -645,6 +646,7 @@ ../../src/eepp/scene/actions/move.cpp ../../src/eepp/scene/actions/paddingtransition.cpp ../../src/eepp/scene/actions/resize.cpp +../../src/eepp/scene/actions/resizeborderradius.cpp ../../src/eepp/scene/actions/resizeheight.cpp ../../src/eepp/scene/actions/resizewidth.cpp ../../src/eepp/scene/actions/rotate.cpp diff --git a/src/eepp/core/string.cpp b/src/eepp/core/string.cpp index b62c87c94..82a124e37 100644 --- a/src/eepp/core/string.cpp +++ b/src/eepp/core/string.cpp @@ -220,7 +220,7 @@ void String::insertChar( String& str, const unsigned int& pos, const Uint32& tch str.insert( str.begin() + pos, tchar ); } -void String::strFormat( char * Buffer, int BufferSize, const char * format, ... ) { +void String::formatBuffer( char * Buffer, int BufferSize, const char * format, ... ) { va_list args; va_start( args, format ); #ifdef EE_COMPILER_MSVC @@ -231,7 +231,7 @@ void String::strFormat( char * Buffer, int BufferSize, const char * format, ... va_end( args ); } -std::string String::strFormated( const char * format, ... ) { +std::string String::format( const char * format, ... ) { int n, size = 256; std::string tstr( size, '\0' ); diff --git a/src/eepp/core/version.cpp b/src/eepp/core/version.cpp index 49c35c3ce..5d17f1096 100644 --- a/src/eepp/core/version.cpp +++ b/src/eepp/core/version.cpp @@ -16,7 +16,7 @@ Uint32 Version::getVersionNum() { std::string Version::getVersionName() { Version ver = getVersion(); - return String::strFormated( "eepp version %d.%d.%d", ver.major, ver.minor, ver.patch ); + return String::format( "eepp version %d.%d.%d", ver.major, ver.minor, ver.patch ); } std::string Version::getCodename() { diff --git a/src/eepp/graphics/rectangledrawable.cpp b/src/eepp/graphics/rectangledrawable.cpp index 6addd0db1..8b2024e7e 100644 --- a/src/eepp/graphics/rectangledrawable.cpp +++ b/src/eepp/graphics/rectangledrawable.cpp @@ -40,7 +40,7 @@ void RectangleDrawable::draw() { draw( mPosition ); } -void RectangleDrawable::draw(const Vector2f & position) { +void RectangleDrawable::draw(const Vector2f &) { draw( mPosition, mSize ); } diff --git a/src/eepp/graphics/textureatlasmanager.cpp b/src/eepp/graphics/textureatlasmanager.cpp index 23616d07b..fae8d1295 100644 --- a/src/eepp/graphics/textureatlasmanager.cpp +++ b/src/eepp/graphics/textureatlasmanager.cpp @@ -120,7 +120,7 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con // Test if name starts with 0 - 1 for ( i = 0; i < 2; i++ ) { - search = String::strFormated( "%s%d%s", name.c_str(), i, realext.c_str() ); + search = String::format( "%s%d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) tTextureRegion = getTextureRegionByName( search ); @@ -137,7 +137,7 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con // in case that name doesn't start with 0 - 1, we test with 00 - 01 if ( 0 == t ) { for ( i = 0; i < 2; i++ ) { - search = String::strFormated( "%s%02d%s", name.c_str(), i, realext.c_str() ); + search = String::format( "%s%02d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) tTextureRegion = getTextureRegionByName( search ); @@ -154,7 +154,7 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con // in case that name doesn't start with 00 - 01, we test with 000 - 001 if ( 0 == t ) { for ( i = 0; i < 2; i++ ) { - search = String::strFormated( "%s%03d%s", name.c_str(), i, realext.c_str() ); + search = String::format( "%s%03d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) tTextureRegion = getTextureRegionByName( search ); @@ -170,7 +170,7 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con if ( 0 == t ) { for ( i = 0; i < 2; i++ ) { - search = String::strFormated( "%s%04d%s", name.c_str(), i, realext.c_str() ); + search = String::format( "%s%04d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) tTextureRegion = getTextureRegionByName( search ); @@ -186,7 +186,7 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con if ( 0 == t ) { for ( i = 0; i < 2; i++ ) { - search = String::strFormated( "%s%05d%s", name.c_str(), i, realext.c_str() ); + search = String::format( "%s%05d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) tTextureRegion = getTextureRegionByName( search ); @@ -202,7 +202,7 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con if ( 0 == t ) { for ( i = 0; i < 2; i++ ) { - search = String::strFormated( "%s%06d%s", name.c_str(), i, realext.c_str() ); + search = String::format( "%s%06d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) tTextureRegion = getTextureRegionByName( search ); @@ -224,12 +224,12 @@ std::vector TextureAtlasManager::getTextureRegionsByPattern( con if ( 0 != t ) { do { switch ( t ) { - case 1: search = String::strFormated( "%s%d%s", name.c_str(), c, realext.c_str() ); break; - case 2: search = String::strFormated( "%s%02d%s", name.c_str(), c, realext.c_str() ); break; - case 3: search = String::strFormated( "%s%03d%s", name.c_str(), c, realext.c_str() ); break; - case 4: search = String::strFormated( "%s%04d%s", name.c_str(), c, realext.c_str() ); break; - case 5: search = String::strFormated( "%s%05d%s", name.c_str(), c, realext.c_str() ); break; - case 6: search = String::strFormated( "%s%06d%s", name.c_str(), c, realext.c_str() ); break; + case 1: search = String::format( "%s%d%s", name.c_str(), c, realext.c_str() ); break; + case 2: search = String::format( "%s%02d%s", name.c_str(), c, realext.c_str() ); break; + case 3: search = String::format( "%s%03d%s", name.c_str(), c, realext.c_str() ); break; + case 4: search = String::format( "%s%04d%s", name.c_str(), c, realext.c_str() ); break; + case 5: search = String::format( "%s%05d%s", name.c_str(), c, realext.c_str() ); break; + case 6: search = String::format( "%s%06d%s", name.c_str(), c, realext.c_str() ); break; default: found = false; } diff --git a/src/eepp/maps/tilemap.cpp b/src/eepp/maps/tilemap.cpp index 671bcbb46..695a96917 100644 --- a/src/eepp/maps/tilemap.cpp +++ b/src/eepp/maps/tilemap.cpp @@ -120,7 +120,7 @@ void TileMap::createEmptyTile() { //! I create a texture representing an empty tile to render instead of rendering with primitives because is a lot faster, at least with NVIDIA GPUs. TextureFactory * TF = TextureFactory::instance(); - std::string tileName( String::strFormated( "maptile-%dx%d-%ul", mTileSize.getWidth(), mTileSize.getHeight(), mGridLinesColor.getValue() ) ); + std::string tileName( String::format( "maptile-%dx%d-%ul", mTileSize.getWidth(), mTileSize.getHeight(), mGridLinesColor.getValue() ) ); Texture * Tex = TF->getByName( tileName ); diff --git a/src/eepp/scene/actions/resizeborderradius.cpp b/src/eepp/scene/actions/resizeborderradius.cpp new file mode 100644 index 000000000..167c7260f --- /dev/null +++ b/src/eepp/scene/actions/resizeborderradius.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +using namespace EE::UI; + +namespace EE { namespace Scene { namespace Actions { + +ResizeBorderRadius * ResizeBorderRadius::New( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type ) { + return eeNew( ResizeBorderRadius, ( start, end, duration, type ) ); +} + +ResizeBorderRadius::ResizeBorderRadius() +{} + +ResizeBorderRadius::ResizeBorderRadius( const Float & start, const Float & end, const Time& duration, const Ease::Interpolation& type ) { + mInterpolation.clear().add( start, duration ).add( end ).setType( type ); +} + +void ResizeBorderRadius::onStart() { + onUpdate( Time::Zero ); +} + +void ResizeBorderRadius::onUpdate( const Time& ) { + if ( NULL != mNode && mNode->isWidget() ) { + UIWidget * widget = static_cast( mNode ); + + widget->setBorderRadius( widget->getStyleState(), mInterpolation.getPosition() ); + } +} + +Action * ResizeBorderRadius::clone() const { + ResizeBorderRadius * action = eeNew( ResizeBorderRadius, () ); + action->setInterpolation( mInterpolation ); + return action; +} + +Action * ResizeBorderRadius::reverse() const { + ResizeBorderRadius * action = eeNew( ResizeBorderRadius, () ); + action->setInterpolation( Interpolation1d( mInterpolation.getReversePoints() ) ); + return action; +} + +}}} diff --git a/src/eepp/system/inifile.cpp b/src/eepp/system/inifile.cpp index 052e77484..43720618e 100755 --- a/src/eepp/system/inifile.cpp +++ b/src/eepp/system/inifile.cpp @@ -308,14 +308,14 @@ bool IniFile::setValue ( std::string const keyname, std::string const valuename, bool IniFile::setValueI ( std::string const keyname, std::string const valuename, int const value, bool create ) { char svalue[MAX_VALUEDATA]; - String::strFormat( svalue, MAX_VALUEDATA, "%d", value ); + String::formatBuffer( svalue, MAX_VALUEDATA, "%d", value ); return setValue ( keyname, valuename, svalue, create ); } bool IniFile::setValueF ( std::string const keyname, std::string const valuename, double const value, bool create ) { char svalue[MAX_VALUEDATA]; - String::strFormat ( svalue, MAX_VALUEDATA, "%f", value ); + String::formatBuffer ( svalue, MAX_VALUEDATA, "%f", value ); return setValue ( keyname, valuename, svalue, create ); } @@ -354,7 +354,7 @@ std::string IniFile::getValue ( std::string const keyname, std::string const val int IniFile::getValueI ( std::string const keyname, std::string const valuename, int const defValue ) const { char svalue[MAX_VALUEDATA]; - String::strFormat ( svalue, MAX_VALUEDATA, "%d", defValue ); + String::formatBuffer ( svalue, MAX_VALUEDATA, "%d", defValue ); return atoi ( getValue ( keyname, valuename, svalue ).c_str() ); } @@ -367,7 +367,7 @@ bool IniFile::getValueB(const std::string keyname, const std::string valuename, double IniFile::getValueF ( std::string const keyname, std::string const valuename, double const defValue ) const { char svalue[MAX_VALUEDATA]; - String::strFormat ( svalue, MAX_VALUEDATA, "%f", defValue ); + String::formatBuffer ( svalue, MAX_VALUEDATA, "%f", defValue ); return atof ( getValue ( keyname, valuename, svalue ).c_str() ); } diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 60dacec4e..982e30fcc 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -235,7 +235,7 @@ void UINode::drawDebugData() { UIWidget * me = static_cast( this ); if ( NULL != getEventDispatcher() && getEventDispatcher()->getOverControl() == this ) { - String text( String::strFormated( "X: %2.4f Y: %2.4f\nW: %2.4f H: %2.4f", mDpPos.x, mDpPos.y, mDpSize.x, mDpSize.y ) ); + String text( String::format( "X: %2.4f Y: %2.4f\nW: %2.4f H: %2.4f", mDpPos.x, mDpPos.y, mDpSize.x, mDpSize.y ) ); if ( !mId.empty() ) { text = "ID: " + mId + "\n" + text; @@ -432,7 +432,7 @@ UINode * UINode::setBackgroundColor( const Color& color ) { return setBackgroundColor( UIState::StateFlagNormal, color ); } -UINode * UINode::setBackgroundCorners( const Uint32 & state, const unsigned int& corners ) { +UINode * UINode::setBorderRadius( const Uint32 & state, const unsigned int& corners ) { UISkin * background = setBackgroundFillEnabled( true ); Drawable * stateDrawable = background->getStateDrawable( state ); @@ -452,8 +452,28 @@ UINode * UINode::setBackgroundCorners( const Uint32 & state, const unsigned int& return this; } -UINode * UINode::setBackgroundCorners( const unsigned int& corners ) { - return setBackgroundCorners( UIState::StateFlagNormal, corners ); +Uint32 UINode::getBorderRadius( const Uint32& state ) { + if ( NULL != mBackgroundState && NULL != mBackgroundState->getSkin() ) { + Drawable * stateDrawable = mBackgroundState->getSkin()->getStateDrawable( state ); + + if ( NULL != stateDrawable ) { + if ( stateDrawable->getDrawableType() == Drawable::RECTANGLE ) { + RectangleDrawable * rectangleDrawable = static_cast( stateDrawable ); + + return rectangleDrawable->getCorners(); + } + } + } + + return 0; +} + +Uint32 UINode::getBorderRadius() { + return getBorderRadius( UIState::StateFlagNormal ); +} + +UINode * UINode::setBorderRadius( const unsigned int& corners ) { + return setBorderRadius( UIState::StateFlagNormal, corners ); } UISkin * UINode::setForegroundFillEnabled( bool enabled ) { @@ -506,7 +526,7 @@ UINode * UINode::setForegroundColor( const Color& color ) { return setForegroundColor( UIState::StateFlagNormal, color ); } -UINode * UINode::setForegroundCorners( const Uint32& state, const unsigned int& corners ) { +UINode * UINode::setForegroundRadius( const Uint32& state, const unsigned int& corners ) { UISkin * foreground = setForegroundFillEnabled( true ); Drawable * stateDrawable = foreground->getStateDrawable( state ); @@ -526,8 +546,8 @@ UINode * UINode::setForegroundCorners( const Uint32& state, const unsigned int& return this; } -UINode * UINode::setForegroundCorners( const unsigned int& corners ) { - return setForegroundCorners( UIState::StateFlagNormal, corners ); +UINode * UINode::setForegroundRadius( const unsigned int& corners ) { + return setForegroundRadius( UIState::StateFlagNormal, corners ); } RectangleDrawable * UINode::setBorderEnabled( bool enabled ) { diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 279e14d43..2c4beafe6 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -608,7 +608,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) { UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%.2f", mDpSize.getWidth() ) ); + SAVE_NORMAL_STATE_ATTR( String::format( "%.2f", mDpSize.getWidth() ) ); Action * action = Actions::MoveCoordinate::New( getPosition().x, newX, transitionInfo.duration, transitionInfo.timingFunction, Actions::MoveCoordinate::CoordinateX ); @@ -628,7 +628,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) { UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%.2f", mDpSize.getWidth() ) ); + SAVE_NORMAL_STATE_ATTR( String::format( "%.2f", mDpSize.getWidth() ) ); Action * action = Actions::MoveCoordinate::New( getPosition().y, newY, transitionInfo.duration, transitionInfo.timingFunction, Actions::MoveCoordinate::CoordinateY ); @@ -648,7 +648,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) { UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%.2f", mDpSize.getWidth() ) ); + SAVE_NORMAL_STATE_ATTR( String::format( "%.2f", mDpSize.getWidth() ) ); Action * action = Actions::ResizeWidth::New( getSize().getWidth(), newWidth, transitionInfo.duration, transitionInfo.timingFunction ); @@ -668,7 +668,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) { UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%.2f", mDpSize.getHeight() ) ); + SAVE_NORMAL_STATE_ATTR( String::format( "%.2f", mDpSize.getHeight() ) ); Action * action = Actions::ResizeHeight::New( getSize().getHeight(), newHeight, transitionInfo.duration, transitionInfo.timingFunction ); @@ -732,8 +732,8 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } else { setForegroundColor( state, color ); } - } else if ( "foregroundcorners" == name ) { - setForegroundCorners( state, attribute.asUint() ); + } else if ( "foregroundradius" == name ) { + setForegroundRadius( state, attribute.asUint() ); } else if ( "bordercolor" == name ) { Color color = attribute.asColor(); @@ -754,8 +754,24 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } } else if ( "borderwidth" == name ) { setBorderWidth( attribute.asDpDimensionI("1") ); - } else if ( "bordercorners" == name || "backgroundcorners" == name ) { - setBackgroundCorners( state, attribute.asUint() ); + } else if ( "borderradius" == name || "backgroundcorners" == name ) { + Uint32 borderRadius = attribute.asUint(); + + if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( state, attribute.getName() ) ) { + UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) ); + Uint32 start( getBorderRadius( getStylePreviousState() ) ); + + SAVE_NORMAL_STATE_ATTR( String::format( "%d", start ) ); + + Action * action = Actions::ResizeBorderRadius::New( start, borderRadius, transitionInfo.duration, transitionInfo.timingFunction ); + + if ( Time::Zero != transitionInfo.delay ) + action = Actions::Sequence::New( Actions::Delay::New( transitionInfo.delay ), action ); + + runAction( action ); + } else { + setBorderRadius( state, attribute.asUint() ); + } } else if ( "visible" == name ) { setVisible( attribute.asBool() ); } else if ( "enabled" == name ) { @@ -864,15 +880,15 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state NodeAttribute oldAttribute = mStyle->getAttribute( UIState::StateFlagNormal, attribute.getName() ); if ( oldAttribute.isEmpty() && mStyle->getPreviousState() == UIState::StateFlagNormal ) { if ( "layout_margin" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%d %d %d %d", mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d %d %d %d", mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) ) ); else if ( "layout_marginleft" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%d", mLayoutMargin.Left ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Left ) ) ); else if ( "layout_marginright" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%d", mLayoutMargin.Right ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Right ) ) ); else if ( "layout_margintop" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%d", mLayoutMargin.Top ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Top ) ) ); else if ( "layout_marginbottom" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%d", mLayoutMargin.Bottom ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%d", mLayoutMargin.Bottom ) ) ); } if ( Time::Zero != transitionInfo.delay ) @@ -977,7 +993,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state Float newRotation( mStyle->getAttribute( state, attribute.getName() ).asFloat() ); Action * action = Actions::Rotate::New( mRotation, newRotation, transitionInfo.duration, transitionInfo.timingFunction ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%2.f", mRotation ) ) + SAVE_NORMAL_STATE_ATTR( String::format( "%2.f", mRotation ) ) if ( Time::Zero != transitionInfo.delay ) action = Actions::Sequence::New( Actions::Delay::New( transitionInfo.delay ), action ); @@ -992,7 +1008,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state Vector2f newScale( mStyle->getAttribute( state, attribute.getName() ).asVector2f() ); Action * action = Actions::Scale::New( mScale, newScale, transitionInfo.duration, transitionInfo.timingFunction ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%2.f, %2.f", mScale.x, mScale.y ) ) + SAVE_NORMAL_STATE_ATTR( String::format( "%2.f, %2.f", mScale.x, mScale.y ) ) if ( Time::Zero != transitionInfo.delay ) action = Actions::Sequence::New( Actions::Delay::New( transitionInfo.delay ), action ); @@ -1028,15 +1044,15 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state NodeAttribute oldAttribute = mStyle->getAttribute( UIState::StateFlagNormal, attribute.getName() ); if ( oldAttribute.isEmpty() && mStyle->getPreviousState() == UIState::StateFlagNormal ) { if ( "padding" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%2.f %2.f %2.f %2.f", mPadding.Left, mPadding.Top, mPadding.Right, mPadding.Bottom ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f %2.f %2.f %2.f", mPadding.Left, mPadding.Top, mPadding.Right, mPadding.Bottom ) ) ); else if ( "paddingleft" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%2.f", mPadding.Left ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Left ) ) ); else if ( "paddingright" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%2.f", mPadding.Right ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Right ) ) ); else if ( "paddingtop" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%2.f", mPadding.Top ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Top ) ) ); else if ( "paddingbottom" == name ) - mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::strFormated( "%2.f", mPadding.Bottom ) ) ); + mStyle->addAttribute( UIState::StateFlagNormal, NodeAttribute( attribute.getName(), String::format( "%2.f", mPadding.Bottom ) ) ); } if ( Time::Zero != transitionInfo.delay ) @@ -1053,7 +1069,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( state, attribute.getName() ) ); Action * action = Actions::Fade::New( mAlpha, alpha, transitionInfo.duration, transitionInfo.timingFunction ); - SAVE_NORMAL_STATE_ATTR( String::strFormated( "%2.f", mAlpha ) ) + SAVE_NORMAL_STATE_ATTR( String::format( "%2.f", mAlpha ) ) if ( Time::Zero != transitionInfo.delay ) action = Actions::Sequence::New( Actions::Delay::New( transitionInfo.delay ), action ); diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index 8a60e241a..dec67c8ff 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -259,7 +259,7 @@ std::string WindowSDL::getVersion() { SDL_GetVersion( &ver ); - return String::strFormated( "SDL %d.%d.%d", ver.major, ver.minor, ver.patch ); + return String::format( "SDL %d.%d.%d", ver.major, ver.minor, ver.patch ); } void WindowSDL::createPlatform() { diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index 6b19274f9..8dbf08dfa 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -266,7 +266,7 @@ bool Window::takeScreenshot(std::string filepath, const Image::SaveType & Format Ext = "." + Image::saveTypeToExtension( Format ); while ( !find && FileNum < 10000 ) { - TmpPath = String::strFormated( "%s%05d%s", filepath.c_str(), FileNum, Ext.c_str() ); + TmpPath = String::format( "%s%05d%s", filepath.c_str(), FileNum, Ext.c_str() ); FileNum++; diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 611b54050..97cce7f1f 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -1663,7 +1663,7 @@ void EETest::render() { if ( Sys::getTicks() - lasttick >= 50 ) { lasttick = Sys::getTicks(); #ifdef EE_DEBUG - mInfo = String::strFormated( "EE - FPS: %d Frame Time: %4.2f\nMouse X: %d Mouse Y: %d\nTexture Memory Usage: %s\nApp Memory Usage: %s\nApp Peak Memory Usage: %s", + mInfo = String::format( "EE - FPS: %d Frame Time: %4.2f\nMouse X: %d Mouse Y: %d\nTexture Memory Usage: %s\nApp Memory Usage: %s\nApp Peak Memory Usage: %s", mWindow->getFPS(), et.asMilliseconds(), (Int32)Mouse.x,