Spinning Topp Logo BlackTopp Studios
inc
multiimagelayer.h
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_h
42 #define _uimultiimagelayer_h
43 
44 #include "UI/imagelayer.h"
45 #include "UI/unifieddim.h"
46 
47 namespace Mezzanine
48 {
49  namespace UI
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief This is an image layer that supports rendering of multiple images within it's space.
53  /// @details
54  ///////////////////////////////////////
56  {
57  public:
58  ///////////////////////////////////////////////////////////////////////////////
59  // Public Data Members
60 
61  /// @brief An array of ColourValues containing the colours to be applied to each corner of the sprite quad.
62  ColourValue FillColours[4];
63  /// @brief The rect describing the size and position for the sprite to be rendered.
65  /// @brief A pointer to the sprite to be rendered.
67 
68  ///////////////////////////////////////////////////////////////////////////////
69  // Construction and Destruction
70 
71  /// @brief Class constructor.
73  /// @brief Class destructor.
74  ~MultiImageData();
75 
76  /*///////////////////////////////////////////////////////////////////////////////
77  // Serialization
78 
79  /// @brief Convert this class to an XML::Node ready for serialization.
80  /// @param ParentNode The point in the XML hierarchy that all this MultiImageData should be appended to.
81  void ProtoSerialize(XML::Node& ParentNode) const;
82  /// @brief Take the data stored in an XML Node and overwrite this object with it.
83  /// @param SelfRoot An XML::Node containing the data to populate this class with.
84  void ProtoDeSerialize(const XML::Node& SelfRoot);
85  /// @brief Get the name of the the XML tag the class will leave behind as its instances are serialized.
86  /// @return A string containing the name of this class.
87  static String GetSerializableName();// */
88  };//MultiImageData
89 
90  ///////////////////////////////////////////////////////////////////////////////
91  /// @brief This is an image layer that supports rendering of multiple images within it's space.
92  /// @details
93  ///////////////////////////////////////
95  {
96  public:
97  /// @brief Container type for the image metadata storage in this class.
98  typedef std::vector< MultiImageData > ImageDataContainer;
99  /// @brief Iterator type for image metadata being stored by this class.
100  typedef ImageDataContainer::iterator ImageDataIterator;
101  /// @brief ConstIterator type for image metadata being stored by this class.
102  typedef ImageDataContainer::const_iterator ConstImageDataIterator;
103  protected:
104  /// @internal
105  /// @brief Container storing all of the images/sprites that will be rendered by this layer.
106  ImageDataContainer LayerImages;
107 
108  /// @copydoc SimpleRenderer::RedrawImpl(Boole Force)
109  virtual void RedrawImpl(Boole Force);
110  public:
111  /// @brief Class constructor.
112  /// @param ParentRenderable The renderable that created this layer.
113  MultiImageLayer(QuadRenderable* ParentRenderable);
114  /// @brief Class destructor.
115  virtual ~MultiImageLayer();
116 
117  ///////////////////////////////////////////////////////////////////////////////
118  // Utility
119 
120  /// @copydoc RenderLayer::GetLayerType() const
121  virtual UI::RenderLayerType GetLayerType() const;
122 
123  ///////////////////////////////////////////////////////////////////////////////
124  // MultiImageData Configuration
125 
126  /// @brief Creates space for the specified number of MultiImageData instances to be populated.
127  /// @param NumImages The number of images to reserve space in this layer for.
128  virtual void ReserveMultiImageData(const Whole NumImages);
129  /// @brief Gets a MultiImageData in this layer by index.
130  /// @param Index The index of the MultiImageData to retrieve.
131  /// @return Returns a reference to the MultiImageData at the specified index.
132  virtual MultiImageData& GetMultiImageData(const Whole Index);
133  /// @brief Gets a MultiImageData in this layer by index.
134  /// @param Index The index of the MultiImageData to retrieve.
135  /// @return Returns a const reference to the MultiImageData at the specified index.
136  virtual const MultiImageData& GetMultiImageData(const Whole Index) const;
137  /// @brief Gets the number of MultiImageData instances currently in this layer.
138  /// @return Returns the number of images this layer is currently configured to support.
139  virtual Whole GetNumMultiImageData() const;
140 
141  ///////////////////////////////////////////////////////////////////////////////
142  // Fill Methods
143 
144  /// @brief Sets the Unified position and size of the image at the specified index.
145  /// @param Index The index of the MultiImageData to update.
146  /// @param Trans The UnifiedRect to be applied to the Image at the specified index.
147  virtual void SetImageRect(const Whole Index, const UnifiedRect& Trans);
148  /// @brief Gets the Unified position and size of the image at the specified index.
149  /// @param Index The index of the MultiImageData to update.
150  /// @return Returns a const Reference to the UnifiedRect to be applied to the image at the specified index.
151  virtual const UnifiedRect& GetImageRect(const Whole Index) const;
152  /// @brief Sets the Unified position of the image at the specified index.
153  /// @param Index The index of the MultiImageData to update.
154  /// @param Position The UnifiedVec2 describing the position to be applied to the image at the specified index.
155  virtual void SetImagePosition(const Whole Index, const UnifiedVec2& Position);
156  /// @brief Gets the Unified position of the image at the specified index.
157  /// @param Index The index of the MultiImageData to update.
158  /// @return Returns a const Reference to the Unified position to be applied to the image at the specified index.
159  virtual const UnifiedVec2& GetImagePosition(const Whole Index) const;
160  /// @brief Sets the Unified size of the image at the specified index.
161  /// @param Index The index of the MultiImageData to update.
162  /// @param Size The UnifiedVec2 describing the size to be applied to the image at the specified index.
163  virtual void SetImageSize(const Whole Index, const UnifiedVec2& Size);
164  /// @brief Gets the Unified size of the image at the specified index.
165  /// @param Index The index of the MultiImageData to update.
166  /// @return Returns a const Reference to the Unified size to be applied to the image at the specified index.
167  virtual const UnifiedVec2& GetImageSize(const Whole Index) const;
168 
169  /// @brief Sets the colour of the layer.
170  /// @param Index The index of the MultiImageData to update.
171  /// @param Colour A colour value representing the colour to be set.
172  virtual void SetColour(const Whole Index, const ColourValue& Colour);
173  /// @brief Sets the colour for one corner the layer.
174  /// @param Index The index of the MultiImageData to update.
175  /// @param Corner Which corner the colour should be applied to.
176  /// @param Colour A colour value representing the colour to be set.
177  virtual void SetColour(const Whole Index, const UI::QuadCorner Corner, const ColourValue& Colour);
178  /// @brief Gets the colour of a corner of this layer.
179  /// @param Index The index of the MultiImageData to update.
180  /// @param Corner The corner to get the colour for.
181  /// @return Returns the colour of the specified corner.
182  virtual const ColourValue& GetColour(const Whole Index, const UI::QuadCorner Corner) const;
183  /// @brief Gets whether or not this layer is entirely transparent.
184  /// @param Index The index of the MultiImageData to update.
185  /// @return Returns true if all quad corners of this layer have their value set to zero, false otherwise.
186  virtual Boole IsCompletelyTransparent(const Whole Index) const;
187 
188  /// @brief Sets the fill image(if provided in the atlas) of the layer.
189  /// @param Index The index of the MultiImageData to update.
190  /// @param NewSprite A pointer to the sprite to set as the fill.
191  virtual void SetSprite(const Whole Index, Sprite* NewSprite);
192  /// @brief Sets the fill image(if provided in the atlas) of the layer.
193  /// @param Index The index of the MultiImageData to update.
194  /// @param SpriteName The name of the sprite to set as the fill.
195  virtual void SetSprite(const Whole Index, const String& SpriteName);
196  /// @brief Sets the fill image(if provided in the atlas) of the layer.
197  /// @param Index The index of the MultiImageData to update.
198  /// @param SpriteName The name of the sprite to set as the fill.
199  /// @param Atlas The Atlas to load the sprite from.
200  virtual void SetSprite(const Whole Index, const String& SpriteName, const String& Atlas);
201 
202  /// @brief Sets a colour gradient to be applied to this layer.
203  /// @param Index The index of the MultiImageData to update.
204  /// @param Grad The direction/style of gradient to enable.
205  /// @param ColourA The colour to apply to the first side of the gradient.
206  /// @param ColourB The colour to apply to the second side of the gradient.
207  virtual void SetGradient(const Whole Index, const UI::Gradient Grad, const ColourValue& ColourA, const ColourValue& ColourB);
208 
209  ///////////////////////////////////////////////////////////////////////////////
210  // Serialization
211 
212  /// @copydoc SimpleRenderer::ProtoSerializeProperties(XML::Node&) const
213  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
214  /// @copydoc SimpleRenderer::ProtoDeSerializeProperties(const XML::Node&)
215  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
216 
217  /// @copydoc SimpleRenderer::GetDerivedSerializableName() const
218  virtual String GetDerivedSerializableName() const;
219  /// @copydoc SimpleRenderer::GetSerializableName()
220  static String GetSerializableName();
221  };//MultiImageLayer
222  }//UI
223 }//Mezzanine
224 
225 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
std::vector< MultiImageData > ImageDataContainer
Container type for the image metadata storage in this class.
ImageDataContainer::iterator ImageDataIterator
Iterator type for image metadata being stored by this class.
QuadCorner
Used by Sprites and Glyphs for tracking their placement on a TextureAtlas.
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
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
Gradient
Used by various basic renderables for applying a gradient effect to a colour or texture on a quad...
This layer is for placing images and basic colours in it's parents' quad space.
Definition: imagelayer.h:55
RenderLayerType
This enum describes the type of RenderLayer this is for use in casting.
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
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
ImageDataContainer LayerImages
Container storing all of the images/sprites that will be rendered by this layer.
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.
Sprite * LayerSprite
A pointer to the sprite to be rendered.
This represents a nestable quad for an object in a GUI layout.
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
This is an image layer that supports rendering of multiple images within it's space.