Spinning Topp Logo BlackTopp Studios
inc
renderlayer.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 _uirenderlayer_h
42 #define _uirenderlayer_h
43 
44 #include "UI/quadrenderer.h"
45 #include "UI/rect.h"
46 #include "UI/uienumerations.h"
47 
48 namespace Mezzanine
49 {
50  namespace UI
51  {
52  class QuadRenderable;
53  class Screen;
54  ///////////////////////////////////////////////////////////////////////////////
55  /// @brief This is the base class for the types of layers that can be added to a renderable.
56  /// @details
57  ///////////////////////////////////////
59  {
60  public:
61  protected:
62  /// @internal
63  /// @brief The scaling applied to this RenderLayer.
65  /// @internal
66  /// @brief A pointer to the parent of this RenderLayer.
68  /// @internal
69  /// @brief Stores the index of this RenderLayer in it's parent QuadRenderable.
71  /// @internal
72  /// @brief The amount of rotation to be applied to this RenderLayer in radians.
74 
75  /// @internal
76  /// @brief Applies rotation to a point in 2D space.
77  /// @param Point A point in 2D space that will be rotated around another point.
78  /// @param RotationCenter The point that will be rotated around.
79  virtual void RotationTransform(Vector2& Point, const Vector2& RotationCenter);
80  /// @internal
81  /// @brief Applies rotation to a quad in 2D space.
82  /// @note This overload will use the center of the quad defined by the 4 points as the point to be rotated around.
83  /// @param TopLeft The top left corner of the quad to be rotated.
84  /// @param TopRight The top right corner of the quad to be rotated.
85  /// @param BottomLeft The bottom left corner of the quad to be rotated.
86  /// @param BottomRight The bottom right corner of the quad to be rotated.
87  virtual void RotationTransform(Vector2& TopLeft, Vector2& TopRight, Vector2& BottomLeft, Vector2& BottomRight);
88  /// @internal
89  /// @brief Applies rotation to a quad in 2D space.
90  /// @param TopLeft The top left corner of the quad to be rotated.
91  /// @param TopRight The top right corner of the quad to be rotated.
92  /// @param BottomLeft The bottom left corner of the quad to be rotated.
93  /// @param BottomRight The bottom right corner of the quad to be rotated.
94  /// @param RotationCenter The point that will be rotated around.
95  virtual void RotationTransform(Vector2& TopLeft, Vector2& TopRight, Vector2& BottomLeft, Vector2& BottomRight, const Vector2& RotationCenter);
96  /// @internal
97  /// @brief Applies rotation to a quad in 2D space.
98  /// @note This overload will use the center of the quad defined by the 4 points as the point to be rotated around.
99  /// @param RotRect An array of 4 Vector2s storing the quad corners to be rotated.
100  virtual void RotationTransform(Vector2* RotRect);
101  /// @internal
102  /// @brief Applies rotation to a quad in 2D space.
103  /// @param RotRect An array of 4 Vector2s storing the quad corners to be rotated.
104  /// @param RotationCenter The point that will be rotated around.
105  virtual void RotationTransform(Vector2* RotRect, const Vector2& RotationCenter);
106  //public:
107  /// @brief Class constructor.
108  /// @param ParentRenderable The renderable that created this layer.
109  RenderLayer(QuadRenderable* ParentRenderable);
110  public:
111  /// @brief Class destructor.
112  virtual ~RenderLayer();
113 
114  ///////////////////////////////////////////////////////////////////////////////
115  // Utility
116 
117  /// @brief Gets the type of render layer this is.
118  /// @return Returns a RenderLayerType describing the type of layer this is.
119  virtual UI::RenderLayerType GetLayerType() const = 0;
120  /// @brief Gets the index position of this RenderLayer in it's parent.
121  /// @return Returns a Whole representing the index position of this RenderLayer in the parent QuadRenderable.
122  virtual Whole GetIndex() const;
123  /// @brief Notifies this RenderLayer that the group this layer belongs to has become the active group.
124  /// @remarks This shouldn't need to ever be called manually and is automatically called when
125  /// a QuadRenderable sets the parent group as the active RenderLayerGroup. This method exists to reset the
126  /// state of a layer (or group of layers) if necessary to achieve the visual effect desired.
127  virtual void NotifyActive();
128  /// @brief Notifies this RenderLayer that the group this layer belongs to is no longer the active group.
129  /// @remarks This shouldn't need to ever be called manually and is automatically called when
130  /// a QuadRenderable removes the parent group as the active RenderLayerGroup. This method exists to reset the
131  /// state of a layer (or group of layers) if necessary to achieve the visual effect desired.
132  virtual void NotifyInactive();
133  /// @brief Gets a rect containing the actual position and size of this layer.
134  /// @note This Rect does have scaling applied, but not any set rotation of the layer.
135  /// @return Returns a Rect containing the area of this layer in pixels.
136  virtual Rect GetAreaRect() const;
137  /// @brief Sets the scaling to be applied to this render layer.
138  /// @param Scaling A Vector2 representing the X and Y scaling to be applied to this render layer.
139  virtual void SetScale(const Vector2& Scaling);
140  /// @brief Gets the scaling currently applied to this render layer.
141  /// @return Returns a Vector2 containing the X and Y scaling applied to this render layer.
142  virtual Vector2 GetScale() const;
143 
144  /// @brief Gets whether or not this is an LineLayer.
145  /// @return Returns true if this is an LineLayer, false otherwise.
146  virtual Boole IsLineLayer() const;
147  /// @brief Gets whether or not this is an ImageLayer.
148  /// @return Returns true if this is an ImageLayer, false otherwise.
149  virtual Boole IsImageLayer() const;
150  /// @brief Gets whether or not this is a SingleImageLayer.
151  /// @return Returns true if this is a SingleImageLayer, false otherwise.
152  virtual Boole IsSingleImageLayer() const;
153  /// @brief Gets whether or not this is a MultiImageLayer.
154  /// @return Returns true if this is a MultiImageLayer, false otherwise.
155  virtual Boole IsMultiImageLayer() const;
156  /// @brief Gets whether or not this is a TextLayer.
157  /// @return Returns true if this is a TextLayer, false otherwise.
158  virtual Boole IsTextLayer() const;
159  /// @brief Gets whether or not this is a SingleLineTextLayer.
160  /// @return Returns true if this is a SingleLineTextLayer, false otherwise.
161  virtual Boole IsSingleLineTextLayer() const;
162  /// @brief Gets whether or not this is a MultiLineTextLayer.
163  /// @return Returns true if this is a MultiLineTextLayer, false otherwise.
164  virtual Boole IsMultiLineTextLayer() const;
165 
166  ///////////////////////////////////////////////////////////////////////////////
167  // Rotation Methods
168 
169  /// @brief Sets the rotation to be applied to this renderable.
170  /// @param Degrees The angle of rotation in degrees.
171  virtual void SetRotationDegrees(const Real& Degrees);
172  /// @brief Sets the rotation to be applied to this renderable.
173  /// @param Radians The angle of rotation in radians.
174  virtual void SetRotationRadians(const Real& Radians);
175  /// @brief Gets the current rotation applied to this renderable in degrees.
176  /// @return Returns a Real with the current rotation.
177  virtual Real GetRotationDegrees() const;
178  /// @brief Gets the current rotation applied to this renderable in radians.
179  /// @return Returns a Real with the current rotation.
180  virtual Real GetRotationRadians() const;
181 
182  ///////////////////////////////////////////////////////////////////////////////
183  // Accessor Methods
184 
185  /// @brief Gets the parent of this render layer.
186  /// @return Returns a pointer to the parent of this render layer.
187  virtual QuadRenderable* GetParent() const;
188  /// @brief Gets the screen the parent renderable is being rendered on.
189  /// @return Returns a pointer to the screen this layer belongs to.
190  virtual Screen* GetScreen() const;
191 
192  ///////////////////////////////////////////////////////////////////////////////
193  // Serialization
194 
195  /// @copydoc SimpleRenderer::ProtoSerializeProperties(XML::Node&) const
196  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
197  /// @copydoc SimpleRenderer::ProtoDeSerializeProperties(const XML::Node&)
198  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
199 
200  /// @copydoc SimpleRenderer::GetDerivedSerializableName() const
201  virtual String GetDerivedSerializableName() const;
202  /// @copydoc SimpleRenderer::GetSerializableName()
203  static String GetSerializableName();
204 
205  ///////////////////////////////////////////////////////////////////////////////
206  // Internal Methods
207 
208  /// @copydoc SimpleRenderer::_MarkDirty()
209  virtual void _MarkDirty();
210  /// @internal
211  /// @brief Notifies this RenderLayer that it's index in the parent QuadRenderable has been updated.
212  /// @param Index The new index being given to this RenderLayer.
213  virtual void _UpdateIndex(const Whole Index);
214  };//RenderLayer
215  }//UI
216 }//Mezzanine
217 
218 #endif
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
QuadRenderable * Parent
A pointer to the parent of this RenderLayer.
Definition: renderlayer.h:67
This class represents a box shaped area on the screen.
Definition: rect.h:55
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
Vector2 Scale
The scaling applied to this RenderLayer.
Definition: renderlayer.h:64
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
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
This represents a nestable quad for an object in a GUI layout.
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Whole IndexID
Stores the index of this RenderLayer in it's parent QuadRenderable.
Definition: renderlayer.h:70
This is the base class for the types of layers that can be added to a renderable. ...
Definition: renderlayer.h:58
Real RotAngle
The amount of rotation to be applied to this RenderLayer in radians.
Definition: renderlayer.h:73