MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
renderlayer.h
1 //© Copyright 2010 - 2012 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 
47 namespace Mezzanine
48 {
49  namespace UI
50  {
51  class QuadRenderable;
52  class Screen;
53  ///////////////////////////////////////////////////////////////////////////////
54  /// @class RenderLayer
55  /// @headerfile renderlayer.h
56  /// @brief This is the base class for the types of layers that can be added to a renderable.
57  /// @details
58  ///////////////////////////////////////
60  {
61  public:
62  /// @enum RenderLayerType
63  /// @brief This enum describes the type of RenderLayer this is for use in casting.
65  {
66  RLT_Image,
67  RLT_MultiLineText,
68  RLT_SingleLineText
69  };
70  protected:
71  /// @internal
72  /// @brief The scaling applied to this RenderLayer.
74  /// @internal
75  /// @brief A pointer to the parent of this RenderLayer.
77  /// @internal
78  /// @brief Stores the index of this RenderLayer in it's parent QuadRenderable.
80  /// @internal
81  /// @brief The amount of rotation to be applied to this RenderLayer in radians.
83 
84  /// @internal
85  /// @brief Applies rotation to a point in 2D space.
86  virtual void RotationTransform(Vector2& Point, const Vector2& RotationCenter);
87  /// @internal
88  /// @brief Applies rotation to a quad in 2D space.
89  virtual void RotationTransform(Vector2& TopLeft, Vector2& TopRight, Vector2& BottomLeft, Vector2& BottomRight);
90  //public:
91  /// @brief Class constructor.
92  /// @param ParentRenderable The renderable that created this layer.
93  RenderLayer(QuadRenderable* ParentRenderable);
94  public:
95  /// @brief Class destructor.
96  virtual ~RenderLayer();
97 
98  ///////////////////////////////////////////////////////////////////////////////
99  // Utility
100 
101  /// @brief Gets the type of render layer this is.
102  /// @return Returns a RenderLayerType describing the type of layer this is.
103  virtual RenderLayerType GetLayerType() const = 0;
104  /// @brief Gets the index position of this RenderLayer in it's parent.
105  /// @return Returns a Whole representing the index position of this RenderLayer in the parent QuadRenderable.
106  virtual Whole GetIndex() const;
107  /// @brief Notifies this RenderLayer that the group this layer belongs to has become the active group.
108  /// @remarks This shouldn't need to ever be called manually and is automatically called when
109  /// a QuadRenderable sets the parent group as the active RenderLayerGroup. This method exists to reset the
110  /// state of a layer (or group of layers) if necessary to achieve the visual effect desired.
111  virtual void NotifyActive();
112  /// @brief Notifies this RenderLayer that the group this layer belongs to is no longer the active group.
113  /// @remarks This shouldn't need to ever be called manually and is automatically called when
114  /// a QuadRenderable removes the parent group as the active RenderLayerGroup. This method exists to reset the
115  /// state of a layer (or group of layers) if necessary to achieve the visual effect desired.
116  virtual void NotifyInactive();
117  /// @brief Gets a rect containing the actual position and size of this layer.
118  /// @return Returns a Rect containing the area of this layer in pixels.
119  virtual Rect GetAreaRect() const;
120  /// @brief Sets the scaling to be applied to this render layer.
121  /// @param Scaling A Vector2 representing the X and Y scaling to be applied to this render layer.
122  virtual void SetScale(const Vector2& Scaling);
123  /// @brief Gets the scaling currently applied to this render layer.
124  /// @return Returns a Vector2 containing the X and Y scaling applied to this render layer.
125  virtual Vector2 GetScale() const;
126 
127  ///////////////////////////////////////////////////////////////////////////////
128  // Rotation Methods
129 
130  /// @brief Sets the rotation to be applied to this renderable.
131  /// @param Degrees The angle of rotation in degrees.
132  virtual void SetRotationDegrees(const Real& Degrees);
133  /// @brief Sets the rotation to be applied to this renderable.
134  /// @param Radians The angle of rotation in radians.
135  virtual void SetRotationRadians(const Real& Radians);
136  /// @brief Gets the current rotation applied to this renderable in degrees.
137  /// @return Returns a Real with the current rotation.
138  virtual Real GetRotationDegrees() const;
139  /// @brief Gets the current rotation applied to this renderable in radians.
140  /// @return Returns a Real with the current rotation.
141  virtual Real GetRotationRadians() const;
142 
143  ///////////////////////////////////////////////////////////////////////////////
144  // Accessor Methods
145 
146  /// @brief Gets the parent of this render layer.
147  /// @return Returns a pointer to the parent of this render layer.
148  virtual QuadRenderable* GetParent() const;
149  /// @brief Gets the screen the parent renderable is being rendered on.
150  /// @return Returns a pointer to the screen this layer belongs to.
151  virtual Screen* GetScreen() const;
152 
153  ///////////////////////////////////////////////////////////////////////////////
154  // Serialization
155 
156  /// @copydoc SimpleRenderer::ProtoSerializeProperties(XML::Node&) const
157  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
158  /// @copydoc SimpleRenderer::ProtoDeSerializeProperties(const XML::Node&)
159  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
160 
161  /// @copydoc SimpleRenderer::GetDerivedSerializableName() const
162  virtual String GetDerivedSerializableName() const;
163  /// @copydoc SimpleRenderer::GetSerializableName()
164  static String GetSerializableName();
165 
166  ///////////////////////////////////////////////////////////////////////////////
167  // Internal Methods
168 
169  /// @copydoc SimpleRenderer::_MarkDirty()
170  virtual void _MarkDirty();
171  /// @internal
172  /// @brief Notifies this RenderLayer that it's index in the parent QuadRenderable has been updated.
173  /// @param Index The new index being given to this RenderLayer.
174  virtual void _UpdateIndex(const Whole Index);
175  };//RenderLayer
176  }//UI
177 }//Mezzanine
178 
179 #endif