Minor clean up.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-03-21 23:34:50 -03:00
parent d1edfcf705
commit ca9950b282
17 changed files with 96 additions and 71 deletions

View File

@@ -13,4 +13,4 @@ JoystickEnabled = 0
ParticlesNum = 1000
UseShaders = 1
Music = 0
PixelDensity = 1
PixelDensity = 2

View File

@@ -7,28 +7,27 @@ namespace EE { namespace UI {
class EE_API UIBackground {
public:
static UIBackground * New();
UIBackground();
UIBackground( const ColorA& color, const unsigned int& corners = 0, const EE_BLEND_MODE& BlendMode = ALPHA_NORMAL );
UIBackground( const UIBackground& Back );
UIBackground( const ColorA& TopLeftColor, const ColorA& BottomLeftColor, const ColorA& BottomRightColor, const ColorA& TopRightColor, const unsigned int& corners, const EE_BLEND_MODE& BlendMode );
ColorA& getColor( const unsigned int& index = 0 );
void setColor( const ColorA& Col );
UIBackground * setColor( const ColorA& Col );
const std::vector<ColorA>& getColors();
void setColors( const ColorA& TopLeftColor, const ColorA& BottomLeftColor, const ColorA& BottomRightColor, const ColorA& TopRightColor );
UIBackground * setColors( const ColorA& TopLeftColor, const ColorA& BottomLeftColor, const ColorA& BottomRightColor, const ColorA& TopRightColor );
void setColorsTo( const ColorA& color );
UIBackground * setColorsTo( const ColorA& color );
const EE_BLEND_MODE& getBlendMode() const;
void setBlendMode( const EE_BLEND_MODE& blend );
UIBackground * setBlendMode( const EE_BLEND_MODE& blend );
const unsigned int& getCorners() const;
void setCorners( const unsigned int& corners );
UIBackground * setCorners( const unsigned int& corners );
protected:
std::vector<ColorA> mColor;

View File

@@ -7,16 +7,17 @@ namespace EE { namespace UI {
class EE_API UIBorder {
public:
static UIBorder * New();
UIBorder();
UIBorder( const UIBorder& border );
const ColorA& getColor() const;
void setColor( const ColorA& Col );
UIBorder * setColor( const ColorA& Col );
const unsigned int& getWidth() const;
void setWidth( const unsigned int& width );
UIBorder * setWidth( const unsigned int& width );
protected:
ColorA mColor;
unsigned int mWidth;

View File

@@ -12,6 +12,8 @@ namespace EE { namespace UI {
class EE_API UISkinComplex : public UISkin {
public:
static UISkinComplex * New( const std::string& name );
static std::string getSideSuffix( const Uint32& Side );
enum UISkinComplexSides {
@@ -27,7 +29,7 @@ class EE_API UISkinComplex : public UISkin {
SideCount
};
UISkinComplex( const std::string& getName );
UISkinComplex( const std::string& name );
virtual ~UISkinComplex();

View File

@@ -12,7 +12,9 @@ namespace EE { namespace UI {
class EE_API UISkinSimple : public UISkin {
public:
UISkinSimple( const std::string& getName );
static UISkinSimple * New( const std::string& name );
UISkinSimple( const std::string& name );
virtual ~UISkinSimple();
@@ -39,4 +41,3 @@ class EE_API UISkinSimple : public UISkin {
}}
#endif

View File

@@ -19,6 +19,8 @@ class EE_API UISkinState {
StateCount
};
static UISkinState * New( UISkin * skin );
UISkinState( UISkin * Skin );
~UISkinState();

View File

@@ -23,6 +23,8 @@ class EE_API UITheme : protected ResourceManager<UISkin> {
using ResourceManager<UISkin>::exists;
using ResourceManager<UISkin>::existsId;
static UITheme * New( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL );
static UITheme * loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtlas * getTextureAtlas );
static UITheme * loadFromFile( UITheme * tTheme, const std::string& Path, const std::string ImgExt = "png" );

View File

@@ -7,6 +7,8 @@ namespace EE { namespace UI {
class EE_API UIThemeDefault : public UITheme {
public:
static UIThemeDefault * New( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL );
UIThemeDefault( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL );
UITabWidgetStyleConfig getTabWidgetStyleConfig();

View File

@@ -2,6 +2,10 @@
namespace EE { namespace UI {
UIBackground * UIBackground::New() {
return eeNew( UIBackground, () );
}
UIBackground::UIBackground() :
mBlendMode( ALPHA_NORMAL ),
mCorners(0)
@@ -9,28 +13,6 @@ UIBackground::UIBackground() :
mColor.push_back( ColorA(0xFF404040) );
}
UIBackground::UIBackground( const UIBackground& Back ) :
mBlendMode( ALPHA_NORMAL ),
mCorners( Back.getCorners() )
{
UIBackground * b = const_cast<UIBackground *> ( &Back ); // cheating
mColor = b->getColors();
}
UIBackground::UIBackground( const ColorA& Color, const unsigned int& Corners, const EE_BLEND_MODE& BlendMode ) :
mBlendMode( BlendMode ),
mCorners( Corners )
{
mColor.push_back( Color );
}
UIBackground::UIBackground( const ColorA& TopLeftColor, const ColorA& BottomLeftColor, const ColorA& BottomRightColor, const ColorA& TopRightColor, const unsigned int& Corners, const EE_BLEND_MODE& BlendMode ) :
mBlendMode( BlendMode ),
mCorners( Corners )
{
setColors( TopLeftColor, BottomLeftColor, BottomRightColor, TopRightColor );
}
ColorA& UIBackground::getColor( const unsigned int& index ) {
if ( index < mColor.size() )
return mColor[ index ];
@@ -38,12 +20,14 @@ ColorA& UIBackground::getColor( const unsigned int& index ) {
return mColor[ 0 ];
}
void UIBackground::setColorsTo( const ColorA& Color ) {
UIBackground * UIBackground::setColorsTo( const ColorA& Color ) {
for ( unsigned int i = 0; i < mColor.size(); i++ )
mColor[i] = Color;
return this;
}
void UIBackground::setColors( const ColorA& TopLeftColor, const ColorA& BottomLeftColor, const ColorA& BottomRightColor, const ColorA& TopRightColor ) {
UIBackground * UIBackground::setColors( const ColorA& TopLeftColor, const ColorA& BottomLeftColor, const ColorA& BottomRightColor, const ColorA& TopRightColor ) {
mColor[0] = TopLeftColor;
if ( mColor.size() < 2 )
@@ -60,30 +44,35 @@ void UIBackground::setColors( const ColorA& TopLeftColor, const ColorA& BottomLe
mColor.push_back( TopRightColor );
else
mColor[3] = TopRightColor;
return this;
}
const std::vector<ColorA>& UIBackground::getColors() {
return mColor;
}
void UIBackground::setColor( const ColorA& Col ) {
UIBackground * UIBackground::setColor( const ColorA& Col ) {
mColor[0] = Col;
return this;
}
const EE_BLEND_MODE& UIBackground::getBlendMode() const {
return mBlendMode;
}
void UIBackground::setBlendMode( const EE_BLEND_MODE& blend ) {
UIBackground * UIBackground::setBlendMode( const EE_BLEND_MODE& blend ) {
mBlendMode = blend;
return this;
}
const unsigned int& UIBackground::getCorners() const {
return mCorners;
}
void UIBackground::setCorners( const unsigned int& corners ) {
UIBackground * UIBackground::setCorners( const unsigned int& corners ) {
mCorners = corners;
return this;
}
}}

View File

@@ -2,23 +2,31 @@
namespace EE { namespace UI {
UIBorder::UIBorder() : mColor( 0xFF404040 ), mWidth( 1 ) {}
UIBorder::UIBorder( const UIBorder& border ) : mColor( border.getColor() ), mWidth( border.getWidth() ) {}
UIBorder * UIBorder::New() {
return eeNew( UIBorder, () );
}
UIBorder::UIBorder() :
mColor( ColorA::Black ),
mWidth( 1 )
{}
const ColorA& UIBorder::getColor() const {
return mColor;
}
void UIBorder::setColor( const ColorA& Col ) {
UIBorder * UIBorder::setColor( const ColorA& Col ) {
mColor = Col;
return this;
}
const unsigned int& UIBorder::getWidth() const {
return mWidth;
}
void UIBorder::setWidth( const unsigned int& width ) {
UIBorder * UIBorder::setWidth( const unsigned int& width ) {
mWidth = width;
return this;
}
}}

View File

@@ -557,7 +557,7 @@ UIBackground * UIControl::setBackgroundFillEnabled( bool enabled ) {
writeFlag( UI_FILL_BACKGROUND, enabled ? 1 : 0 );
if ( enabled && NULL == mBackground ) {
mBackground = eeNew( UIBackground, () );
mBackground = UIBackground::New();
}
return mBackground;
@@ -567,10 +567,10 @@ UIBorder * UIControl::setBorderEnabled( bool enabled ) {
writeFlag( UI_BORDER, enabled ? 1 : 0 );
if ( enabled && NULL == mBorder ) {
mBorder = eeNew( UIBorder, () );
mBorder = UIBorder::New();
if ( NULL == mBackground ) {
mBackground = eeNew( UIBackground, () );
mBackground = UIBackground::New();
}
}
@@ -606,10 +606,10 @@ const Uint32& UIControl::getFlags() const {
UIControl * UIControl::setFlags( const Uint32& flags ) {
if ( NULL == mBackground && ( flags & UI_FILL_BACKGROUND ) )
mBackground = eeNew( UIBackground, () );
mBackground = UIBackground::New();
if ( NULL == mBorder && ( flags & UI_BORDER ) )
mBorder = eeNew( UIBorder, () );
mBorder = UIBorder::New();
if ( fontHAlignGet( flags ) || fontVAlignGet( flags ) ) {
onAlignChange();
@@ -720,7 +720,6 @@ void UIControl::drawBorder() {
P.setLineWidth( PixelDensity::dpToPx( mBorder->getWidth() ) );
P.setColor( mBorder->getColor() );
//! @TODO: Check why was this +0.1f -0.1f?
if ( mFlags & UI_CLIP_ENABLE ) {
Rectf R( Vector2f( mScreenPosf.x + 0.1f, mScreenPosf.y + 0.1f ), Sizef( (Float)mRealSize.getWidth() - 0.1f, (Float)mRealSize.getHeight() - 0.1f ) );
@@ -1190,7 +1189,7 @@ void UIControl::sendEvent( const UIEvent * Event ) {
UIBackground * UIControl::getBackground() {
if ( NULL == mBackground ) {
mBackground = eeNew( UIBackground, () );
mBackground = UIBackground::New();
}
return mBackground;
@@ -1198,7 +1197,7 @@ UIBackground * UIControl::getBackground() {
UIBorder * UIControl::getBorder() {
if ( NULL == mBorder ) {
mBorder = eeNew( UIBorder, () );
mBorder = UIBorder::New();
}
return mBorder;
@@ -1229,7 +1228,7 @@ UIControl * UIControl::setThemeControl( UITheme * Theme, const std::string& Cont
removeSkin();
mSkinState = eeNew( UISkinState, ( tSkin ) );
mSkinState = UISkinState::New( tSkin );
mSkinState->setState( InitialState );
onThemeLoaded();
@@ -1246,7 +1245,7 @@ void UIControl::setSkin( const UISkin& Skin ) {
UISkin * SkinCopy = const_cast<UISkin*>( &Skin )->clone();
mSkinState = eeNew( UISkinState, ( SkinCopy ) );
mSkinState = UISkinState::New( SkinCopy );
onThemeLoaded();
}
@@ -1264,7 +1263,7 @@ UIControl * UIControl::setSkin( UISkin * skin ) {
removeSkin();
mSkinState = eeNew( UISkinState, ( skin ) );
mSkinState = UISkinState::New( skin );
mSkinState->setState( InitialState );
onThemeLoaded();

View File

@@ -8,14 +8,18 @@ static const char SideSuffix[ UISkinComplex::SideCount ][4] = {
"ml", "mr","d","u","ul","ur","dl","dr","m"
};
UISkinComplex *UISkinComplex::New(const std::string & name) {
return eeNew( UISkinComplex, ( name ) );
}
std::string UISkinComplex::getSideSuffix( const Uint32& Side ) {
eeASSERT( Side < UISkinComplex::SideCount );
return std::string( SideSuffix[ Side ] );
}
UISkinComplex::UISkinComplex( const std::string& Name ) :
UISkin( Name, SkinComplex )
UISkinComplex::UISkinComplex(const std::string& name ) :
UISkin( name, SkinComplex )
{
for ( Int32 x = 0; x < UISkinState::StateCount; x++ )
for ( Int32 y = 0; y < SideCount; y++ )
@@ -194,7 +198,7 @@ void UISkinComplex::stateNormalToState( const Uint32& State ) {
}
UISkinComplex * UISkinComplex::clone( const std::string& NewName, const bool& CopyColorsState ) {
UISkinComplex * SkinC = eeNew( UISkinComplex, ( NewName ) );
UISkinComplex * SkinC = UISkinComplex::New( NewName );
if ( CopyColorsState ) {
SkinC->mColorDefault = mColorDefault;

View File

@@ -4,8 +4,12 @@
namespace EE { namespace UI {
UISkinSimple::UISkinSimple( const std::string& Name ) :
UISkin( Name, SkinSimple )
UISkinSimple * UISkinSimple::New( const std::string& name ) {
return eeNew( UISkinSimple, ( name ) );
}
UISkinSimple::UISkinSimple(const std::string& name ) :
UISkin( name, SkinSimple )
{
for ( Int32 i = 0; i < UISkinState::StateCount; i++ )
mDrawable[ i ] = NULL;
@@ -52,7 +56,7 @@ void UISkinSimple::stateNormalToState( const Uint32& State ) {
}
UISkinSimple * UISkinSimple::clone( const std::string& NewName, const bool& CopyColorsState ) {
UISkinSimple * SkinS = eeNew( UISkinSimple, ( NewName ) );
UISkinSimple * SkinS = UISkinSimple::New( NewName );
if ( CopyColorsState ) {
SkinS->mColorDefault = mColorDefault;

View File

@@ -3,6 +3,10 @@
namespace EE { namespace UI {
UISkinState *UISkinState::New( UISkin * skin ) {
return eeNew( UISkinState, ( skin ) );
}
UISkinState::UISkinState( UISkin * Skin ) :
mSkin( Skin ),
mCurState(0),

View File

@@ -124,6 +124,10 @@ void UITheme::addThemeIcon( const std::string& Icon ) {
mUIIcons.push_back( Icon );
}
UITheme * UITheme::New( const std::string & name, const std::string & abbr, Font * defaultFont ) {
return eeNew( UITheme, ( name, abbr, defaultFont ) );
}
UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtlas * TextureAtlas ) {
eeASSERT( NULL != tTheme && NULL != TextureAtlas );
@@ -159,9 +163,9 @@ UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtla
for ( i = 0; i < ElemFound.size(); i++ ) {
if ( ElemType[i] )
tTheme->add( eeNew( UISkinComplex, ( ElemFound[i] ) ) );
tTheme->add( UISkinComplex::New( ElemFound[i] ) );
else
tTheme->add( eeNew( UISkinSimple, ( ElemFound[i] ) ) );
tTheme->add( UISkinSimple::New( ElemFound[i] ) );
}
eePRINTL( "UI Theme Loaded in: %4.3f ms ( from TextureAtlas )", TE.getElapsed().asMilliseconds() );
@@ -222,9 +226,9 @@ UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path, cons
for ( i = 0; i < ElemFound.size(); i++ ) {
if ( ElemType[i] )
tTheme->add( eeNew( UISkinComplex, ( ElemFound[i] ) ) );
tTheme->add( UISkinComplex::New( ElemFound[i] ) );
else
tTheme->add( eeNew( UISkinSimple, ( ElemFound[i] ) ) );
tTheme->add( UISkinSimple::New( ElemFound[i] ) );
}
eePRINTL( "UI Theme Loaded in: %4.3f ms ( from path )", TE.getElapsed().asMilliseconds() );
@@ -233,11 +237,11 @@ UITheme * UITheme::loadFromFile( UITheme * tTheme, const std::string& Path, cons
}
UITheme * UITheme::loadFromFile( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt ) {
return loadFromFile( eeNew( UITheme, ( Name, NameAbbr ) ), Path, ImgExt );
return loadFromFile( UITheme::New( Name, NameAbbr ), Path, ImgExt );
}
UITheme * UITheme::loadFromTextureAtlas( Graphics::TextureAtlas * TextureAtlas, const std::string& Name, const std::string NameAbbr ) {
return loadFromTextureAtlas( eeNew( UITheme, ( Name, NameAbbr ) ), TextureAtlas );
return loadFromTextureAtlas( UITheme::New( Name, NameAbbr ), TextureAtlas );
}
bool UITheme::searchFilesInAtlas( Graphics::TextureAtlas * SG, std::string Element, Uint32& IsComplex ) {

View File

@@ -9,6 +9,10 @@
namespace EE { namespace UI {
UIThemeDefault * UIThemeDefault::New( const std::string & name, const std::string & abbr, Font * defaultFont ) {
return eeNew( UIThemeDefault, ( name, abbr, defaultFont ) );
}
UIThemeDefault::UIThemeDefault( const std::string& name, const std::string& Abbr, Graphics::Font * defaultFont ) :
UITheme( name, Abbr, defaultFont )
{

View File

@@ -286,11 +286,11 @@ void EETest::createUI() {
//UI_MAN_OPS = UI_MANAGER_HIGHLIGHT_FOCUS | UI_MANAGER_HIGHLIGHT_OVER | UI_MANAGER_DRAW_DEBUG_DATA | UI_MANAGER_DRAW_BOXES;
UIManager::instance()->init(UI_MAN_OPS);
//mTheme = UITheme::loadFromFile( eeNew( UIThemeDefault, ( mThemeName, mThemeName ) ), MyPath + mThemeName + "/" );
//mTheme = UITheme::loadFromFile( UIThemeDefault::New( mThemeName, mThemeName ), MyPath + mThemeName + "/" );
TextureAtlasLoader tgl( MyPath + "ui/" + mThemeName + EE_TEXTURE_ATLAS_EXTENSION );
mTheme = UITheme::loadFromTextureAtlas( eeNew( UIThemeDefault, ( mThemeName, mThemeName ) ), TextureAtlasManager::instance()->getByName( mThemeName ) );
mTheme = UITheme::loadFromTextureAtlas( UIThemeDefault::New( mThemeName, mThemeName ), TextureAtlasManager::instance()->getByName( mThemeName ) );
UIThemeManager::instance()->add( mTheme );
UIThemeManager::instance()->setDefaultEffectsEnabled( true );