diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/Extended_IGUIRectangle.h Irrlicht_starsonata/include/Extended_IGUIRectangle.h --- irrlicht-svn-ss/trunk/include/Extended_IGUIRectangle.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/include/Extended_IGUIRectangle.h 2007-10-22 18:57:04.000000000 +0200 @@ -0,0 +1,32 @@ +#ifndef __EXTENDED_IGUIRECTANGLE_H__ +#define __EXTENDED_IGUIRECTANGLE_H__ + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + + //! A rectangle displaying smoothly interpolated colors which can be set for each corner + class IGUIRectangle : public IGUIElement + { + public: + + //! constructor + IGUIRectangle(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_RECTANGLE, environment, parent, id, rectangle) {} + + // Set the colors of the four corners of the rectangle + virtual void setCornerColors(video::SColor colorLeftUp, video::SColor colorRightUp, video::SColor colorLeftDown, video::SColor colorRightDown) = 0; + + //! destructor + ~IGUIRectangle() {}; + }; + + +} // end namespace gui +} // end namespace irr + +#endif diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/Extended_CGUIRectangle.cpp Irrlicht_starsonata/source/Irrlicht/Extended_CGUIRectangle.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/Extended_CGUIRectangle.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/Extended_CGUIRectangle.cpp 2007-10-22 18:56:54.000000000 +0200 @@ -0,0 +1,77 @@ +// Extended_IGUIRectangle.cpp // + +#include "Extended_CGUIRectangle.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIRectangle::CGUIRectangle(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) +: IGUIRectangle(environment, parent, id, rectangle) +{ + #ifdef _DEBUG + setDebugName("CGUIRectangle"); + #endif + + // Set some default color + for (int i=0; i<4; ++i) + { + m_colors[i].set(255, 255, 255, 255); + } +} + +//! sets the colors of the four corners +void CGUIRectangle::setCornerColors(video::SColor colorLeftUp, video::SColor colorRightUp, video::SColor colorLeftDown, video::SColor colorRightDown) +{ + m_colors[0] = colorLeftUp; + m_colors[1] = colorRightUp; + m_colors[2] = colorLeftDown; + m_colors[3] = colorRightDown; +} + +//! draws the element and its children +void CGUIRectangle::draw() +{ + if (!IsVisible) + return; + +// IGUISkin* skin = Environment->getSkin(); + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect rect = AbsoluteRect; + + driver->draw2DRectangle(rect, m_colors[0], m_colors[1], m_colors[2], m_colors[3], &AbsoluteClippingRect); + + IGUIElement::draw(); +} + +//! Writes attributes of the element. +void CGUIRectangle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + IGUIRectangle::serializeAttributes(out, options); + + out->addColor("col_left_up", m_colors[0]); + out->addColor("col_right_up", m_colors[1]); + out->addColor("col_left_down", m_colors[2]); + out->addColor("col_right_down", m_colors[3]); +} + +//! Reads attributes of the element +void CGUIRectangle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + IGUIRectangle::deserializeAttributes(in, options); + + m_colors[0] = in->getAttributeAsColor("col_left_up"); + m_colors[1] = in->getAttributeAsColor("col_right_up"); + m_colors[2] = in->getAttributeAsColor("col_left_down"); + m_colors[3] = in->getAttributeAsColor("col_right_down"); +} + + + +} // end namespace gui +} // end namespace irr diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/Extended_CGUIRectangle.h Irrlicht_starsonata/source/Irrlicht/Extended_CGUIRectangle.h --- irrlicht-svn-ss/trunk/source/Irrlicht/Extended_CGUIRectangle.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht_starsonata/source/Irrlicht/Extended_CGUIRectangle.h 2007-10-22 18:56:54.000000000 +0200 @@ -0,0 +1,48 @@ +// Extended_CGUIRectangle.h // +// Adds an arbitrarily sized and colored rectangle as a GUI element +// Note that the color values have alpha components + +#ifndef __EXTENDED_CGUIRECTANGLE_H__ +#define __EXTENDED_CGUIRECTANGLE_H__ + +#include "Extended_IGUIRectangle.h" + +namespace irr +{ +namespace gui +{ + + //! GUI element displaying an image. + class CGUIRectangle : public IGUIRectangle + { + public: + + //! constructor + CGUIRectangle(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + + //! destructor + ~CGUIRectangle() {}; + + //! sets the colors of the four corners + virtual void setCornerColors(video::SColor colorLeftUp, video::SColor colorRightUp, video::SColor colorLeftDown, video::SColor colorRightDown); + + //! draws the element and its children + virtual void draw(); + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + + + private: + + video::SColor m_colors[4]; // left up, right up, left down, right down + }; + + +} // end namespace gui +} // end namespace irr + +#endif