Fixed some bugs, added rounder rectangles.

This commit is contained in:
spartanj
2010-06-30 23:35:28 -03:00
parent c00a979022
commit 0048fa6dfb
22 changed files with 798 additions and 436 deletions

View File

@@ -2,24 +2,72 @@
namespace EE { namespace UI {
cUIBackground::cUIBackground() :
mColor( 0xFF404040 ),
mBlendMode( ALPHA_NORMAL )
cUIBackground::cUIBackground() :
mBlendMode( ALPHA_NORMAL ),
mCorners(0)
{
mColor.push_back( eeColorA(0xFF404040) );
}
cUIBackground::cUIBackground( const cUIBackground& Back ) :
mColor( Back.Color() ),
mBlendMode( ALPHA_NORMAL )
cUIBackground::cUIBackground( const cUIBackground& Back ) :
mBlendMode( ALPHA_NORMAL ),
mCorners( Back.Corners() )
{
cUIBackground * b = const_cast<cUIBackground *> ( &Back ); // cheating
mColor = b->Colors();
}
const eeColorA& cUIBackground::Color() const {
cUIBackground::cUIBackground( const eeColorA& Color, const eeUint& Corners, const EE_RENDERALPHAS& BlendMode ) :
mBlendMode( BlendMode ),
mCorners( Corners )
{
mColor.push_back( Color );
}
cUIBackground::cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_RENDERALPHAS& BlendMode ) :
mBlendMode( BlendMode ),
mCorners( Corners )
{
Colors( TopLeftColor, BottomLeftColor, BottomRightColor, TopRightColor );
}
eeColorA& cUIBackground::Color( const eeUint& index ) {
if ( index < mColor.size() )
return mColor[ index ];
return mColor[ 0 ];
}
void cUIBackground::ColorsTo( const eeColorA& Color ) {
for ( eeUint i = 0; i < mColor.size(); i++ )
mColor[i] = Color;
}
void cUIBackground::Colors( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor ) {
mColor[0] = TopLeftColor;
if ( mColor.size() < 2 )
mColor.push_back( BottomLeftColor );
else
mColor[1] = BottomLeftColor;
if ( mColor.size() < 3 )
mColor.push_back( BottomRightColor );
else
mColor[2] = BottomRightColor;
if ( mColor.size() < 4 )
mColor.push_back( TopRightColor );
else
mColor[3] = TopRightColor;
}
const std::vector<eeColorA>& cUIBackground::Colors() {
return mColor;
}
void cUIBackground::Color( const eeColorA& Col ) {
mColor = Col;
mColor[0] = Col;
}
const EE_RENDERALPHAS& cUIBackground::Blend() const {
@@ -30,4 +78,12 @@ void cUIBackground::Blend( const EE_RENDERALPHAS& blend ) {
mBlendMode = blend;
}
const eeUint& cUIBackground::Corners() const {
return mCorners;
}
void cUIBackground::Corners( const eeUint& corners ) {
mCorners = corners;
}
}}

View File

@@ -4,22 +4,36 @@
#include "base.hpp"
namespace EE { namespace UI {
class cUIBackground {
public:
cUIBackground();
cUIBackground( const eeColorA& Color, const eeUint& Corners = 0, const EE_RENDERALPHAS& BlendMode = ALPHA_NORMAL );
cUIBackground( const cUIBackground& Back );
cUIBackground( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor, const eeUint& Corners, const EE_RENDERALPHAS& BlendMode );
eeColorA& Color( const eeUint& index = 0 );
const eeColorA& Color() const;
void Color( const eeColorA& Col );
const std::vector<eeColorA>& Colors();
void Colors( const eeColorA& TopLeftColor, const eeColorA& BottomLeftColor, const eeColorA& BottomRightColor, const eeColorA& TopRightColor );
void ColorsTo( const eeColorA& Color );
const EE_RENDERALPHAS& Blend() const;
void Blend( const EE_RENDERALPHAS& blend );
const eeUint& Corners() const;
void Corners( const eeUint& corners );
protected:
eeColorA mColor;
EE_RENDERALPHAS mBlendMode;
std::vector<eeColorA> mColor;
EE_RENDERALPHAS mBlendMode;
eeUint mCorners;
};
}}
#endif
#endif

View File

@@ -405,7 +405,12 @@ void cUIControl::BackgroundDraw() {
cPrimitives P;
P.SetColor( mBackground.Color() );
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_FILL, mBackground.Blend() );
if ( 4 == mBackground.Colors().size() ) {
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), mBackground.Colors()[0], mBackground.Colors()[1], mBackground.Colors()[2], mBackground.Colors()[3], 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() );
} else {
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() );
}
}
void cUIControl::BorderDraw() {
@@ -414,7 +419,7 @@ void cUIControl::BorderDraw() {
cPrimitives P;
P.SetColor( mBorder.Color() );
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_LINE, mBlend, (eeFloat)mBorder.Width() );
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() );
}
const Uint32& cUIControl::ControlFlags() const {

View File

@@ -25,14 +25,19 @@ class EE_API cUIControl {
const eeVector2i& pos = eeVector2i( 0, 0 ),
const eeSize& size = eeSize( -1, -1 ),
const Uint32& flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER,
const EE_RENDERALPHAS& blend = ALPHA_NORMAL
const EE_RENDERALPHAS& blend = ALPHA_NORMAL,
const cUIBackground& Back = cUIBackground(),
const cUIBorder& Bord = cUIBorder()
) :
ParentCtrl( parentCtrl ),
Pos( pos ),
Size( size ),
Flags( flags ),
Blend( blend )
{}
{
Background = Back;
Border = Bord;
}
CreateParams() {
ParentCtrl = NULL;

View File

@@ -204,7 +204,12 @@ void cUIControlAnim::BackgroundDraw() {
cPrimitives P;
P.SetColor( GetColor( mBackground.Color() ) );
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_FILL, mBackground.Blend() );
if ( 4 == mBackground.Colors().size() ) {
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), GetColor( mBackground.Colors()[0] ), GetColor( mBackground.Colors()[1] ), GetColor( mBackground.Colors()[2] ), GetColor( mBackground.Colors()[3] ), 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() );
} else {
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_FILL, mBackground.Blend(), 1.0f, mBackground.Corners() );
}
}
void cUIControlAnim::BorderDraw() {
@@ -213,7 +218,7 @@ void cUIControlAnim::BorderDraw() {
cPrimitives P;
P.SetColor( GetColor( mBorder.Color() ) );
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_LINE, mBlend, (eeFloat)mBorder.Width() );
P.DrawRectangle( (eeFloat)Pos.x, (eeFloat)Pos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, DRAW_LINE, mBlend, (eeFloat)mBorder.Width(), mBackground.Corners() );
}
eeColorA cUIControlAnim::GetColor( const eeColorA& Col ) {