41 #ifndef _uimultiimagelayer_cpp
42 #define _uimultiimagelayer_cpp
44 #include "UI/multiimagelayer.h"
45 #include "UI/quadrenderable.h"
46 #include "UI/screen.h"
161 Rect ImageDims = (*ImageIt).FillRect.CalculateActualDimensions( ActDims );
164 RectCorners[UI::QC_TopLeft].
X = ImageDims.
Position.
X + TexelOffsetX; RectCorners[UI::QC_TopLeft].
Y = ImageDims.
Position.
Y + TexelOffsetY;
165 RectCorners[UI::QC_TopRight].
X = (ImageDims.
Position.
X + ImageDims.
Size.
X) + TexelOffsetX; RectCorners[UI::QC_TopRight].
Y = ImageDims.
Position.
Y + TexelOffsetY;
166 RectCorners[UI::QC_BottomLeft].
X = ImageDims.
Position.
X + TexelOffsetX; RectCorners[UI::QC_BottomLeft].
Y = (ImageDims.
Position.
Y + ImageDims.
Size.
Y) + TexelOffsetY;
167 RectCorners[UI::QC_BottomRight].
X = (ImageDims.
Position.
X + ImageDims.
Size.
X) + TexelOffsetX; RectCorners[UI::QC_BottomRight].
Y = (ImageDims.
Position.
Y + ImageDims.
Size.
Y) + TexelOffsetY;
172 OuterBorder[UI::QC_TopLeft].
X = RectCorners[UI::QC_TopLeft].
X -
BorderWidth; OuterBorder[UI::QC_TopLeft].
Y = RectCorners[UI::QC_TopLeft].
Y -
BorderWidth;
173 OuterBorder[UI::QC_TopRight].
X = RectCorners[UI::QC_TopRight].
X +
BorderWidth; OuterBorder[UI::QC_TopRight].
Y = RectCorners[UI::QC_TopRight].
Y -
BorderWidth;
174 OuterBorder[UI::QC_BottomLeft].
X = RectCorners[UI::QC_BottomLeft].
X -
BorderWidth; OuterBorder[UI::QC_BottomLeft].
Y = RectCorners[UI::QC_BottomLeft].
Y +
BorderWidth;
175 OuterBorder[UI::QC_BottomRight].
X = RectCorners[UI::QC_BottomRight].
X +
BorderWidth; OuterBorder[UI::QC_BottomRight].
Y = RectCorners[UI::QC_BottomRight].
Y +
BorderWidth;
184 Boole TransparencyCheck = ( 0 == (*ImageIt).FillColours[UI::QC_TopLeft].AlphaChannel && 0 == (*ImageIt).FillColours[UI::QC_TopRight].AlphaChannel &&
185 0 == (*ImageIt).FillColours[UI::QC_BottomLeft].AlphaChannel && 0 == (*ImageIt).FillColours[UI::QC_BottomRight].AlphaChannel );
187 if( !TransparencyCheck ) {
188 this->
DrawFill(RectCorners,(*ImageIt).LayerSprite,(*ImageIt).FillColours);
306 case UI::Gradient_NorthSouth:
314 case UI::Gradient_WestEast:
322 case UI::Gradient_Diagonal_1:
335 case UI::Gradient_Diagonal_2:
370 ImageDataRoot.
AppendAttribute(
"SpriteName").
SetValue( (*ImageIt).LayerSprite ? (*ImageIt).LayerSprite->Name :
"" ) &&
371 ImageDataRoot.
AppendAttribute(
"SpriteAtlas").
SetValue( (*ImageIt).LayerSprite ? (*ImageIt).LayerSprite->GetAtlasName() :
"" ) )
374 (*ImageIt).FillRect.ProtoSerialize( FillRectNode );
378 (*ImageIt).FillColours[UI::QC_TopLeft].ProtoSerialize(TopLeftFillNode);
381 (*ImageIt).FillColours[UI::QC_TopRight].ProtoSerialize(TopRightFillNode);
384 (*ImageIt).FillColours[UI::QC_BottomLeft].ProtoSerialize(BottomLeftFillNode);
387 (*ImageIt).FillColours[UI::QC_BottomRight].ProtoSerialize(BottomRightFillNode);
391 SerializeError(
"Create XML Attribute Values",
"MultiImageData",
true);
407 if( !PropertiesNode.
Empty() ) {
412 if( !CurrAttrib.
Empty() )
420 String SpriteName, SpriteAtlas;
426 CurrAttrib = (*ImageNodeIt).GetAttribute(
"SpriteName");
427 if( !CurrAttrib.
Empty() )
430 CurrAttrib = (*ImageNodeIt).GetAttribute(
"SpriteAtlas");
431 if( !CurrAttrib.
Empty() )
432 SpriteAtlas = CurrAttrib.
AsString();
437 if( !FillRectNode.
Empty() )
438 (*ImageIt).FillRect.ProtoDeSerialize(FillRectNode);
442 if( !TopLeftFillNode.
Empty() )
443 (*ImageIt).FillColours[UI::QC_TopLeft].ProtoDeSerialize(TopLeftFillNode);
446 if( !TopRightFillNode.
Empty() )
447 (*ImageIt).FillColours[UI::QC_TopRight].ProtoDeSerialize(TopRightFillNode);
450 if( !BottomLeftFillNode.
Empty() )
451 (*ImageIt).FillColours[UI::QC_BottomLeft].ProtoDeSerialize(BottomLeftFillNode);
454 if( !BottomRightFillNode.
Empty() )
455 (*ImageIt).FillColours[UI::QC_BottomRight].ProtoDeSerialize(BottomRightFillNode);
471 {
return "MultiImageLayer"; }
virtual const UnifiedVec2 & GetImagePosition(const Whole Index) const
Gets the Unified position of the image at the specified index.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
virtual Boole IsCompletelyTransparent(const Whole Index) const
Gets whether or not this layer is entirely transparent.
virtual void SetImageRect(const Whole Index, const UnifiedRect &Trans)
Sets the Unified position and size of the image at the specified index.
bool Boole
Generally acts a single bit, true or false.
UnifiedVec2 Size
The width and height of this rect.
virtual UI::RenderLayerType GetLayerType() const
Gets the type of render layer this is.
virtual void SetImageSize(const Whole Index, const UnifiedVec2 &Size)
Sets the Unified size of the image at the specified index.
MultiImageLayer(QuadRenderable *ParentRenderable)
Class constructor.
virtual void RotationTransform(Vector2 &Point, const Vector2 &RotationCenter)
Applies rotation to a point in 2D space.
virtual Rect GetAreaRect() const
Gets a rect containing the actual position and size of this layer.
Vector2 Size
Vector2 representing the width and height of the rect.
ImageDataContainer::iterator ImageDataIterator
Iterator type for image metadata being stored by this class.
virtual const UnifiedRect & GetImageRect(const Whole Index) const
Gets the Unified position and size of the image at the specified index.
Thrown when the requested identity could not be found.
QuadCorner
Used by Sprites and Glyphs for tracking their placement on a TextureAtlas.
Node GetFirstChild() const
Get the first child Node of this Node.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
QuadRenderable * Parent
A pointer to the parent of this RenderLayer.
String PriAtlas
This contains the name of the atlas that will be used as default when one isn't specified.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
static ColourValue White()
Creates a ColourValue representing the colour White.
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
~MultiImageData()
Class destructor.
Screen * GetScreen() const
Gets the parent screen of this renderable.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
This class represents a box shaped area on the screen.
This is an image layer that supports rendering of multiple images within it's space.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
virtual void _MarkDirty()
Marks this renderable as well as all parent objects as dirty.
bool Empty() const
Is this storing anything at all?
virtual ~MultiImageLayer()
Class destructor.
float Real
A Datatype used to represent a real floating point number.
bool SetValue(const Char8 *rhs)
Set the value of this.
virtual void RedrawImpl(Boole Force)
Provides the class specific implementation for regenerating vertices for this renderable.
ColourValue FillColours[4]
An array of ColourValues containing the colours to be applied to each corner of the sprite quad...
This class represents a 2D rect which can express the size and position of a renderable on screen...
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
virtual void SetImagePosition(const Whole Index, const UnifiedVec2 &Position)
Sets the Unified position of the image at the specified index.
Real Y
Coordinate on the Y vector.
void DrawFill(const Vector2 *FillRect, const Sprite *FillSprite, const ColourValue *FillColours)
Draws the main rectangle.
Child node iterator (a bidirectional iterator over a collection of Node)
A light-weight handle for manipulating nodes in DOM tree.
iterator begin() const
Get a Child node iterator that references the first child Node.
Real X
Coordinate on the X vector.
virtual MultiImageData & GetMultiImageData(const Whole Index)
Gets a MultiImageData in this layer by index.
UnifiedVec2 Position
The top left position of this rect.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
This is used to represent a point on a 2 dimentional area, such as a screen.
iterator end() const
Get a Child node iterator that references one past the last child Node.
bool Empty() const
Is this storing anything at all?
Gradient
Used by various basic renderables for applying a gradient effect to a colour or texture on a quad...
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
Sprite * GetSprite(const String &SpriteName, const String &Atlas) const
Gets a sprite from an Atlas.
void DrawBorder(const Vector2 *InnerRect, const Vector2 *OuterRect)
Draws the border, if any is set.
This layer is for placing images and basic colours in it's parents' quad space.
Thrown when a passed parameter is checked at runtime and not in the expected range.
Real GetTexelOffsetX() const
Gets the X axis Texel Offset for the current rendersystem.
virtual void ReserveMultiImageData(const Whole NumImages)
Creates space for the specified number of MultiImageData instances to be populated.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
virtual void SetColour(const Whole Index, const ColourValue &Colour)
Sets the colour of the layer.
virtual String GetDerivedSerializableName() const
Gets the most derived serializable name of this Renderable.
virtual const UnifiedVec2 & GetImageSize(const Whole Index) const
Gets the Unified size of the image at the specified index.
virtual Whole GetNumMultiImageData() const
Gets the number of MultiImageData instances currently in this layer.
MultiImageData()
Class constructor.
RenderLayerType
This enum describes the type of RenderLayer this is for use in casting.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Real BorderWidth
The width of the border to render around this layer in pixels.
ImageDataContainer LayerImages
Container storing all of the images/sprites that will be rendered by this layer.
Real BlueChannel
Value from 0.0 to 1.0 representing the amount of blue present in the colour. 1.0 if very blue...
This class represents a point in 2D space using UnifiedDim's.
ImageDataContainer::const_iterator ConstImageDataIterator
ConstIterator type for image metadata being stored by this class.
UnifiedRect FillRect
The rect describing the size and position for the sprite to be rendered.
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
Sprite * LayerSprite
A pointer to the sprite to be rendered.
virtual const ColourValue & GetColour(const Whole Index, const UI::QuadCorner Corner) const
Gets the colour of a corner of this layer.
This represents a nestable quad for an object in a GUI layout.
Vector2 Position
Vector2 representing the top-left position of the rect.
virtual void SetGradient(const Whole Index, const UI::Gradient Grad, const ColourValue &ColourA, const ColourValue &ColourB)
Sets a colour gradient to be applied to this layer.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
Value representing a MultiImageLayer.
Basic class used to describe a portion of a texture to be applied to a Quad.
std::string String
A datatype used to a series of characters.
virtual void SetSprite(const Whole Index, Sprite *NewSprite)
Sets the fill image(if provided in the atlas) of the layer.
Real GetTexelOffsetY() const
Gets the Y axis Texel Offset for the current rendersystem.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Vector2 GetRectCenter() const
Gets the coordinates to the center of this rect.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.