diff --git a/include/eepp/graphics/cimage.hpp b/include/eepp/graphics/cimage.hpp index 34614c58b..5d119cb1a 100644 --- a/include/eepp/graphics/cimage.hpp +++ b/include/eepp/graphics/cimage.hpp @@ -3,6 +3,9 @@ #include +#include +using namespace EE::Math; + #include #include #include @@ -102,7 +105,10 @@ class EE_API cImage { void ClearCache(); /** @return The Image Size on Memory (in bytes) */ - eeUint Size() const; + eeUint MemSize() const; + + /** @return The image dimensions */ + eeSize Size(); /** Save the Image to a new File in a specific format */ virtual bool SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format ); diff --git a/include/eepp/graphics/cprimitives.hpp b/include/eepp/graphics/cprimitives.hpp index e1254a269..a0bcd2f9d 100755 --- a/include/eepp/graphics/cprimitives.hpp +++ b/include/eepp/graphics/cprimitives.hpp @@ -2,9 +2,6 @@ #define EE_GRAPHICSCPRIMITIVES_H #include -#include -#include -#include namespace EE { namespace Graphics { @@ -15,172 +12,53 @@ class EE_API cPrimitives { ~cPrimitives(); - /** Draw a Line on screen - * @param x First point x axis - * @param y First point y axis - * @param x2 Second Point x axis - * @param y2 Second Point y axis - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawLine(const eeFloat& x, const eeFloat& y, const eeFloat& x2, const eeFloat& y2, const eeFloat& lineWidth = 1.0f); - - /** Draw a Line on screen - * @param p1 First Point - * @param p2 Second Point - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawLine(const eeVector2f& p1, const eeVector2f& p2, const eeFloat& lineWidth = 1.0f); - - /** Draw a point on the screen - * @param x Point x axis - * @param y Point y axis - * @param pointSize Point Size (default 1.0f ) - */ - void DrawPoint(const eeFloat& x, const eeFloat& y, const eeFloat& pointSize = 1.0f); - /** Draw a point on the screen * @param p The coordinates * @param pointSize Point Size (default 1.0f ) */ - void DrawPoint(const eeVector2f& p, const eeFloat& pointSize = 1.0f); + void DrawPoint( const eeVector2f& p, const eeFloat& pointSize = 1.0f ); + + /** Draw a Line on screen + * @param line The line + */ + void DrawLine( const eeLine2f& line ); /** Draw a circle on the screen * @param p The coordinates ( x and y represents the center of the circle ) * @param radius The Circle Radius * @param points Number of points to represent the circle - * @param fillmode Draw filled or only lines - * @param lineWidth The line width ( default 1.0f ) */ - void DrawCircle(const eeVector2f& p, const eeFloat& radius, Uint32 points = 360, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const eeFloat& lineWidth = 1.0f); - - /** Draw a circle on the screen - * @param x Point x axis - * @param y Point y axis - * @param radius The Circle Radius - * @param points Number of points to represent the circle - * @param fillmode Draw filled or only lines - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawCircle(const eeFloat& x, const eeFloat& y, const eeFloat& radius, Uint32 points = 360, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const eeFloat& lineWidth = 1.0f); - - /** Draw a triangle on the screen - * @param x1 First Point x axis - * @param y1 First Point y axis - * @param x2 Second Point x axis - * @param y2 Second Point y axis - * @param x3 Third Point x axis - * @param y3 Third Point y axis - * @param Color1 First Point Color - * @param Color2 Second Point Color - * @param Color3 Third Point Color - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); - - /** Draw a triangle on the screen - * @param x1 First Point x axis - * @param y1 First Point y axis - * @param x2 Second Point x axis - * @param y2 Second Point y axis - * @param x3 Third Point x axis - * @param y3 Third Point y axis - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); - - /** Draw a triangle on the screen - * @param p1 First Point axis - * @param p2 Second Point axis - * @param p3 Third Point axis - * @param Color1 First Point Color - * @param Color2 Second Point Color - * @param Color3 Third Point Color - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); - - /** Draw a triangle on the screen - * @param p1 First Point axis - * @param p2 Second Point axis - * @param p3 Third Point axis - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawCircle( const eeVector2f& p, const eeFloat& radius, Uint32 points = 360 ); /** Draw a triangle on the screen * @param t The Triangle (eeTriangle2f) - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawTriangle( const eeTriangle2f& t ); - /** Draw a triangle on the screen + /** Draw a triangle on the screen setting per vertex color * @param t The Triangle (eeTriangle2f) * @param Color1 First Point Color * @param Color2 Second Point Color * @param Color3 Third Point Color - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) */ - void DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); - - /** Draw a rectangle on the screen - * @param x Screen x axis - * @param y Screen y axis - * @param width Rectangle Width - * @param height Rectangle Height - * @param Angle Rectangle Angle - * @param Scale Rectangle Scale ( default 1.0f ) - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); - - void DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); - - /** Draw a rectangle on the screen - * @param x Screen x axis - * @param y Screen y axis - * @param width Rectangle Width - * @param height Rectangle Height - * @param TopLeft The Top Left Rectangle Color - * @param BottomLeft The Bottom Left Rectangle Color - * @param BottomRight The Bottom Right Rectangle Color - * @param TopRight The Top Right Rectangle Color - * @param Angle Rectangle Angle - * @param Scale Rectangle Scale ( default 1.0f ) - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); - - void DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); + void DrawTriangle( const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3 ); /** Draw a rectangle on the screen * @param R The Rectangle eeRectf * @param Angle Rectangle Angle * @param Scale Rectangle Scale ( default 1.0f ) - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) */ - void DrawRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); + void DrawRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1 ); - void DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); + /** Draw a rounded rectangle on the screen + * @param R The Rectangle eeRectf + * @param Angle Rectangle Angle + * @param Scale Rectangle Scale ( default 1.0f ) + * @param Corners Number of vertices per corner ( how rounded is each corner ) + */ + void DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const eeUint& Corners = 8 ); - /** Draw a rectangle on the screen + /** Draw a rectangle on the screen setting per vertex color * @param R The Rectangle eeRectf * @param TopLeft The Top Left Rectangle Color * @param BottomLeft The Bottom Left Rectangle Color @@ -188,89 +66,43 @@ class EE_API cPrimitives { * @param TopRight The Top Right Rectangle Color * @param Angle Rectangle Angle * @param Scale Rectangle Scale ( default 1.0f ) - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) */ - void DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 0 ); + void DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1 ); - void DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeUint& Corners = 8 ); - - /** Draw a four edges polygon on screen - * @param x1 First Point x axis - * @param y1 First Point y axis - * @param x2 Second Point x axis - * @param y2 Second Point y axis - * @param x3 Third Point x axis - * @param y3 Third Point y axis - * @param x4 Fourth Point x axis - * @param y4 Fourth Point y axis - * @param Color1 First Point Color - * @param Color2 Second Point Color - * @param Color3 Third Point Color - * @param Color4 Fourth Point Color - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) + /** Draw a rounded rectangle on the screen setting per vertex color + * @param R The Rectangle eeRectf + * @param TopLeft The Top Left Rectangle Color + * @param BottomLeft The Bottom Left Rectangle Color + * @param BottomRight The Bottom Right Rectangle Color + * @param TopRight The Top Right Rectangle Color + * @param Angle Rectangle Angle + * @param Scale Rectangle Scale ( default 1.0f ) + * @param Corners Number of vertices per corner ( how rounded is each corner ) */ - void DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); - - /** Draw a four edges polygon on screen - * @param x1 First Point x axis - * @param y1 First Point y axis - * @param x2 Second Point x axis - * @param y2 Second Point y axis - * @param x3 Third Point x axis - * @param y3 Third Point y axis - * @param x4 Fourth Point x axis - * @param y4 Fourth Point y axis - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); - - /** Draw a four edges polygon on screen - * @param p1 First Point - * @param p2 Second Point - * @param p3 Third Point - * @param p4 Fourth Point - * @param Color1 First Point Color - * @param Color2 Second Point Color - * @param Color3 Third Point Color - * @param Color4 Fourth Point Color - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); - - /** Draw a four edges polygon on screen - * @param p1 First Point - * @param p2 Second Point - * @param p3 Third Point - * @param p4 Fourth Point - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) - */ - void DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle = 0, const eeFloat& Scale = 1, const eeUint& Corners = 8 ); /** Draw a four edges polygon on screen * @param q The Quad - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) + * @param OffsetX X offset for the quad + * @param OffsetY Y offset for the quad */ - void DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0); + void DrawQuad( const eeQuad2f& q, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0 ); + + /** Draw a four edges polygon on screen + * @param q The Quad + * @param Color1 First Point Color + * @param Color2 Second Point Color + * @param Color3 Third Point Color + * @param Color4 Fourth Point Color + * @param OffsetX X offset for the quad + * @param OffsetY Y offset for the quad + */ + void DrawQuad( const eeQuad2f& q, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const eeFloat& OffsetX = 0, const eeFloat& OffsetY = 0 ); /** Draw a polygon on screen * @param p The Polygon - * @param fillmode Draw filled or only lines - * @param blend The Blend Mode - * @param lineWidth The line width ( default 1.0f ) */ - void DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode = EE_DRAW_FILL, const EE_BLEND_MODE& blend = ALPHA_NORMAL, const eeFloat& lineWidth = 1.0f); + void DrawPolygon( const eePolygon2f& p ); /** Set the current color for drawing primitives */ void SetColor( const eeColorA& Color ); @@ -282,9 +114,29 @@ class EE_API cPrimitives { /** Force to draw the batched vertexs. */ void DrawBatch(); + + /** Set the fill mode used to draw primitives */ + void FillMode( const EE_FILL_MODE& Mode ); + + /** @return The fill mode used to draw primitives */ + const EE_FILL_MODE& FillMode() const; + + /** Set the blend mode used to draw primitives */ + void BlendMode( const EE_BLEND_MODE& Mode ); + + /** @return The blend mode used to draw primitives */ + const EE_BLEND_MODE& BlendMode() const; + + /** Set the line width to draw primitives */ + void LineWidth( const eeFloat& width ); + + /** @return The line with to draw primitives */ + const eeFloat& LineWidth() const; private: eeColorA mColor; - cGlobalBatchRenderer * mBR; + EE_FILL_MODE mFillMode; + EE_BLEND_MODE mBlendMode; + eeFloat mLineWidth; bool mForceDraw; }; diff --git a/include/eepp/math/quad2.hpp b/include/eepp/math/quad2.hpp index 5c8f5b4da..6a25adbe3 100644 --- a/include/eepp/math/quad2.hpp +++ b/include/eepp/math/quad2.hpp @@ -11,6 +11,8 @@ class Quad2 { public: Quad2(); + Quad2( const tRECT& R ); + Quad2( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4 ); const Vector2& operator[] ( const Uint32& Pos ) const; @@ -38,6 +40,30 @@ class Quad2 { void Scale( const T& scale, const Vector2& Center ); }; +template +Quad2::Quad2() { + V[0] = Vector2(); + V[1] = Vector2(); + V[2] = Vector2(); + V[3] = Vector2(); +} + +template +Quad2::Quad2( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4 ) { + V[0] = v1; + V[1] = v2; + V[2] = v3; + V[3] = v4; +} + +template +Quad2::Quad2( const tRECT& R ) { + V[0] = Vector2( R.Left, R.Top ); + V[1] = Vector2( R.Left, R.Bottom ); + V[2] = Vector2( R.Right, R.Bottom ); + V[3] = Vector2( R.Right, R.Top ); +} + template void Quad2::Rotate( const T& Angle ) { Rotate( Angle, GetCenter() ); @@ -125,22 +151,6 @@ const Vector2& Quad2::operator[] ( const Uint32& Pos ) const { return V[0]; } -template -Quad2::Quad2() { - V[0] = Vector2(); - V[1] = Vector2(); - V[2] = Vector2(); - V[3] = Vector2(); -} - -template -Quad2::Quad2( const Vector2& v1, const Vector2& v2, const Vector2& v3, const Vector2& v4 ) { - V[0] = v1; - V[1] = v2; - V[2] = v3; - V[3] = v4; -} - typedef Quad2 eeQuad2f; }} diff --git a/include/eepp/math/rect.hpp b/include/eepp/math/rect.hpp index a4ed695f1..cf27cca85 100755 --- a/include/eepp/math/rect.hpp +++ b/include/eepp/math/rect.hpp @@ -51,6 +51,8 @@ class tRECT { Vector2 Pos(); + Vector2 Center(); + tSize Size(); }; @@ -105,6 +107,11 @@ Vector2 tRECT::Pos() { return Vector2( Left, Top ); } +template +Vector2 tRECT::Center() { + return Vector2( Left + ( ( Right - Left ) * 0.5 ), Top + ( ( Bottom - Top ) * 0.5 ) ); +} + template tSize tRECT::Size() { return tSize( Right - Left, Bottom - Top ); diff --git a/include/eepp/ui/cuicontrol.hpp b/include/eepp/ui/cuicontrol.hpp index 93044a89f..0b3055c76 100644 --- a/include/eepp/ui/cuicontrol.hpp +++ b/include/eepp/ui/cuicontrol.hpp @@ -199,7 +199,7 @@ class EE_API cUIControl { void SetSkinFromTheme( cUITheme * Theme, const std::string& ControlName ); - virtual void SetSkin( cUISkin * Skin ); + virtual void SetSkin( const cUISkin& Skin ); cUIControl * ChildGetFirst() const; @@ -319,6 +319,8 @@ class EE_API cUIControl { virtual void DrawChilds(); + virtual void DoAfterSetTheme(); + virtual cUIControl * OverFind( const eeVector2f& Point ); void ClipMe(); @@ -370,6 +372,8 @@ class EE_API cUIControl { void SafeDeleteSkinState(); eeSize GetSkinSize( cUISkin * Skin, const Uint32& State = cUISkinState::StateNormal ); + + eeRectf GetRectf(); }; }} diff --git a/include/eepp/ui/cuipushbutton.hpp b/include/eepp/ui/cuipushbutton.hpp index 1447e76c6..14b010e04 100644 --- a/include/eepp/ui/cuipushbutton.hpp +++ b/include/eepp/ui/cuipushbutton.hpp @@ -62,8 +62,6 @@ class EE_API cUIPushButton : public cUIComplexControl { virtual bool IsType( const Uint32& type ) const; - virtual void SetSkin( cUISkin * Skin ); - virtual void SetTheme( cUITheme * Theme ); virtual void Icon( cSubTexture * Icon ); @@ -98,7 +96,7 @@ class EE_API cUIPushButton : public cUIComplexControl { virtual void OnStateChange(); - void DoAfterSetTheme(); + virtual void DoAfterSetTheme(); virtual Uint32 OnKeyDown( const cUIEventKey& Event ); diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 535d426f4..a10793b46 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/src/eepp/gaming/cgameobjectvirtual.cpp b/src/eepp/gaming/cgameobjectvirtual.cpp index 87cb06da1..5c9a5825a 100644 --- a/src/eepp/gaming/cgameobjectvirtual.cpp +++ b/src/eepp/gaming/cgameobjectvirtual.cpp @@ -110,9 +110,9 @@ void cGameObjectVirtual::Draw() { if ( NULL != mLayer ) { eeSize ts = mLayer->Map()->TileSize(); - P.DrawRectangle( mPos.x, mPos.y, ts.x ,ts.y, 0, 1 ); + P.DrawRectangle( eeRectf( eeVector2f( mPos.x, mPos.y ), eeSizef( ts.x ,ts.y ) ), 0, 1 ); } else { - P.DrawRectangle( mPos.x, mPos.y, 32 ,32, 0, 1 ); + P.DrawRectangle( eeRectf( eeVector2f( mPos.x, mPos.y ), eeSizef( 32 ,32 ) ), 0, 1 ); } } } diff --git a/src/eepp/gaming/cisomap.cpp b/src/eepp/gaming/cisomap.cpp index 590a124bd..4f64c1377 100755 --- a/src/eepp/gaming/cisomap.cpp +++ b/src/eepp/gaming/cisomap.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace EE { namespace Gaming { diff --git a/src/eepp/gaming/cmap.cpp b/src/eepp/gaming/cmap.cpp index 601a81b39..4b7971e3c 100644 --- a/src/eepp/gaming/cmap.cpp +++ b/src/eepp/gaming/cmap.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace EE::Graphics; #include @@ -205,7 +206,7 @@ void cMap::Draw() { Uint8 Alpha = static_cast( (eeFloat)mBackColor.A() * ( (eeFloat)mBackAlpha / 255.f ) ); P.SetColor( eeColorA( mBackColor.R(), mBackColor.G(), mBackColor.B(), Alpha ) ); - P.DrawRectangle( mScreenPos.x, mScreenPos.y, mViewSize.x, mViewSize.y, 0.f, 1.f ); + P.DrawRectangle( eeRectf( eeVector2f( mScreenPos.x, mScreenPos.y ), eeSizef( mViewSize.x, mViewSize.y ) ), 0.f, 1.f ); P.SetColor( eeColorA( 255, 255, 255, 255 ) ); } diff --git a/src/eepp/gaming/mapeditor/cuimap.cpp b/src/eepp/gaming/mapeditor/cuimap.cpp index a7df750b9..a284e7ed3 100644 --- a/src/eepp/gaming/mapeditor/cuimap.cpp +++ b/src/eepp/gaming/mapeditor/cuimap.cpp @@ -163,9 +163,9 @@ void cUIMap::MapDraw() { eeVector2f Pos( mSelLight->GetAABB().Left, mSelLight->GetAABB().Top ); eeAABB AB( mSelLight->GetAABB() ); - eeSizef Size( AB.Size() ); - P.DrawRectangle( Pos.x, Pos.y, Size.Width(), Size.Height(), 0, 1, EE_DRAW_LINE ); + P.FillMode( EE_DRAW_LINE ); + P.DrawRectangle( eeRectf( Pos, AB.Size() ) ); } } diff --git a/src/eepp/graphics/cconsole.cpp b/src/eepp/graphics/cconsole.cpp index e2eceabd3..3f36da5e1 100755 --- a/src/eepp/graphics/cconsole.cpp +++ b/src/eepp/graphics/cconsole.cpp @@ -122,7 +122,7 @@ void cConsole::Draw() { if ( mY > 0.0f ) { if ( mTexId == 0 ) { mPri.SetColor( eeColorA( mConColor.R(), mConColor.G(), mConColor.B(), static_cast(mA) ) ); - mPri.DrawRectangle( 0.0f, 0.0f, mWidth, mY ); + mPri.DrawRectangle( eeRectf( eeVector2f( 0.0f, 0.0f ), eeSizef( mWidth, mY ) ) ); } else { eeColorA C( mConColor.R(), mConColor.G(), mConColor.B(), static_cast(mA) ); @@ -132,7 +132,7 @@ void cConsole::Draw() { Tex->DrawEx( 0.0f, 0.0f, mWidth, mY, 0.0f, 1.0f, C, C, C, C ); } mPri.SetColor( eeColorA( mConLineColor.R(), mConLineColor.G(), mConLineColor.B(), static_cast(mA) ) ); - mPri.DrawRectangle( 0.0f, mY, mWidth, 4.0f ); + mPri.DrawRectangle( eeRectf( eeVector2f( 0.0f, mY ), eeSizef( mWidth, 4.0f ) ) ); Int16 LinesInScreen = (Int16) ( (mCurHeight / mFontSize) - 1 ); diff --git a/src/eepp/graphics/cimage.cpp b/src/eepp/graphics/cimage.cpp index 593ac6f60..d6c309ba1 100644 --- a/src/eepp/graphics/cimage.cpp +++ b/src/eepp/graphics/cimage.cpp @@ -13,7 +13,7 @@ Uint32 cImage::JpegQuality() { } void cImage::JpegQuality( Uint32 level ) { - level = eemin( level, (Uint32)100 ); + level = eemin( level, 100 ); sJpegQuality = level; } @@ -250,10 +250,14 @@ void cImage::Allocate( const Uint32& size, eeColorA DefaultColor ) { mSize = size; } -eeUint cImage::Size() const { +eeUint cImage::MemSize() const { return mSize; } +eeSize cImage::Size() { + return eeSize( mWidth, mHeight ); +} + void cImage::ClearCache() { if ( mLoadedFromStbi ) { free( mPixels ); diff --git a/src/eepp/graphics/cprimitives.cpp b/src/eepp/graphics/cprimitives.cpp index 310257af0..aa6f5519d 100755 --- a/src/eepp/graphics/cprimitives.cpp +++ b/src/eepp/graphics/cprimitives.cpp @@ -1,349 +1,315 @@ #include #include +#include +#include namespace EE { namespace Graphics { +static cGlobalBatchRenderer * sBR = NULL; + cPrimitives::cPrimitives() : - mBR( cGlobalBatchRenderer::instance() ), + mFillMode( EE_DRAW_FILL ), + mBlendMode( ALPHA_NORMAL ), + mLineWidth( 1.f ), mForceDraw( true ) { + if ( NULL == sBR ) { + sBR = cGlobalBatchRenderer::instance(); + } } cPrimitives::~cPrimitives() { } -void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) { - mBR->SetTexture( NULL ); - mBR->SetBlendMode( blend ); +void cPrimitives::DrawPoint( const eeVector2f& p, const eeFloat& pointSize ) { + sBR->SetPointSize( pointSize ); + + sBR->SetTexture( NULL ); + sBR->PointsBegin(); + sBR->PointSetColor( mColor ); + + sBR->BatchPoint( p.x, p.y ); + + DrawBatch(); +} + +void cPrimitives::DrawLine( const eeLine2f& line ) { + sBR->SetLineWidth( mLineWidth ); + + sBR->SetTexture( NULL ); + sBR->LinesBegin(); + sBR->LinesSetColor( mColor ); + + sBR->BatchLine( line.V[0].x, line.V[0].y, line.V[1].x, line.V[1].y ); + + DrawBatch(); +} + +void cPrimitives::DrawTriangle( const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3 ) { + sBR->SetTexture( NULL ); + sBR->SetBlendMode( mBlendMode ); + + switch( mFillMode ) { + case EE_DRAW_LINE: + { + sBR->SetLineWidth( mLineWidth ); + + sBR->LineLoopBegin(); + + sBR->LineLoopSetColorFree( Color1, Color2 ); + sBR->BatchLineLoop( t.V[0].x, t.V[0].y, t.V[1].x, t.V[1].y ); + sBR->LineLoopSetColorFree( Color2, Color3 ); + sBR->BatchLineLoop( t.V[1].x, t.V[1].y, t.V[2].x, t.V[2].y ); + break; + } + default: + case EE_DRAW_FILL: + { + sBR->TrianglesBegin(); + + sBR->TrianglesSetColorFree( Color1, Color2, Color3 ); + sBR->BatchTriangle( t.V[0].x, t.V[0].y, t.V[1].x, t.V[1].y, t.V[2].x, t.V[2].y ); + + break; + } + } + + DrawBatch(); +} + +void cPrimitives::DrawTriangle( const eeTriangle2f& t ) { + DrawTriangle( t, mColor, mColor, mColor ); +} + +void cPrimitives::DrawCircle( const eeVector2f& p, const eeFloat& radius, Uint32 points ) { + if(points < 6) points = 6; + eeFloat angle_shift = 360 / static_cast(points); + + sBR->SetTexture( NULL ); + + switch( mFillMode ) { + case EE_DRAW_LINE: + { + sBR->SetLineWidth( mLineWidth ); + sBR->LineLoopBegin(); + sBR->LineLoopSetColor( mColor ); + + for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift ) ) + sBR->BatchLineLoop( p.x + radius * Math::sinAng(i), p.y + radius * Math::cosAng(i), p.x + radius * Math::sinAng( i + angle_shift ), p.y + radius * Math::cosAng( i + angle_shift ) ); + + break; + } + case EE_DRAW_FILL: + { + sBR->TriangleFanBegin(); + sBR->TriangleFanSetColor( mColor ); + + for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift + angle_shift ) ) + sBR->BatchTriangleFan( p.x + radius * Math::sinAng(i), p.y + radius * Math::cosAng(i), p.x + radius * Math::sinAng( i + angle_shift ), p.y + radius * Math::cosAng( i + angle_shift ), p.x + radius * Math::sinAng( i + angle_shift + angle_shift ), p.y + radius * Math::cosAng( i + angle_shift + angle_shift ) ); + + break; + } + } + + DrawBatch(); +} + +void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale ) { + sBR->SetTexture( NULL ); + sBR->SetBlendMode( mBlendMode ); + + switch( mFillMode ) { + case EE_DRAW_FILL: + { + sBR->QuadsBegin(); + sBR->QuadsSetColorFree( TopLeft, BottomLeft, BottomRight, TopRight ); + + eeSizef size = const_cast(&R)->Size(); + + sBR->BatchQuadEx( R.Left, R.Top, size.Width(), size.Height(), Angle, Scale ); + break; + } + case EE_DRAW_LINE: + { + sBR->SetLineWidth( mLineWidth ); + + sBR->LineLoopBegin(); + sBR->LineLoopSetColorFree( TopLeft, BottomLeft ); + + if ( Scale != 1.0f || Angle != 0.0f ) { + eeQuad2f Q( R ); + + Q.Scale( Scale ); + Q.Rotate( Angle, Q.GetCenter() ); + + sBR->BatchLineLoop( Q[0].x, Q[0].y, Q[1].x, Q[1].y ); + sBR->LineLoopSetColorFree( BottomRight, TopRight ); + sBR->BatchLineLoop( Q[2].x, Q[2].y, Q[3].x, Q[3].y ); + } else { + sBR->BatchLineLoop( R.Left, R.Top, R.Left, R.Bottom ); + sBR->LineLoopSetColorFree( BottomRight, TopRight ); + sBR->BatchLineLoop( R.Right, R.Bottom, R.Right, R.Top ); + } + + break; + } + } + + DrawBatch(); +} + +void cPrimitives::DrawRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale ) { + DrawRectangle( R, mColor, mColor, mColor, mColor, Angle, Scale ); +} + +void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const eeUint& Corners ) { + sBR->SetTexture( NULL ); + sBR->SetBlendMode( mBlendMode ); eeUint i; - eeFloat xscalediff = width * Scale - width; - eeFloat yscalediff = height * Scale - height; + eeSizef size = const_cast( &R )->Size(); + eeFloat xscalediff = size.Width() * Scale - size.Width(); + eeFloat yscalediff = size.Height() * Scale - size.Height(); + eeVector2f Center( R.Left + size.Width() * 0.5f + xscalediff, R.Top + size.Height() * 0.5f + yscalediff ); + eePolygon2f Poly = eePolygon2f::CreateRoundedPolygon( R.Left - xscalediff, R.Top - yscalediff, size.Width() + xscalediff, size.Height() + yscalediff, Corners ); eeVector2f poly; - eeVector2f Center( x + width * 0.5f + xscalediff, y + height * 0.5f + yscalediff ); - - eePolygon2f Poly = eePolygon2f::CreateRoundedPolygon( x - xscalediff, y - yscalediff, width + xscalediff, height + yscalediff, Corners ); Poly.Rotate( Angle, Center ); - switch(fillmode) { - case EE_DRAW_FILL: { + switch( mFillMode ) { + case EE_DRAW_FILL: + { if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) { - mBR->PolygonSetColor( TopLeft ); + sBR->PolygonSetColor( TopLeft ); - mBR->BatchPolygon( Poly ); + sBR->BatchPolygon( Poly ); } else { for ( i = 0; i < Poly.Size(); i++ ) { poly = Poly[i]; if ( poly.x <= Center.x && poly.y <= Center.y ) - mBR->PolygonSetColor( TopLeft ); + sBR->PolygonSetColor( TopLeft ); else if ( poly.x <= Center.x && poly.y >= Center.y ) - mBR->PolygonSetColor( BottomLeft ); + sBR->PolygonSetColor( BottomLeft ); else if ( poly.x > Center.x && poly.y > Center.y ) - mBR->PolygonSetColor( BottomRight ); + sBR->PolygonSetColor( BottomRight ); else if ( poly.x > Center.x && poly.y < Center.y ) - mBR->PolygonSetColor( TopRight ); + sBR->PolygonSetColor( TopRight ); else - mBR->PolygonSetColor( TopLeft ); + sBR->PolygonSetColor( TopLeft ); - mBR->BatchPolygonByPoint( Poly[i] ); + sBR->BatchPolygonByPoint( Poly[i] ); } } break; } case EE_DRAW_LINE: - mBR->SetLineWidth( lineWidth ); + { + sBR->SetLineWidth( mLineWidth ); - mBR->LineLoopBegin(); - mBR->LineLoopSetColor( TopLeft ); + sBR->LineLoopBegin(); + sBR->LineLoopSetColor( TopLeft ); if ( TopLeft == BottomLeft && BottomLeft == BottomRight && BottomRight == TopRight ) { - for ( i = 0; i < Poly.Size(); i+=2 ) - mBR->BatchLineLoop( Poly[i], Poly[i+1] ); + for ( i = 0; i < Poly.Size(); i+=2 ) { + sBR->BatchLineLoop( Poly[i], Poly[i+1] ); + } } else { for ( eeUint i = 0; i < Poly.Size(); i++ ) { poly = Poly[i]; if ( poly.x <= Center.x && poly.y <= Center.y ) - mBR->LineLoopSetColor( TopLeft ); + sBR->LineLoopSetColor( TopLeft ); else if ( poly.x < Center.x && poly.y > Center.y ) - mBR->LineLoopSetColor( BottomLeft ); + sBR->LineLoopSetColor( BottomLeft ); else if ( poly.x > Center.x && poly.y > Center.y ) - mBR->LineLoopSetColor( BottomRight ); + sBR->LineLoopSetColor( BottomRight ); else if ( poly.x > Center.x && poly.y < Center.y ) - mBR->LineLoopSetColor( TopRight ); + sBR->LineLoopSetColor( TopRight ); else - mBR->LineLoopSetColor( TopLeft ); + sBR->LineLoopSetColor( TopLeft ); - mBR->BatchLineLoop( Poly[i] ); + sBR->BatchLineLoop( Poly[i] ); } } break; + } } DrawBatch(); } -void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { - if ( 0 != Corners ) { - DrawRoundedRectangle( x, y, width, height, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners ); - return; - } +void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const eeUint& Corners ) { + DrawRoundedRectangle( R, mColor, mColor, mColor, mColor, Angle, Scale, Corners ); +} - mBR->SetTexture( NULL ); - mBR->SetBlendMode( blend ); +void cPrimitives::DrawQuad( const eeQuad2f& q, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const eeFloat& OffsetX, const eeFloat& OffsetY ) { + sBR->SetTexture( NULL ); + sBR->SetBlendMode( mBlendMode ); - switch(fillmode) { - case EE_DRAW_FILL: { - mBR->QuadsBegin(); - mBR->QuadsSetColorFree( TopLeft, BottomLeft, BottomRight, TopRight ); - mBR->BatchQuadEx( x, y, width, height, Angle, Scale ); + switch( mFillMode ) { + case EE_DRAW_LINE: + { + sBR->SetLineWidth( mLineWidth ); + + sBR->LineLoopBegin(); + sBR->LineLoopSetColorFree( Color1, Color2 ); + sBR->BatchLineLoop( OffsetX + q[0].x, OffsetY + q[0].y, OffsetX + q[1].x, OffsetY + q[1].y ); + sBR->LineLoopSetColorFree( Color2, Color3 ); + sBR->BatchLineLoop( OffsetX + q[2].x, OffsetY + q[2].y, OffsetX + q[3].x, OffsetY + q[3].y ); break; } - case EE_DRAW_LINE: - mBR->SetLineWidth( lineWidth ); - - mBR->LineLoopBegin(); - mBR->LineLoopSetColorFree( TopLeft, BottomLeft ); - - if ( Scale != 1.0f || Angle != 0.0f ) { - eeQuad2f Q; - Q.V[0].x = x; Q.V[0].y = y; - Q.V[1].x = x, Q.V[1].y = y + height; - Q.V[2].x = x + width; Q.V[2].y = y + height; - Q.V[3].x = x + width; Q.V[3].y = y; - - Q.Scale( Scale ); - Q.Rotate( Angle, eeVector2f( x + width * 0.5f, y + height * 0.5f ) ); - - mBR->BatchLineLoop( Q[0].x, Q[0].y, Q[1].x, Q[1].y ); - mBR->LineLoopSetColorFree( BottomRight, TopRight ); - mBR->BatchLineLoop( Q[2].x, Q[2].y, Q[3].x, Q[3].y ); - } else { - mBR->BatchLineLoop( x, y, x, y + height ); - mBR->LineLoopSetColorFree( BottomRight, TopRight ); - mBR->BatchLineLoop( x + width, y + height, x + width, y ); - } - - break; - } - - DrawBatch(); -} - -void cPrimitives::DrawLine(const eeFloat& x, const eeFloat& y, const eeFloat& x2, const eeFloat& y2, const eeFloat& lineWidth) { - mBR->SetLineWidth( lineWidth ); - - mBR->SetTexture( NULL ); - mBR->LinesBegin(); - mBR->LinesSetColor( mColor ); - - mBR->BatchLine( x, y, x2, y2 ); - - DrawBatch(); -} - -void cPrimitives::DrawPoint( const eeFloat& x, const eeFloat& y, const eeFloat& pointSize ) { - mBR->SetPointSize( pointSize ); - - mBR->SetTexture( NULL ); - mBR->PointsBegin(); - mBR->PointSetColor( mColor ); - - mBR->BatchPoint( x, y ); - - DrawBatch(); -} - -void cPrimitives::DrawCircle( const eeFloat& x, const eeFloat& y, const eeFloat& radius, Uint32 points, const EE_FILL_MODE& fillmode, const eeFloat& lineWidth ) { - if(points < 6) points = 6; - eeFloat angle_shift = 360 / static_cast(points); - - mBR->SetTexture( NULL ); - - switch( fillmode ) { - case EE_DRAW_LINE: - mBR->SetLineWidth( lineWidth ); - mBR->LineLoopBegin(); - mBR->LineLoopSetColor( mColor ); - - for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift ) ) - mBR->BatchLineLoop( x + radius * Math::sinAng(i), y + radius * Math::cosAng(i), x + radius * Math::sinAng( i + angle_shift ), y + radius * Math::cosAng( i + angle_shift ) ); - - break; case EE_DRAW_FILL: - mBR->TriangleFanBegin(); - mBR->TriangleFanSetColor( mColor ); - - for( eeFloat i = 0; i < 360; i+= ( angle_shift + angle_shift + angle_shift ) ) - mBR->BatchTriangleFan( x + radius * Math::sinAng(i), y + radius * Math::cosAng(i), x + radius * Math::sinAng( i + angle_shift ), y + radius * Math::cosAng( i + angle_shift ), x + radius * Math::sinAng( i + angle_shift + angle_shift ), y + radius * Math::cosAng( i + angle_shift + angle_shift ) ); - + { + sBR->QuadsBegin(); + sBR->QuadsSetColorFree( Color1, Color2, Color3, Color4 ); + sBR->BatchQuadFree( OffsetX + q[0].x, OffsetY + q[0].y, OffsetX + q[1].x, OffsetY + q[1].y, OffsetX + q[2].x, OffsetY + q[2].y, OffsetX + q[3].x, OffsetY + q[3].y ); break; + } } DrawBatch(); } -void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - mBR->SetTexture( NULL ); - mBR->SetBlendMode( blend ); - - switch(fillmode) { - case EE_DRAW_LINE: - mBR->SetLineWidth( lineWidth ); - - mBR->LineLoopBegin(); - - mBR->LineLoopSetColorFree( Color1, Color2 ); - mBR->BatchLineLoop( x1, y1, x2, y2 ); - mBR->LineLoopSetColorFree( Color2, Color3 ); - mBR->BatchLineLoop( x2, y2, x3, y3 ); - break; - default: - case EE_DRAW_FILL: - mBR->TrianglesBegin(); - - mBR->TrianglesSetColorFree( Color1, Color2, Color3 ); - mBR->BatchTriangle( x1, y1, x2, y2, x3, y3 ); - - break; - } - - DrawBatch(); +void cPrimitives::DrawQuad( const eeQuad2f& q, const eeFloat& OffsetX, const eeFloat& OffsetY ) { + DrawQuad( q, mColor, mColor, mColor, mColor, OffsetX, OffsetY ); } -void cPrimitives::DrawQuad( const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { - mBR->SetTexture( NULL ); - mBR->SetBlendMode( blend ); +void cPrimitives::DrawPolygon( const eePolygon2f& p ) { + sBR->SetTexture( NULL ); + sBR->SetBlendMode( mBlendMode ); - switch(fillmode) { + switch( mFillMode ) { case EE_DRAW_LINE: - mBR->SetLineWidth( lineWidth ); + { + sBR->SetLineWidth( mLineWidth ); - mBR->LineLoopBegin(); - mBR->LineLoopSetColorFree( Color1, Color2 ); - mBR->BatchLineLoop( OffsetX + x1, OffsetY + y1, OffsetX + x2, OffsetY + y2 ); - mBR->LineLoopSetColorFree( Color2, Color3 ); - mBR->BatchLineLoop( OffsetX + x3, OffsetY + y3, OffsetX + x4, OffsetY + y4 ); - break; - case EE_DRAW_FILL: - mBR->QuadsBegin(); - mBR->QuadsSetColorFree( Color1, Color2, Color3, Color4 ); - mBR->BatchQuadFree( OffsetX + x1, OffsetY + y1, OffsetX + x2, OffsetY + y2, OffsetX + x3, OffsetY + y3, OffsetX + x4, OffsetY + y4 ); - break; - } - - DrawBatch(); -} - -void cPrimitives::DrawPolygon(const eePolygon2f& p, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - mBR->SetTexture( NULL ); - mBR->SetBlendMode( blend ); - - switch(fillmode) { - case EE_DRAW_LINE: - mBR->SetLineWidth( lineWidth ); - - mBR->LineLoopBegin(); - mBR->LineLoopSetColor( mColor ); + sBR->LineLoopBegin(); + sBR->LineLoopSetColor( mColor ); for ( Uint32 i = 0; i < p.Size(); i += 2 ) - mBR->BatchLineLoop( p[i].x, p[i].y, p[i+1].x, p[i+1].y ); + sBR->BatchLineLoop( p[i].x, p[i].y, p[i+1].x, p[i+1].y ); break; + } case EE_DRAW_FILL: - mBR->PolygonSetColor( mColor ); - mBR->BatchPolygon( p ); + { + sBR->PolygonSetColor( mColor ); + sBR->BatchPolygon( p ); break; + } } DrawBatch(); } -void cPrimitives::DrawRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { - DrawRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners); -} - -void cPrimitives::DrawRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { - DrawRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); -} - -void cPrimitives::DrawRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { - DrawRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); -} - -void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeColorA& TopLeft, const eeColorA& BottomLeft, const eeColorA& BottomRight, const eeColorA& TopRight, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) { - DrawRoundedRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, TopLeft, BottomLeft, BottomRight, TopRight, Angle, Scale, fillmode, blend, lineWidth, Corners); -} - -void cPrimitives::DrawRoundedRectangle( const eeRectf& R, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners) { - DrawRoundedRectangle( R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); -} - -void cPrimitives::DrawRoundedRectangle(const eeFloat& x, const eeFloat& y, const eeFloat& width, const eeFloat& height, const eeFloat& Angle, const eeFloat& Scale, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeUint& Corners ) { - DrawRoundedRectangle(x, y, width, height, mColor, mColor, mColor, mColor, Angle, Scale, fillmode, blend, lineWidth, Corners); -} - -void cPrimitives::DrawLine(const eeVector2f& p1, const eeVector2f& p2, const eeFloat& lineWidth) { - DrawLine(p1.x, p1.y, p2.x, p2.y, lineWidth); -} - -void cPrimitives::DrawPoint(const eeVector2f& p, const eeFloat& pointSize) { - DrawPoint(p.x, p.y, pointSize); -} - -void cPrimitives::DrawCircle(const eeVector2f& p, const eeFloat& radius, Uint32 points, const EE_FILL_MODE& fillmode, const eeFloat& lineWidth) { - DrawCircle(p.x, p.y, radius, points, fillmode, lineWidth); -} - -void cPrimitives::SetColor( const eeColorA& Color ) { - mColor = Color; -} - -void cPrimitives::DrawTriangle(const eeTriangle2f& t, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - DrawTriangle( t.V[0], t.V[1], t.V[2], mColor, mColor, mColor, fillmode, blend, lineWidth ); -} - -void cPrimitives::DrawTriangle(const eeTriangle2f& t, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - DrawTriangle( t.V[0], t.V[1], t.V[2], Color1, Color2, Color3, fillmode, blend, lineWidth ); -} - -void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - DrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, Color1, Color2, Color3, fillmode, blend, lineWidth); -} - -void cPrimitives::DrawTriangle(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - DrawTriangle(x1, y1, x2, y2, x3, y3, mColor, mColor, mColor, fillmode, blend, lineWidth); -} - -void cPrimitives::DrawTriangle(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth) { - DrawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, mColor, mColor, mColor, fillmode, blend, lineWidth); -} - -void cPrimitives::DrawQuad(const eeFloat& x1, const eeFloat& y1, const eeFloat& x2, const eeFloat& y2, const eeFloat& x3, const eeFloat& y3, const eeFloat& x4, const eeFloat& y4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { - DrawQuad(x1, y1, x2, y2, x3, y3, x4, y4, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY); -} - -void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3, const eeColorA& Color4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { - DrawQuad(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, Color1, Color2, Color3, Color4, fillmode, blend, lineWidth, OffsetX, OffsetY); -} - -void cPrimitives::DrawQuad(const eeVector2f& p1, const eeVector2f& p2, const eeVector2f& p3, const eeVector2f& p4, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { - DrawQuad(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY); -} - -void cPrimitives::DrawQuad(const eeQuad2f& q, const EE_FILL_MODE& fillmode, const EE_BLEND_MODE& blend, const eeFloat& lineWidth, const eeFloat& OffsetX, const eeFloat& OffsetY ) { - DrawQuad(q.V[0].x, q.V[0].y, q.V[1].x, q.V[1].y, q.V[2].x, q.V[2].y, q.V[3].x, q.V[3].y, mColor, mColor, mColor, mColor, fillmode, blend, lineWidth, OffsetX, OffsetY); -} - void cPrimitives::DrawBatch() { if ( mForceDraw ) - mBR->Draw(); + sBR->Draw(); else - mBR->DrawOpt(); + sBR->DrawOpt(); } void cPrimitives::ForceDraw( const bool& force ) { @@ -357,4 +323,32 @@ const bool& cPrimitives::ForceDraw() const { return mForceDraw; } +void cPrimitives::SetColor( const eeColorA& Color ) { + mColor = Color; +} + +void cPrimitives::FillMode( const EE_FILL_MODE& Mode ) { + mFillMode = Mode; +} + +const EE_FILL_MODE& cPrimitives::FillMode() const { + return mFillMode; +} + +void cPrimitives::BlendMode( const EE_BLEND_MODE& Mode ) { + mBlendMode = Mode; +} + +const EE_BLEND_MODE& cPrimitives::BlendMode() const { + return mBlendMode; +} + +void cPrimitives::LineWidth( const eeFloat& width ) { + mLineWidth = width; +} + +const eeFloat& cPrimitives::LineWidth() const { + return mLineWidth; +} + }} diff --git a/src/eepp/graphics/ctexturefactory.cpp b/src/eepp/graphics/ctexturefactory.cpp index 734cfffb3..e6fdc0f48 100755 --- a/src/eepp/graphics/ctexturefactory.cpp +++ b/src/eepp/graphics/ctexturefactory.cpp @@ -288,8 +288,8 @@ eeUint cTextureFactory::GetTexMemSize( const eeUint& TexId ) { eeUint h = Tex->Height(); eeUint c = Tex->Channels(); - if ( 0 != Tex->Size() ) - Size = Tex->Size(); + if ( 0 != Tex->MemSize() ) + Size = Tex->MemSize(); else Size = ( w * h * c ); @@ -301,7 +301,7 @@ eeUint cTextureFactory::GetTexMemSize( const eeUint& TexId ) { } } } else { - Size = Tex->Size(); + Size = Tex->MemSize(); } } diff --git a/src/eepp/physics/cshape.cpp b/src/eepp/physics/cshape.cpp index 86a11ffc2..20308f34d 100644 --- a/src/eepp/physics/cshape.cpp +++ b/src/eepp/physics/cshape.cpp @@ -171,10 +171,10 @@ void cShape::DrawBB() { cPrimitives P; P.SetColor( eeColorA( 76, 128, 76, 255 ) ); P.ForceDraw( false ); - P.DrawLine( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.t ) ); - P.DrawLine( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.l, mShape->bb.b ) ); - P.DrawLine( eeVector2f( mShape->bb.l, mShape->bb.b ), eeVector2f( mShape->bb.r, mShape->bb.b ) ); - P.DrawLine( eeVector2f( mShape->bb.r, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.b ) ); + P.DrawLine( eeLine2f( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.t ) ) ); + P.DrawLine( eeLine2f( eeVector2f( mShape->bb.l, mShape->bb.t ), eeVector2f( mShape->bb.l, mShape->bb.b ) ) ); + P.DrawLine( eeLine2f( eeVector2f( mShape->bb.l, mShape->bb.b ), eeVector2f( mShape->bb.r, mShape->bb.b ) ) ); + P.DrawLine( eeLine2f( eeVector2f( mShape->bb.r, mShape->bb.t ), eeVector2f( mShape->bb.r, mShape->bb.b ) ) ); #endif } diff --git a/src/eepp/physics/cshapecircle.cpp b/src/eepp/physics/cshapecircle.cpp index e17591d6a..06aa30946 100644 --- a/src/eepp/physics/cshapecircle.cpp +++ b/src/eepp/physics/cshapecircle.cpp @@ -41,7 +41,7 @@ void cShapeCircle::Draw( cSpace * space ) { cpCircleShape * cs = (cpCircleShape*)mShape; p.SetColor( ColorForShape( mShape, space->Space() ) ); - p.DrawCircle( cs->CP_PRIVATE(tc).x, cs->CP_PRIVATE(tc).y, cs->CP_PRIVATE(r) ); + p.DrawCircle( eeVector2f( cs->CP_PRIVATE(tc).x, cs->CP_PRIVATE(tc).y ), cs->CP_PRIVATE(r) ); #endif } diff --git a/src/eepp/physics/cshapesegment.cpp b/src/eepp/physics/cshapesegment.cpp index 93cf26754..72825ff5d 100644 --- a/src/eepp/physics/cshapesegment.cpp +++ b/src/eepp/physics/cshapesegment.cpp @@ -105,7 +105,7 @@ void cShapeSegment::Draw( cSpace * space ) { GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY ); } else { cPrimitives p; - p.DrawLine( eeVector2f( a.x, a.y ), eeVector2f( b.x, b.y ) ); + p.DrawLine( eeLine2f( eeVector2f( a.x, a.y ), eeVector2f( b.x, b.y ) ) ); } #endif } diff --git a/src/eepp/ui/cuicontrol.cpp b/src/eepp/ui/cuicontrol.cpp index 2af23b6c1..0dfcca3b3 100644 --- a/src/eepp/ui/cuicontrol.cpp +++ b/src/eepp/ui/cuicontrol.cpp @@ -497,25 +497,54 @@ void cUIControl::OnSizeChange() { SendCommonEvent( cUIEvent::EventOnSizeChange ); } +eeRectf cUIControl::GetRectf() { + return eeRectf( eeVector2f( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y ), eeSizef( (eeFloat)mSize.Width(), (eeFloat)mSize.Height() ) ); +} + void cUIControl::BackgroundDraw() { cPrimitives P; + eeRectf R = GetRectf(); + P.BlendMode( mBackground->Blend() ); P.SetColor( mBackground->Color() ); if ( 4 == mBackground->Colors().size() ) { - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), mBackground->Colors()[0], mBackground->Colors()[1], mBackground->Colors()[2], mBackground->Colors()[3], 0.f, 1.f, EE_DRAW_FILL, mBackground->Blend(), 1.0f, mBackground->Corners() ); + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( R, mBackground->Colors()[0], mBackground->Colors()[1], mBackground->Colors()[2], mBackground->Colors()[3], mBackground->Corners() ); + } else { + P.DrawRectangle( R, mBackground->Colors()[0], mBackground->Colors()[1], mBackground->Colors()[2], mBackground->Colors()[3] ); + } } else { - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_FILL, mBackground->Blend(), 1.0f, mBackground->Corners() ); + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( R, 0.f, 1.f, mBackground->Corners() ); + } else { + P.DrawRectangle( R ); + } } } void cUIControl::BorderDraw() { cPrimitives P; + P.FillMode( EE_DRAW_LINE ); + P.BlendMode( Blend() ); + P.LineWidth( (eeFloat)mBorder->Width() ); P.SetColor( mBorder->Color() ); - if ( mFlags & UI_CLIP_ENABLE ) - P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); - else - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); + //! @TODO: Check why was this +0.1f -0.1f? + if ( mFlags & UI_CLIP_ENABLE ) { + eeRectf R( eeVector2f( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f ), eeSizef( (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f ) ); + + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() ); + } else { + P.DrawRectangle( R ); + } + } else { + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() ); + } else { + P.DrawRectangle( GetRectf() ); + } + } } const Uint32& cUIControl::ControlFlags() const { @@ -908,14 +937,16 @@ void cUIControl::SetSkinFromTheme( cUITheme * Theme, const std::string& ControlN SetThemeControl( Theme, ControlName ); } -void cUIControl::SetSkin( cUISkin * Skin ) { - if ( NULL != Skin ) { - SafeDeleteSkinState(); +void cUIControl::SetSkin( const cUISkin& Skin ) { + SafeDeleteSkinState(); - WriteCtrlFlag( UI_CTRL_FLAG_SKIN_OWNER, 1 ); + WriteCtrlFlag( UI_CTRL_FLAG_SKIN_OWNER, 1 ); - mSkinState = eeNew( cUISkinState, ( Skin ) ); - } + cUISkin * SkinCopy = const_cast( &Skin )->Copy(); + + mSkinState = eeNew( cUISkinState, ( SkinCopy ) ); + + DoAfterSetTheme(); } void cUIControl::OnStateChange() { @@ -1145,4 +1176,7 @@ cUIControl * cUIControl::NextComplexControl() { return cUIManager::instance()->MainControl(); } +void cUIControl::DoAfterSetTheme() { +} + }} diff --git a/src/eepp/ui/cuicontrolanim.cpp b/src/eepp/ui/cuicontrolanim.cpp index f3ac78b2d..e8d2d9e8b 100644 --- a/src/eepp/ui/cuicontrolanim.cpp +++ b/src/eepp/ui/cuicontrolanim.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace EE { namespace UI { @@ -45,8 +46,10 @@ void cUIControlAnim::Draw() { if ( cUIManager::instance()->HighlightFocus() && cUIManager::instance()->FocusControl() == this ) { cPrimitives P; + P.FillMode( EE_DRAW_LINE ); + P.BlendMode( Blend() ); P.SetColor( cUIManager::instance()->HighlightColor() ); - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), 1, 0 ); + P.DrawRectangle( GetRectf() ); } } } @@ -262,23 +265,48 @@ void cUIControlAnim::DisableFadeOut( const eeFloat& Time, const bool& AlphaChild void cUIControlAnim::BackgroundDraw() { cPrimitives P; + eeRectf R = GetRectf(); + P.BlendMode( mBackground->Blend() ); P.SetColor( GetColor( mBackground->Color() ) ); if ( 4 == mBackground->Colors().size() ) { - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.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, EE_DRAW_FILL, mBackground->Blend(), 1.0f, mBackground->Corners() ); + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( R, GetColor( mBackground->Colors()[0] ), GetColor( mBackground->Colors()[1] ), GetColor( mBackground->Colors()[2] ), GetColor( mBackground->Colors()[3] ), mBackground->Corners() ); + } else { + P.DrawRectangle( R, GetColor( mBackground->Colors()[0] ), GetColor( mBackground->Colors()[1] ), GetColor( mBackground->Colors()[2] ), GetColor( mBackground->Colors()[3] ) ); + } } else { - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_FILL, mBackground->Blend(), 1.0f, mBackground->Corners() ); + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( R, 0.f, 1.f, mBackground->Corners() ); + } else { + P.DrawRectangle( R ); + } } } void cUIControlAnim::BorderDraw() { cPrimitives P; + P.FillMode( EE_DRAW_LINE ); + P.BlendMode( Blend() ); + P.LineWidth( (eeFloat)mBorder->Width() ); P.SetColor( GetColor( mBorder->Color() ) ); - if ( mFlags & UI_CLIP_ENABLE ) - P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); - else - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); + //! @TODO: Check why was this +0.1f -0.1f? + if ( mFlags & UI_CLIP_ENABLE ) { + eeRectf R( eeVector2f( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f ), eeSizef( (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f ) ); + + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() ); + } else { + P.DrawRectangle( R ); + } + } else { + if ( mBackground->Corners() ) { + P.DrawRoundedRectangle( GetRectf(), 0.f, 1.f, mBackground->Corners() ); + } else { + P.DrawRectangle( GetRectf() ); + } + } } eeColorA cUIControlAnim::GetColor( const eeColorA& Col ) { diff --git a/src/eepp/ui/cuimanager.cpp b/src/eepp/ui/cuimanager.cpp index d7e3ffb85..aa5cfc2b6 100644 --- a/src/eepp/ui/cuimanager.cpp +++ b/src/eepp/ui/cuimanager.cpp @@ -1,5 +1,6 @@ #include #include +#include #include namespace EE { namespace UI { diff --git a/src/eepp/ui/cuipushbutton.cpp b/src/eepp/ui/cuipushbutton.cpp index fe59266df..c901c6d01 100644 --- a/src/eepp/ui/cuipushbutton.cpp +++ b/src/eepp/ui/cuipushbutton.cpp @@ -127,12 +127,6 @@ void cUIPushButton::SetTheme( cUITheme * Theme ) { DoAfterSetTheme(); } -void cUIPushButton::SetSkin( cUISkin * Skin ) { - cUIControl::SetSkin( Skin ); - - DoAfterSetTheme(); -} - void cUIPushButton::DoAfterSetTheme() { if ( NULL != mTextBox && NULL == mTextBox->Font() && NULL != mSkinState && NULL != mSkinState->GetSkin() && NULL != mSkinState->GetSkin()->Theme() && NULL != mSkinState->GetSkin()->Theme()->Font() ) mTextBox->Font( mSkinState->GetSkin()->Theme()->Font() ); diff --git a/src/eepp/ui/cuitextinput.cpp b/src/eepp/ui/cuitextinput.cpp index a2c8eb374..de7a99077 100644 --- a/src/eepp/ui/cuitextinput.cpp +++ b/src/eepp/ui/cuitextinput.cpp @@ -84,7 +84,7 @@ void cUITextInput::Draw() { if ( CurPosX > (eeFloat)mScreenPos.x + (eeFloat)mSize.x ) CurPosX = (eeFloat)mScreenPos.x + (eeFloat)mSize.x; - P.DrawLine( CurPosX, CurPosY, CurPosX, CurPosY + mTextCache->Font()->GetFontHeight(), 1.f ); + P.DrawLine( eeLine2f( eeVector2f( CurPosX, CurPosY ), eeVector2f( CurPosX, CurPosY + mTextCache->Font()->GetFontHeight() ) ) ); if ( disableSmooth ) GLi->LineSmooth( true ); diff --git a/src/eepp/ui/cuiwindow.cpp b/src/eepp/ui/cuiwindow.cpp index 73c417ee8..2843917d4 100644 --- a/src/eepp/ui/cuiwindow.cpp +++ b/src/eepp/ui/cuiwindow.cpp @@ -582,15 +582,15 @@ void cUIWindow::Draw() { eeVector2i ShadowPos = mScreenPos + eeVector2i( 0, 16 ); - P.DrawRectangle( ShadowPos.x, ShadowPos.y, mSize.Width(), mSize.Height(), BeginC, BeginC, BeginC, BeginC ); + P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y ), eeSizef( mSize.Width(), mSize.Height() ) ), BeginC, BeginC, BeginC, BeginC ); - P.DrawRectangle( ShadowPos.x, ShadowPos.y - SSize, mSize.Width(), SSize, EndC, BeginC, BeginC, EndC ); + P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y - SSize ), eeSizef( mSize.Width(), SSize ) ), EndC, BeginC, BeginC, EndC ); - P.DrawRectangle( ShadowPos.x - SSize, ShadowPos.y, SSize, mSize.Height(), EndC, EndC, BeginC, BeginC ); + P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x - SSize, ShadowPos.y ), eeSizef( SSize, mSize.Height() ) ), EndC, EndC, BeginC, BeginC ); - P.DrawRectangle( ShadowPos.x + mSize.Width(), ShadowPos.y, SSize, mSize.Height(), BeginC, BeginC, EndC, EndC ); + P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y ), eeSizef( SSize, mSize.Height() ) ), BeginC, BeginC, EndC, EndC ); - P.DrawRectangle( ShadowPos.x, ShadowPos.y + mSize.Height(), mSize.Width(), SSize, BeginC, EndC, EndC, BeginC ); + P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() ), eeSizef( mSize.Width(), SSize ) ), BeginC, EndC, EndC, BeginC ); P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y ), eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y - SSize ), eeVector2f( ShadowPos.x + mSize.Width() + SSize, ShadowPos.y ) ), BeginC, EndC, EndC ); diff --git a/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp b/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp index 7183b39fe..0be3019c4 100644 --- a/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp +++ b/src/eepp/ui/tools/ctextureatlassubtextureeditor.cpp @@ -35,8 +35,8 @@ cTextureAtlasSubTextureEditor::~cTextureAtlasSubTextureEditor() { void cTextureAtlasSubTextureEditor::Draw() { cPrimitives P; P.SetColor( eeColorA( 255, 0, 0, mAlpha ) ); - P.DrawLine( mScreenPos.x, mScreenPos.y + mUICenter.y, mScreenPos.x + mSize.Width(), mScreenPos.y + mUICenter.y ); - P.DrawLine( mScreenPos.x + mUICenter.x, mScreenPos.y, mScreenPos.x + mUICenter.x, mScreenPos.y + mSize.Height() ); + P.DrawLine( eeLine2f( eeVector2f( mScreenPos.x, mScreenPos.y + mUICenter.y ), eeVector2f( mScreenPos.x + mSize.Width(), mScreenPos.y + mUICenter.y ) ) ); + P.DrawLine( eeLine2f( eeVector2f( mScreenPos.x + mUICenter.x, mScreenPos.y ), eeVector2f( mScreenPos.x + mUICenter.x, mScreenPos.y + mSize.Height() ) ) ); cUIComplexControl::Draw(); } diff --git a/src/eepp/window/ccursor.cpp b/src/eepp/window/ccursor.cpp index 4ab43e447..6de01288a 100644 --- a/src/eepp/window/ccursor.cpp +++ b/src/eepp/window/ccursor.cpp @@ -25,7 +25,7 @@ cCursor::cCursor( cImage * img, const eeVector2i& hotspot, const std::string& na mHotSpot( hotspot ), mWindow( window ) { - if ( img->Size() ) { + if ( img->MemSize() ) { mImage = eeNew( cImage, ( img->GetPixelsPtr(), img->Width(), img->Height(), img->Channels() ) ); } else { cLog::instance()->Write( "cCursor::cCursor: Error creating cursor from cImage." ); diff --git a/src/eepp/window/platform/win/ccursorwin.cpp b/src/eepp/window/platform/win/ccursorwin.cpp index f627a08f0..c9738f291 100644 --- a/src/eepp/window/platform/win/ccursorwin.cpp +++ b/src/eepp/window/platform/win/ccursorwin.cpp @@ -126,7 +126,7 @@ static void local_draw_to_hdc( HDC dc, cImage * bitmap, int x, int y ) { } void cCursorWin::Create() { - if ( NULL == mImage && mImage->Size() ) + if ( NULL == mImage && mImage->MemSize() ) return; int x, y; diff --git a/src/eepp/window/platform/x11/ccursorx11.cpp b/src/eepp/window/platform/x11/ccursorx11.cpp index a1fb20bf9..b1650ebe0 100644 --- a/src/eepp/window/platform/x11/ccursorx11.cpp +++ b/src/eepp/window/platform/x11/ccursorx11.cpp @@ -41,7 +41,7 @@ cCursorX11::~cCursorX11() { } void cCursorX11::Create() { - if ( NULL == mImage && mImage->Size() ) + if ( NULL == mImage && mImage->MemSize() ) return; XcursorImage * image; diff --git a/src/examples/empty_window/empty_window.cpp b/src/examples/empty_window/empty_window.cpp index f7d848012..4ebd80627 100644 --- a/src/examples/empty_window/empty_window.cpp +++ b/src/examples/empty_window/empty_window.cpp @@ -32,7 +32,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) } // Draw a circle - p.DrawCircle( win->GetWidth() / 2, win->GetHeight() / 2, 200 ); + p.DrawCircle( eeVector2f( win->GetWidth() * 0.5f, win->GetHeight() * 0.5f ), 200 ); // Draw frame win->Display(); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index c4d044af8..663d59c50 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -562,18 +562,20 @@ void cEETest::CreateUI() { #ifdef EE_PLATFORM_TOUCH cTextureAtlas * SG = cGlobalTextureAtlas::instance(); - SG->Add( TF->Load( MyPath + "extra/button-te_normal.png" ), "button-te_normal" ); + cTexture * butTex = TF->GetTexture( TF->Load( MyPath + "extra/button-te_normal.png" ) ); + + SG->Add( butTex->Id(), "button-te_normal" ); SG->Add( TF->Load( MyPath + "extra/button-te_mdown.png" ), "button-te_mdown" ); - cUISkinSimple * nSkin = eeNew( cUISkinSimple, ( "button-te" ) ); + cUISkinSimple nSkin( "button-te" ); - mShowMenu = mTheme->CreatePushButton( NULL, eeSize( 128, 64 ), eeVector2i( mWindow->GetWidth() - 158, mWindow->GetHeight() - 74 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); + mShowMenu = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mWindow->GetWidth() - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); mShowMenu->SetSkin( nSkin ); mShowMenu->Text( "Show Menu" ); mShowMenu->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnShowMenu ) ); - mTerrainBut = mTheme->CreatePushButton( NULL, eeSize( 128, 64 ), eeVector2i( mShowMenu->Pos().x - 128 - 20, mWindow->GetHeight() - 74 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); - mTerrainBut->SetSkin( nSkin->Copy() ); + mTerrainBut = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mShowMenu->Pos().x - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); + mTerrainBut->SetSkin( nSkin ); mTerrainBut->Text( "Terrain Up" ); mTerrainBut->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnTerrainMouse ) ); mTerrainBut->Visible( 1 == Screen ); @@ -1105,9 +1107,10 @@ void cEETest::Screen2() { CL1.Draw(); CL2.Draw(); - PR.DrawRectangle( CL1.GetAABB(), 0.0f, 1.0f, EE_DRAW_LINE ); + PR.FillMode( EE_DRAW_LINE ); + PR.DrawRectangle( CL1.GetAABB() ); - PR.DrawQuad( CL1.GetQuad(), EE_DRAW_LINE ); + PR.DrawQuad( CL1.GetQuad() ); #endif Ang = Ang + mWindow->Elapsed() * 0.1f; @@ -1140,15 +1143,16 @@ void cEETest::Screen2() { else if (iL2) PR.SetColor( eeColorA(255, 255, 0, 255) ); - PR.DrawCircle(Mousef.x, Mousef.y, 80.f, (Uint32)(Ang/3), EE_DRAW_LINE); + PR.FillMode( EE_DRAW_LINE ); + PR.DrawCircle( eeVector2f( Mousef.x, Mousef.y ), 80.f, (Uint32)(Ang/3) ); - PR.DrawTriangle( eeVector2f( Mousef.x, Mousef.y - 10.f ), eeVector2f( Mousef.x - 10.f, Mousef.y + 10.f ), eeVector2f( Mousef.x + 10.f, Mousef.y + 10.f ), EE_DRAW_LINE ); - PR.DrawLine( eeVector2f(Mousef.x - 80.f, Mousef.y - 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y + 80.f) ); - PR.DrawLine( eeVector2f(Mousef.x - 80.f, Mousef.y + 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y - 80.f) ); - PR.DrawLine( eeVector2f((eeFloat)mWindow->GetWidth(), 0.f), eeVector2f( 0.f, (eeFloat)mWindow->GetHeight() ) ); - PR.DrawQuad( eeVector2f(0.f, 0.f), eeVector2f(0.f, 100.f), eeVector2f(150.f, 150.f), eeVector2f(200.f, 150.f), eeColorA(220, 240, 0, 125), eeColorA(100, 0, 240, 125), eeColorA(250, 50, 25, 125), eeColorA(50, 150, 150, 125) ); - PR.DrawRectangle(Mousef.x - 80.f, Mousef.y - 80.f, 160.f, 160.f, 45.f, 1.f, EE_DRAW_LINE); - PR.DrawLine( eeVector2f(0.f, 0.f), eeVector2f( (eeFloat)mWindow->GetWidth(), (eeFloat)mWindow->GetHeight() ) ); + PR.DrawTriangle( eeTriangle2f( eeVector2f( Mousef.x, Mousef.y - 10.f ), eeVector2f( Mousef.x - 10.f, Mousef.y + 10.f ), eeVector2f( Mousef.x + 10.f, Mousef.y + 10.f ) ) ); + PR.DrawLine( eeLine2f( eeVector2f(Mousef.x - 80.f, Mousef.y - 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y + 80.f) ) ); + PR.DrawLine( eeLine2f( eeVector2f(Mousef.x - 80.f, Mousef.y + 80.f), eeVector2f(Mousef.x + 80.f, Mousef.y - 80.f) ) ); + PR.DrawLine( eeLine2f( eeVector2f((eeFloat)mWindow->GetWidth(), 0.f), eeVector2f( 0.f, (eeFloat)mWindow->GetHeight() ) ) ); + PR.DrawQuad( eeQuad2f( eeVector2f(0.f, 0.f), eeVector2f(0.f, 100.f), eeVector2f(150.f, 150.f), eeVector2f(200.f, 150.f) ), eeColorA(220, 240, 0, 125), eeColorA(100, 0, 240, 125), eeColorA(250, 50, 25, 125), eeColorA(50, 150, 150, 125) ); + PR.DrawRectangle( eeRectf( eeVector2f( Mousef.x - 80.f, Mousef.y - 80.f ), eeSizef( 160.f, 160.f ) ), 45.f ); + PR.DrawLine( eeLine2f( eeVector2f(0.f, 0.f), eeVector2f( (eeFloat)mWindow->GetWidth(), (eeFloat)mWindow->GetHeight() ) ) ); TNP[3]->DrawQuadEx( eeQuad2f( eeVector2f(0.f, 0.f), eeVector2f(0.f, 100.f), eeVector2f(150.f, 150.f), eeVector2f(200.f, 150.f) ), 0.0f, 0.0f, ang, scale, eeColorA(220, 240, 0, 125), eeColorA(100, 0, 240, 125), eeColorA(250, 50, 25, 125), eeColorA(50, 150, 150, 125) ); @@ -1262,13 +1266,19 @@ void cEETest::Render() { eeColorA ColRR3( 100, 100, 100, 220 ); PR.SetColor( eeColorA(150, 150, 150, 220) ); - + PR.FillMode( EE_DRAW_FILL ); PR.DrawRectangle( - 0.f, - (eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight(), - mEEText.GetTextWidth(), - mEEText.GetTextHeight(), - ColRR1, ColRR2, ColRR3, ColRR4 + eeRectf( + eeVector2f( + 0.f, + (eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight() + ), + eeVector2f( + mEEText.GetTextWidth(), + mEEText.GetTextHeight() + ) + ), + ColRR1, ColRR2, ColRR3, ColRR4 ); mEEText.Draw( 0.f, (eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight(), FONT_DRAW_CENTER );