Spinning Topp Logo BlackTopp Studios
inc
singleimagelayer.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 _uisingleimagelayer_h
42 #define _uisingleimagelayer_h
43 
44 #include "UI/imagelayer.h"
45 
46 namespace Mezzanine
47 {
48  namespace UI
49  {
50  ///////////////////////////////////////////////////////////////////////////////
51  /// @brief This is an image layer that supports rendering only a single image/sprite.
52  /// @details
53  ///////////////////////////////////////
55  {
56  protected:
57  /// @internal
58  /// @brief An array of colours to be used for each corner section of this layer.
59  ColourValue FillColours[4];
60  /// @internal
61  /// @brief A pointer to the sprite that will be rendered by this layer.
63 
64  /// @copydoc SimpleRenderer::RedrawImpl(Boole Force)
65  virtual void RedrawImpl(Boole Force);
66  public:
67  /// @brief Class constructor.
68  /// @param ParentRenderable The renderable that created this layer.
69  SingleImageLayer(QuadRenderable* ParentRenderable);
70  /// @brief Class destructor.
71  virtual ~SingleImageLayer();
72 
73  ///////////////////////////////////////////////////////////////////////////////
74  // Utility
75 
76  /// @copydoc RenderLayer::GetLayerType() const
77  virtual UI::RenderLayerType GetLayerType() const;
78 
79  ///////////////////////////////////////////////////////////////////////////////
80  // Fill Methods
81 
82  /// @brief Sets the colour of the layer.
83  /// @param Colour A colour value representing the colour to be set.
84  virtual void SetColour(const ColourValue& Colour);
85  /// @brief Sets the colour for one corner the layer.
86  /// @param Corner Which corner the colour should be applied to.
87  /// @param Colour A colour value representing the colour to be set.
88  virtual void SetColour(const UI::QuadCorner Corner, const ColourValue& Colour);
89  /// @brief Gets the colour of a corner of this layer.
90  /// @param Corner The corner to get the colour for.
91  /// @return Returns the colour of the specified corner.
92  virtual const ColourValue& GetColour(const UI::QuadCorner Corner) const;
93  /// @brief Gets whether or not this layer is entirely transparent.
94  /// @return Returns true if all quad corners of this layer have their value set to zero, false otherwise.
95  virtual Boole IsCompletelyTransparent() const;
96 
97  /// @brief Sets the fill image(if provided in the atlas) of the layer.
98  /// @param NewSprite A pointer to the sprite to set as the fill.
99  virtual void SetSprite(Sprite* NewSprite);
100  /// @brief Sets the fill image(if provided in the atlas) of the layer.
101  /// @param SpriteName The name of the sprite to set as the fill.
102  virtual void SetSprite(const String& SpriteName);
103  /// @brief Sets the fill image(if provided in the atlas) of the layer.
104  /// @param SpriteName The name of the sprite to set as the fill.
105  /// @param Atlas The Atlas to load the sprite from.
106  virtual void SetSprite(const String& SpriteName, const String& Atlas);
107 
108  /// @brief Sets a colour gradient to be applied to this layer.
109  /// @param Grad The direction/style of gradient to enable.
110  /// @param ColourA The colour to apply to the first side of the gradient.
111  /// @param ColourB The colour to apply to the second side of the gradient.
112  virtual void SetGradient(const UI::Gradient Grad, const ColourValue& ColourA, const ColourValue& ColourB);
113 
114  ///////////////////////////////////////////////////////////////////////////////
115  // Serialization
116 
117  /// @copydoc SimpleRenderer::ProtoSerializeProperties(XML::Node&) const
118  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
119  /// @copydoc SimpleRenderer::ProtoDeSerializeProperties(const XML::Node&)
120  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
121 
122  /// @copydoc SimpleRenderer::GetDerivedSerializableName() const
123  virtual String GetDerivedSerializableName() const;
124  /// @copydoc SimpleRenderer::GetSerializableName()
125  static String GetSerializableName();
126  };//SingleImageLayer
127  }//UI
128 }//Mezzanine
129 
130 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
QuadCorner
Used by Sprites and Glyphs for tracking their placement on a TextureAtlas.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
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
Sprite * LayerSprite
A pointer to the sprite that will be rendered by this layer.
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
This represents a nestable quad for an object in a GUI layout.
This is an image layer that supports rendering only a single image/sprite.
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