Spinning Topp Logo BlackTopp Studios
inc
imagelayer.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 _uiimagelayer_h
42 #define _uiimagelayer_h
43 
44 #include "UI/renderlayer.h"
45 #include "UI/sprite.h"
46 
47 namespace Mezzanine
48 {
49  namespace UI
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief This layer is for placing images and basic colours in it's parents' quad space.
53  /// @details
54  ///////////////////////////////////////
56  {
57  protected:
58  /// @internal
59  /// @brief An array of colours to be used for each corner section of the border being rendered with this layer.
60  ColourValue BorderColours[4];
61  /// @internal
62  /// @brief The width of the border to render around this layer in pixels.
64 
65  /// @internal
66  /// @brief Draws the border, if any is set.
67  /// @param InnerRect An array of 4 Vector2s storing the 4 points of the inner rect for the border.
68  /// @param OuterRect An array of 4 Vector2s storing the 4 points of the outer rect for the border.
69  void DrawBorder(const Vector2* InnerRect, const Vector2* OuterRect);
70  /// @internal
71  /// @brief Draws the main rectangle.
72  /// @param FillRect An array of 4 Vector2s storing the 4 points of the rect to render.
73  /// @param FillSprite A pointer to the Sprite that will be rendered within the provided rect.
74  /// @param FillColours An array of 4 ColourValues storing the colour to render at each corner.
75  void DrawFill(const Vector2* FillRect, const Sprite* FillSprite, const ColourValue* FillColours);
76  public:
77  /// @brief Class constructor.
78  /// @param ParentRenderable The renderable that created this layer.
79  ImageLayer(QuadRenderable* ParentRenderable);
80  /// @brief Class destructor.
81  virtual ~ImageLayer();
82 
83  ///////////////////////////////////////////////////////////////////////////////
84  // Border Methods
85 
86  /// @brief Sets the width of the border for this renderable.
87  /// @param Width The width to set for the border.
88  virtual void SetBorderWidth(const Real Width);
89  /// @brief Sets the colour of the border for this renderable.
90  /// @param Colour The colour to set for the border.
91  virtual void SetBorderColour(const ColourValue& Colour);
92  /// @brief Sets the colour of one side of the border for this renderable.
93  /// @param Side The side to have the colour applied to.
94  /// @param Colour The colour to be applied.
95  virtual void SetBorderColour(const UI::Border Side, const ColourValue& Colour);
96  /// @brief Sets all parameters for enabling a border.
97  /// @param Width The width to set for the border.
98  /// @param Colour The colour to be applied to all sides of the border.
99  virtual void SetBorder(const Real Width, const ColourValue& Colour);
100  /// @brief Sets all parameters for enabling a border.
101  /// @param Width The width to set for the border.
102  /// @param North The colour to apply to the north side of the border.
103  /// @param South The colour to apply to the south side of the border.
104  /// @param East The colour to apply to the east side of the border.
105  /// @param West The colour to apply to the west side of the border.
106  virtual void SetBorder(const Real Width, const ColourValue& North, const ColourValue& South, const ColourValue& East, const ColourValue& West);
107  /// @brief Disables any border set on this renderable if one is currently set.
108  virtual void NoBorder();
109  /// @brief Gets the border width of this renderable.
110  /// @return Returns a Real with the currently set width of the border.
111  virtual Real GetBorderWidth() const;
112  /// @brief Gets the colour of a border on this renderable.
113  /// @param Side The side to retrieve the colour for.
114  /// @return Returns the colour of the border on the specified side.
115  virtual const ColourValue& GetBorderColour(const UI::Border Side) const;
116 
117  ///////////////////////////////////////////////////////////////////////////////
118  // Serialization
119 
120  /// @copydoc SimpleRenderer::ProtoSerializeProperties(XML::Node&) const
121  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
122  /// @copydoc SimpleRenderer::ProtoDeSerializeProperties(const XML::Node&)
123  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
124 
125  /// @copydoc SimpleRenderer::GetDerivedSerializableName() const
126  virtual String GetDerivedSerializableName() const;
127  /// @copydoc SimpleRenderer::GetSerializableName()
128  static String GetSerializableName();
129  };//ImageLayer
130  }//UI
131 }//Mezzanine
132 
133 #endif
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
This layer is for placing images and basic colours in it's parents' quad space.
Definition: imagelayer.h:55
#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
Real BorderWidth
The width of the border to render around this layer in pixels.
Definition: imagelayer.h:63
This represents a nestable quad for an object in a GUI layout.
Border
Used by various basic renderables for border effects.
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 the base class for the types of layers that can be added to a renderable. ...
Definition: renderlayer.h:58