Spinning Topp Logo BlackTopp Studios
inc
renderlayergroup.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 #ifndef _uirenderlayergroup_h
41 #define _uirenderlayergroup_h
42 
43 #include "datatypes.h"
44 
45 namespace Mezzanine
46 {
47  namespace UI
48  {
49  class RenderLayer;
50  class QuadRenderable;
51  //////////////////////////////////////////////////////////////////////////////
52  /// @brief This class stores a group of render layers that can be set to be rendered.
53  /// @details A QuadRenderable can only render one group of layers at a time, but a single layer can be added to
54  /// as many RenderLayerGroup's as the user see's fit.
55  ///////////////////////////////////////
57  {
58  public:
59  /// @brief An std::pair type for storing ZOrders in relation to @ref RenderLayer instances.
60  typedef std::pair<UInt16,RenderLayer*> RenderLayerPair;
61  /// @brief Basic container type for @ref RenderLayerPair storage by this class.
62  typedef std::vector<RenderLayerPair> RenderLayerContainer;
63  /// @brief Iterator type for @ref RenderLayerPair instances stored by this class.
64  typedef RenderLayerContainer::iterator RenderLayerIterator;
65  /// @brief Const Iterator type for @ref RenderLayerPair instances stored by this class.
66  typedef RenderLayerContainer::const_iterator ConstRenderLayerIterator;
67  protected:
68  /// @internal
69  /// @brief Container storing all the layers that belong to this group and their ZOrders.
70  RenderLayerContainer RenderLayers;
71  /// @internal
72  /// @brief A pointer to the host QuadRenderable.
74  /// @internal
75  /// @brief The ID of this group.
77  public:
78  /// @brief Class constructor.
79  /// @param ID The unique ID to give to this RenderLayerGroup.
80  /// @param Creator The Quad that owns this RenderLayerGroup.
81  RenderLayerGroup(const UInt16 ID, QuadRenderable* Creator);
82  /// @brief Class destructor.
84 
85  ///////////////////////////////////////////////////////////////////////////////
86  // Utility
87 
88  /// @brief Gets the ID of this RenderLayerGroup.
89  /// @return Returns a UInt16 representing the ID of this RenderLayerGroup.
90  UInt16 GetGroupID() const;
91  /// @brief Notifies this RenderLayerGroup that it has become the active group.
92  /// @remarks This shouldn't need to ever be called manually and is automatically called when
93  /// a QuadRenderable sets it as the active RenderLayerGroup. This method exists to reset the
94  /// state of a layer (or group of layers) if necessary to achieve the visual effect desired.
95  void NotifyActive();
96  /// @brief Notifies this RenderLayerGroup that it is no longer the active group.
97  /// @remarks This is a straightforward counterpart to the "NotifyActive" method also on this
98  /// class, and also shouldn't ever need to be called manually.
99  void NotifyInactive();
100 
101  ///////////////////////////////////////////////////////////////////////////////
102  // RenderLayer Management
103 
104  /// @brief Adds a layer to this group by it's ZOrder.
105  /// @param RL The layer to add.
106  /// @param ZOrder The ZOrder at which to add the layer.
107  void AddLayer(RenderLayer* RL, const UInt16 ZOrder);
108  /// @brief Gets a RenderLayer in this group by it's index.
109  /// @param Index The index of the RenderLayer to retrieve. Note: RenderLayers are sorted via ZOrder.
110  /// @return Returns a pointer to the RenderLayer at the specified index.
111  RenderLayer* GetLayer(const Whole Index) const;
112  /// @brief Gets a RenderLayer in this group by it's ZOrder.
113  /// @param ZOrder The ZOrder of the RenderLayer to retrieve.
114  /// @return Returns a pointer to the layer at the specified ZOrder, or NULL if no layers exist at that ZOrder.
115  RenderLayer* GetLayerByZOrder(const UInt16 ZOrder) const;
116  /// @brief Gets the number of RenderLayers assigned to this group.
117  /// @return Returns a UInt32 containing the number of RenderLayers in this group.
118  UInt32 GetNumRenderLayers() const;
119  /// @brief Swaps the layers contained by this group and another group.
120  /// @param OtherGroup The other RenderLayerGroup to swap layers with.
121  void SwapLayers(RenderLayerGroup* OtherGroup);
122  /// @brief Removes a layer from this group.
123  /// @param RL The RenderLayer to be removed.
124  void RemoveLayer(RenderLayer* RL);
125  /// @brief Removes every layer in this group, from this group.
126  void RemoveAllLayers();
127 
128  /// @brief Gets an iterator to the first RenderLayer.
129  /// @return Returns an iterator to the first RenderLayer being stored by this group.
130  RenderLayerIterator RenderLayerBegin();
131  /// @brief Gets an iterator to one passed the last RenderLayer.
132  /// @return Returns an iterator to one passed the last RenderLayer being stored by this group.
133  RenderLayerIterator RenderLayerEnd();
134  /// @brief Gets a const iterator to the first RenderLayer.
135  /// @return Returns a const iterator to the first RenderLayer being stored by this group.
136  ConstRenderLayerIterator RenderLayerBegin() const;
137  /// @brief Gets an iterator to one passed the last RenderLayer.
138  /// @return Returns an iterator to one passed the last RenderLayer being stored by this group.
139  ConstRenderLayerIterator RenderLayerEnd() const;
140 
141  ///////////////////////////////////////////////////////////////////////////////
142  // Serialization
143 
144  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
145  /// @return A string containing the name of this class.
146  static String GetSerializableName();
147  };//RenderLayerGroup
148  }//UI
149 }//Mezzanine
150 
151 #endif
RenderLayerContainer::const_iterator ConstRenderLayerIterator
Const Iterator type for RenderLayerPair instances stored by this class.
std::pair< UInt16, RenderLayer * > RenderLayerPair
An std::pair type for storing ZOrders in relation to RenderLayer instances.
All the definitions for datatypes as well as some basic conversion functions are defined here...
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
RenderLayerContainer::iterator RenderLayerIterator
Iterator type for RenderLayerPair instances stored by this class.
RenderLayerContainer RenderLayers
Container storing all the layers that belong to this group and their ZOrders.
This class stores a group of render layers that can be set to be rendered.
QuadRenderable * ParentQuad
A pointer to the host QuadRenderable.
#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
UInt16 GroupID
The ID of this group.
This represents a nestable quad for an object in a GUI layout.
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
std::vector< RenderLayerPair > RenderLayerContainer
Basic container type for RenderLayerPair storage by this class.