Spinning Topp Logo BlackTopp Studios
inc
multiimagelayer.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _uimultiimagelayer_cpp
42 #define _uimultiimagelayer_cpp
43 
44 #include "UI/multiimagelayer.h"
45 #include "UI/quadrenderable.h"
46 #include "UI/screen.h"
47 
48 namespace Mezzanine
49 {
50  namespace UI
51  {
52  ///////////////////////////////////////////////////////////////////////////////
53  // MultiImageData Methods
54 
56  LayerSprite(NULL)
57  {
58  this->FillColours[UI::QC_TopLeft] = ColourValue::White();
59  this->FillColours[UI::QC_TopRight] = ColourValue::White();
60  this->FillColours[UI::QC_BottomLeft] = ColourValue::White();
61  this->FillColours[UI::QC_BottomRight] = ColourValue::White();
62  }
63 
65  { }
66 
67  /*///////////////////////////////////////////////////////////////////////////////
68  // Serialization
69 
70  void MultiImageData::ProtoSerialize(XML::Node& ParentNode) const
71  {
72  XML::Node SelfRoot = ParentNode.AppendChild( MultiImageData::GetSerializableName() );
73 
74  if( SelfRoot.AppendAttribute("Version").SetValue("1") &&
75  SelfRoot.AppendAttribute("SpriteName").SetValue( this->LayerSprite ? this->LayerSprite->Name : "" ) )
76  {
77  XML::Node FillRectNode = SelfRoot.AppendChild("FillRect");
78  this->FillRect.ProtoSerialize( FillRectNode );
79 
80  XML::Node FillColoursNode = SelfRoot.AppendChild("FillColours");
81  XML::Node TopLeftFillNode = FillColoursNode.AppendChild("TopLeft");
82  this->FillColours[UI::QC_TopLeft].ProtoSerialize(TopLeftFillNode);
83 
84  XML::Node TopRightFillNode = FillColoursNode.AppendChild("TopRight");
85  this->FillColours[UI::QC_TopRight].ProtoSerialize(TopRightFillNode);
86 
87  XML::Node BottomLeftFillNode = FillColoursNode.AppendChild("BottomLeft");
88  this->FillColours[UI::QC_BottomLeft].ProtoSerialize(BottomLeftFillNode);
89 
90  XML::Node BottomRightFillNode = FillColoursNode.AppendChild("BottomRight");
91  this->FillColours[UI::QC_BottomRight].ProtoSerialize(BottomRightFillNode);
92 
93  return;
94  }else{
95  SerializeError("Create XML Attribute Values",MultiImageData::GetSerializableName(),true);
96  }
97  }
98 
99  void MultiImageData::ProtoDeSerialize(const XML::Node& SelfRoot)
100  {
101  XML::Attribute CurrAttrib;
102  if( SelfRoot.Name() == MultiImageData::GetSerializableName() ) {
103  if(SelfRoot.GetAttribute("Version").AsInt() == 1) {
104  CurrAttrib = SelfRoot.GetAttribute("SpriteName");
105  if( !CurrAttrib.Empty() )
106  this->SetSprite( CurrAttrib.AsString() );
107 
108  XML::Node FillRectNode = SelfRoot.GetChild("FillRect").GetFirstChild();
109  if( !FillRectNode.Empty() )
110  this->FillRect.ProtoDeSerialize(FillRectNode);
111 
112  XML::Node FillColoursNode = SelfRoot.GetChild("FillColours");
113  XML::Node TopLeftFillNode = FillColoursNode.GetChild("TopLeft").GetFirstChild();
114  if( !TopLeftFillNode.Empty() )
115  this->FillColours[UI::QC_TopLeft].ProtoDeSerialize(TopLeftFillNode);
116 
117  XML::Node TopRightFillNode = FillColoursNode.GetChild("TopRight").GetFirstChild();
118  if( !TopRightFillNode.Empty() )
119  this->FillColours[UI::QC_TopRight].ProtoDeSerialize(TopRightFillNode);
120 
121  XML::Node BottomLeftFillNode = FillColoursNode.GetChild("BottomLeft").GetFirstChild();
122  if( !BottomLeftFillNode.Empty() )
123  this->FillColours[UI::QC_BottomLeft].ProtoDeSerialize(BottomLeftFillNode);
124 
125  XML::Node BottomRightFillNode = FillColoursNode.GetChild("BottomRight").GetFirstChild();
126  if( !BottomRightFillNode.Empty() )
127  this->FillColours[UI::QC_BottomRight].ProtoDeSerialize(BottomRightFillNode);
128  }else{
129  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + MultiImageData::GetSerializableName() + ": Not Version 1.");
130  }
131  }else{
132  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,MultiImageData::GetSerializableName() + " was not found in the provided XML node, which was expected.");
133  }
134  }
135 
136  String MultiImageData::GetSerializableName()
137  { return "MultiImageData"; }// */
138 
139  ///////////////////////////////////////////////////////////////////////////////
140  // MultiImageLayer Methods
141 
143  ImageLayer(ParentRenderable)
144  { }
145 
147  { }
148 
150  {
151  // Get the Texel Offsets
152  Real TexelOffsetX = this->Parent->GetScreen()->GetTexelOffsetX();
153  Real TexelOffsetY = this->Parent->GetScreen()->GetTexelOffsetY();
154 
155  // Get the parent rect and apply the scaling
156  Rect ActDims = this->GetAreaRect();
157  Vector2 RectCenter = ActDims.GetRectCenter();
158 
159  for( ImageDataIterator ImageIt = this->LayerImages.begin() ; ImageIt != this->LayerImages.end() ; ++ImageIt )
160  {
161  Rect ImageDims = (*ImageIt).FillRect.CalculateActualDimensions( ActDims );
162  // Apply the texel offsets
163  Vector2 RectCorners[4];
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;
168 
169  // Border and rotation
170  if( 0.0 != this->BorderWidth ) {
171  Vector2 OuterBorder[4];
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;
176 
177  this->RotationTransform(RectCorners,RectCenter);
178  this->RotationTransform(OuterBorder,RectCenter);
179  this->DrawBorder(RectCorners,OuterBorder);
180  }else{
181  this->RotationTransform(RectCorners,RectCenter);
182  }
183 
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 );
186  // Fill
187  if( !TransparencyCheck ) {
188  this->DrawFill(RectCorners,(*ImageIt).LayerSprite,(*ImageIt).FillColours);
189  }
190  }
191  }
192 
193  ///////////////////////////////////////////////////////////////////////////////
194  // Utility
195 
197  { return UI::RLT_MultiImage; }
198 
199  ///////////////////////////////////////////////////////////////////////////////
200  // MultiImageData Configuration
201 
203  { this->LayerImages.resize(NumImages); }
204 
206  { return this->LayerImages.at(Index); }
207 
209  { return this->LayerImages.at(Index); }
210 
212  { return this->LayerImages.size(); }
213 
214  ///////////////////////////////////////////////////////////////////////////////
215  // Fill Methods
216 
217  void MultiImageLayer::SetImageRect(const Whole Index, const UnifiedRect& Trans)
218  {
219  this->GetMultiImageData(Index).FillRect = Trans;
220  this->_MarkDirty();
221  }
222 
224  {
225  return this->GetMultiImageData(Index).FillRect;
226  }
227 
228  void MultiImageLayer::SetImagePosition(const Whole Index, const UnifiedVec2& Position)
229  {
230  this->GetMultiImageData(Index).FillRect.Position = Position;
231  this->_MarkDirty();
232  }
233 
235  {
236  return this->GetMultiImageData(Index).FillRect.Position;
237  }
238 
239  void MultiImageLayer::SetImageSize(const Whole Index, const UnifiedVec2& Size)
240  {
241  this->GetMultiImageData(Index).FillRect.Size = Size;
242  this->_MarkDirty();
243  }
244 
246  {
247  return this->GetMultiImageData(Index).FillRect.Size;
248  }
249 
250  void MultiImageLayer::SetColour(const Whole Index, const ColourValue& Colour)
251  {
252  MultiImageData& Data = this->GetMultiImageData(Index);
253  Data.FillColours[UI::QC_TopLeft] = Colour;
254  Data.FillColours[UI::QC_TopRight] = Colour;
255  Data.FillColours[UI::QC_BottomLeft] = Colour;
256  Data.FillColours[UI::QC_BottomRight] = Colour;
257  this->_MarkDirty();
258  }
259 
260  void MultiImageLayer::SetColour(const Whole Index, const UI::QuadCorner Corner, const ColourValue& Colour)
261  {
262  this->GetMultiImageData(Index).FillColours[Corner] = Colour;
263  this->_MarkDirty();
264  }
265 
266  const ColourValue& MultiImageLayer::GetColour(const Whole Index, const UI::QuadCorner Corner) const
267  {
268  return this->GetMultiImageData(Index).FillColours[Corner];
269  }
270 
272  {
273  const MultiImageData& Data = this->GetMultiImageData(Index);
274  return ( 0 == Data.FillColours[UI::QC_TopLeft].AlphaChannel &&
275  0 == Data.FillColours[UI::QC_TopRight].AlphaChannel &&
276  0 == Data.FillColours[UI::QC_BottomLeft].AlphaChannel &&
277  0 == Data.FillColours[UI::QC_BottomRight].AlphaChannel );
278  }
279 
280  void MultiImageLayer::SetSprite(const Whole Index, Sprite* NewSprite)
281  {
282  MultiImageData& Data = this->GetMultiImageData(Index);
283  if( Data.LayerSprite != NewSprite ) {
284  Data.LayerSprite = NewSprite;
285  this->_MarkDirty();
286  }
287  }
288 
289  void MultiImageLayer::SetSprite(const Whole Index, const String& SpriteName)
290  {
291  Sprite* NewSprite = this->Parent->GetScreen()->GetSprite(SpriteName,PriAtlas);
292  this->SetSprite(Index,NewSprite);
293  }
294 
295  void MultiImageLayer::SetSprite(const Whole Index, const String& SpriteName, const String& Atlas)
296  {
297  Sprite* NewSprite = this->Parent->GetScreen()->GetSprite(SpriteName,Atlas);
298  this->SetSprite(Index,NewSprite);
299  }
300 
301  void MultiImageLayer::SetGradient(const Whole Index, const UI::Gradient Grad, const ColourValue& ColourA, const ColourValue& ColourB)
302  {
303  MultiImageData& Data = this->GetMultiImageData(Index);
304  switch(Grad)
305  {
306  case UI::Gradient_NorthSouth:
307  {
308  Data.FillColours[UI::QC_TopLeft] = ColourA;
309  Data.FillColours[UI::QC_TopRight] = ColourA;
310  Data.FillColours[UI::QC_BottomRight] = ColourB;
311  Data.FillColours[UI::QC_BottomLeft] = ColourB;
312  break;
313  }
314  case UI::Gradient_WestEast:
315  {
316  Data.FillColours[UI::QC_TopLeft] = ColourA;
317  Data.FillColours[UI::QC_BottomLeft] = ColourA;
318  Data.FillColours[UI::QC_TopRight] = ColourB;
319  Data.FillColours[UI::QC_BottomRight] = ColourB;
320  break;
321  }
322  case UI::Gradient_Diagonal_1:
323  {
324  ColourValue Average;
325  Average.RedChannel = (ColourA.RedChannel + ColourB.RedChannel) * 0.5f;
326  Average.GreenChannel = (ColourA.GreenChannel + ColourB.GreenChannel) * 0.5f;
327  Average.BlueChannel = (ColourA.BlueChannel + ColourB.BlueChannel) * 0.5f;
328  Average.AlphaChannel = (ColourA.AlphaChannel + ColourB.AlphaChannel) * 0.5f;
329  Data.FillColours[UI::QC_TopLeft] = ColourA;
330  Data.FillColours[UI::QC_TopRight] = Average;
331  Data.FillColours[UI::QC_BottomRight] = ColourB;
332  Data.FillColours[UI::QC_BottomLeft] = Average;
333  break;
334  }
335  case UI::Gradient_Diagonal_2:
336  {
337  ColourValue Average;
338  Average.RedChannel = (ColourA.RedChannel + ColourB.RedChannel) * 0.5f;
339  Average.GreenChannel = (ColourA.GreenChannel + ColourB.GreenChannel) * 0.5f;
340  Average.BlueChannel = (ColourA.BlueChannel + ColourB.BlueChannel) * 0.5f;
341  Average.AlphaChannel = (ColourA.AlphaChannel + ColourB.AlphaChannel) * 0.5f;
342  Data.FillColours[UI::QC_TopLeft] = Average;
343  Data.FillColours[UI::QC_TopRight] = ColourA;
344  Data.FillColours[UI::QC_BottomRight] = Average;
345  Data.FillColours[UI::QC_BottomLeft] = ColourB;
346  break;
347  }
348  }
349  this->_MarkDirty();
350  }
351 
352  ///////////////////////////////////////////////////////////////////////////////
353  // Serialization
354 
356  {
357  this->ImageLayer::ProtoSerializeProperties(SelfRoot);
358  XML::Node PropertiesNode = SelfRoot.AppendChild( MultiImageLayer::GetSerializableName() + "Properties" );
359 
360  if( PropertiesNode.AppendAttribute("Version").SetValue("1") )
361  {
362  XML::Node LayerImagesNode = PropertiesNode.AppendChild( "LayerImages" );
363  LayerImagesNode.AppendAttribute("NumImages").SetValue( this->LayerImages.size() );
364 
365  for( ConstImageDataIterator ImageIt = this->LayerImages.begin() ; ImageIt != this->LayerImages.end() ; ++ImageIt )
366  {
367  XML::Node ImageDataRoot = LayerImagesNode.AppendChild( "MultiImageData" );
368 
369  if( ImageDataRoot.AppendAttribute("Version").SetValue("1") &&
370  ImageDataRoot.AppendAttribute("SpriteName").SetValue( (*ImageIt).LayerSprite ? (*ImageIt).LayerSprite->Name : "" ) &&
371  ImageDataRoot.AppendAttribute("SpriteAtlas").SetValue( (*ImageIt).LayerSprite ? (*ImageIt).LayerSprite->GetAtlasName() : "" ) )
372  {
373  XML::Node FillRectNode = ImageDataRoot.AppendChild("FillRect");
374  (*ImageIt).FillRect.ProtoSerialize( FillRectNode );
375 
376  XML::Node FillColoursNode = ImageDataRoot.AppendChild("FillColours");
377  XML::Node TopLeftFillNode = FillColoursNode.AppendChild("TopLeft");
378  (*ImageIt).FillColours[UI::QC_TopLeft].ProtoSerialize(TopLeftFillNode);
379 
380  XML::Node TopRightFillNode = FillColoursNode.AppendChild("TopRight");
381  (*ImageIt).FillColours[UI::QC_TopRight].ProtoSerialize(TopRightFillNode);
382 
383  XML::Node BottomLeftFillNode = FillColoursNode.AppendChild("BottomLeft");
384  (*ImageIt).FillColours[UI::QC_BottomLeft].ProtoSerialize(BottomLeftFillNode);
385 
386  XML::Node BottomRightFillNode = FillColoursNode.AppendChild("BottomRight");
387  (*ImageIt).FillColours[UI::QC_BottomRight].ProtoSerialize(BottomRightFillNode);
388 
389  return;
390  }else{
391  SerializeError("Create XML Attribute Values","MultiImageData",true);
392  }
393  }
394 
395  return;
396  }else{
397  SerializeError("Create XML Attribute Values",MultiImageLayer::GetSerializableName() + "Properties",true);
398  }
399  }
400 
402  {
404  XML::Attribute CurrAttrib;
405  XML::Node PropertiesNode = SelfRoot.GetChild( MultiImageLayer::GetSerializableName() + "Properties" );
406 
407  if( !PropertiesNode.Empty() ) {
408  if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
409  XML::Node LayerImagesNode = PropertiesNode.GetChild( MultiImageLayer::GetSerializableName() + "Properties" );
410 
411  CurrAttrib = LayerImagesNode.GetAttribute("NumImages");
412  if( !CurrAttrib.Empty() )
413  this->ReserveMultiImageData( CurrAttrib.AsWhole() );
414 
415  /// @todo This loop expects the listed order in the XML to match the order in which they were serialized. Within PugiXML at least this
416  /// shouldn't be a problem, however if Images start appearing out of order it may be worthwhile to investigate or add some ordering redundancy.
417  ImageDataIterator ImageIt = this->LayerImages.begin();
418  for( XML::NodeIterator ImageNodeIt = LayerImagesNode.begin() ; ImageNodeIt != LayerImagesNode.end() ; ++ImageNodeIt )
419  {
420  String SpriteName, SpriteAtlas;
421 
422  if( ImageIt == this->LayerImages.end() ) {
423  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Seriailzed value for \"NumImages\" is smaller than number of nodes to deserialize. Verify serialized XML.");
424  }
425 
426  CurrAttrib = (*ImageNodeIt).GetAttribute("SpriteName");
427  if( !CurrAttrib.Empty() )
428  SpriteName = CurrAttrib.AsString();
429 
430  CurrAttrib = (*ImageNodeIt).GetAttribute("SpriteAtlas");
431  if( !CurrAttrib.Empty() )
432  SpriteAtlas = CurrAttrib.AsString();
433 
434  (*ImageIt).LayerSprite = this->Parent->GetScreen()->GetSprite(SpriteName,SpriteAtlas);
435 
436  XML::Node FillRectNode = (*ImageNodeIt).GetChild("FillRect").GetFirstChild();
437  if( !FillRectNode.Empty() )
438  (*ImageIt).FillRect.ProtoDeSerialize(FillRectNode);
439 
440  XML::Node FillColoursNode = (*ImageNodeIt).GetChild("FillColours");
441  XML::Node TopLeftFillNode = FillColoursNode.GetChild("TopLeft").GetFirstChild();
442  if( !TopLeftFillNode.Empty() )
443  (*ImageIt).FillColours[UI::QC_TopLeft].ProtoDeSerialize(TopLeftFillNode);
444 
445  XML::Node TopRightFillNode = FillColoursNode.GetChild("TopRight").GetFirstChild();
446  if( !TopRightFillNode.Empty() )
447  (*ImageIt).FillColours[UI::QC_TopRight].ProtoDeSerialize(TopRightFillNode);
448 
449  XML::Node BottomLeftFillNode = FillColoursNode.GetChild("BottomLeft").GetFirstChild();
450  if( !BottomLeftFillNode.Empty() )
451  (*ImageIt).FillColours[UI::QC_BottomLeft].ProtoDeSerialize(BottomLeftFillNode);
452 
453  XML::Node BottomRightFillNode = FillColoursNode.GetChild("BottomRight").GetFirstChild();
454  if( !BottomRightFillNode.Empty() )
455  (*ImageIt).FillColours[UI::QC_BottomRight].ProtoDeSerialize(BottomRightFillNode);
456 
457  ++ImageIt;
458  }
459  }else{
460  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (String("MultiImageData") + "Properties") + ": Not Version 1.");
461  }
462  }else{
463  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,String("MultiImageData") + "Properties" + " was not found in the provided XML node, which was expected.");
464  }
465  }
466 
469 
471  { return "MultiImageLayer"; }
472  }//UI
473 }//Mezzanine
474 
475 #endif
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.
Definition: imagelayer.cpp:171
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.
Definition: attribute.h:74
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.
Definition: datatypes.h:173
UnifiedVec2 Size
The width and height of this rect.
Definition: unifieddim.h:670
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.
Definition: renderlayer.cpp:64
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.
Definition: rect.h:71
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.
Definition: exception.h:94
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.
Definition: exception.h:3048
QuadRenderable * Parent
A pointer to the parent of this RenderLayer.
Definition: renderlayer.h:67
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...
Definition: exception.h:112
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.
Definition: renderable.cpp:80
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.
Definition: rect.h:55
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...
Definition: colourvalue.h:64
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.
Definition: datatypes.h:141
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...
Definition: unifieddim.h:661
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...
Definition: colourvalue.h:73
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.
Definition: vector2.h:69
void DrawFill(const Vector2 *FillRect, const Sprite *FillSprite, const ColourValue *FillColours)
Draws the main rectangle.
Definition: imagelayer.cpp:90
Child node iterator (a bidirectional iterator over a collection of Node)
Definition: nodeiterator.h:77
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
iterator begin() const
Get a Child node iterator that references the first child Node.
Real X
Coordinate on the X vector.
Definition: vector2.h:67
virtual MultiImageData & GetMultiImageData(const Whole Index)
Gets a MultiImageData in this layer by index.
UnifiedVec2 Position
The top left position of this rect.
Definition: unifieddim.h:668
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.
Definition: vector2.h:63
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...
Definition: colourvalue.h:79
Sprite * GetSprite(const String &SpriteName, const String &Atlas) const
Gets a sprite from an Atlas.
Definition: screen.cpp:886
void DrawBorder(const Vector2 *InnerRect, const Vector2 *OuterRect)
Draws the border, if any is set.
Definition: imagelayer.cpp:64
This layer is for placing images and basic colours in it's parents' quad space.
Definition: imagelayer.h:55
Thrown when a passed parameter is checked at runtime and not in the expected range.
Definition: exception.h:110
Real GetTexelOffsetX() const
Gets the X axis Texel Offset for the current rendersystem.
Definition: screen.cpp:898
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...
Definition: imagelayer.cpp:199
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.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Real BorderWidth
The width of the border to render around this layer in pixels.
Definition: imagelayer.h:63
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...
Definition: colourvalue.h:76
This class represents a point in 2D space using UnifiedDim's.
Definition: unifieddim.h:306
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...
Definition: colourvalue.h:70
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.
Definition: rect.h:69
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.
Definition: sprite.h:55
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
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.
Definition: screen.cpp:901
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.
Definition: rect.h:186
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.