Spinning Topp Logo BlackTopp Studios
inc
renderable.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 _uirenderable_h
41 #define _uirenderable_h
42 
43 #include "uienumerations.h"
44 #include "UI/vertex.h"
45 
46 namespace Mezzanine
47 {
48  namespace UI
49  {
50  class UIManager;
51  class Screen;
52  class ScreenRenderData;
53  class Widget;
54  ///////////////////////////////////////////////////////////////////////////////
55  /// @brief Basic class for all structures that get inserted into the rendering hierarchy.
56  /// @details
57  ///////////////////////////////////////
59  {
60  public:
61  /// @brief A small enum to describe the type of renderable this is.
63  {
64  RT_LineList,
65  RT_Screen,
66  RT_Widget
67  };
68  protected:
69  friend class Widget;
70  /// @internal
71  /// @brief A pointer to the Screen that created this Renderable.
73  /// @internal
74  /// @brief Stores whether this Renderable is to be rendered (also dependent on parent visibility).
76  /// @internal
77  /// @brief Stores whether this Renderables vertices need to be regenerated.
79  /// @internal
80  /// @brief The unique name of this Renderable.
82 
83  /// @internal
84  /// @brief Implementation method for serializing additional sets of data.
85  /// @param SelfRoot The root node containing all the serialized data for this instance.
86  virtual void ProtoSerializeImpl(XML::Node& SelfRoot) const;
87  /// @internal
88  /// @brief Implementation method for deseriailizing additional sets of data.
89  /// @param SelfRoot An XML::Node containing the data to populate this class with.
90  virtual void ProtoDeSerializeImpl(const XML::Node& SelfRoot);
91  //public:
92  /// @brief Blank constructor.
93  /// @note This is primarily useful for (and used as) a basic constructor suitable for XML deserialization post-construction.
94  /// @param Parent The parent screen that created this renderable.
95  Renderable(Screen* Parent);
96  /// @brief Class constructor.
97  /// @param RendName The name to be given to this renderable.
98  /// @param Parent The parent screen that created this renderable.
99  Renderable(const String& RendName, Screen* Parent);
100  /// @brief Class destructor.
101  virtual ~Renderable();
102  public:
103  ///////////////////////////////////////////////////////////////////////////////
104  // Utility Methods
105 
106  /// @brief Gets the name of this renderable.
107  /// @return Returns a string containing the name of this renderable.
108  const String& GetName() const;
109  /// @brief Gets the type of renderable this is.
110  /// @return Returns a RenderableType enum value coressponding the type of renderable this is.
111  virtual RenderableType GetRenderableType() const = 0;
112  /// @brief Gets the parent screen of this renderable.
113  /// @return Returns a pointer to the screen this renderable belongs to.
114  Screen* GetScreen() const;
115 
116  /// @brief Gets whether or not this renderable is a Widget.
117  /// @return Returns true if this renderable is a Widget, false otherwise.
118  Boole IsWidget() const;
119  /// @brief Gets whether or not this renderable is a Screen.
120  /// @return Returns true if this renderable is a Screen, false otherwise.
121  Boole IsScreen() const;
122 
123  ///////////////////////////////////////////////////////////////////////////////
124  // Visibility Methods
125 
126  /// @brief Sets the visibility of this renderable.
127  /// @param CanSee Boole determining whether or not this renderable should be visible.
128  virtual void SetVisible(Boole CanSee) = 0;
129  /// @brief Gets the visibility setting of this renderable.
130  /// @return Returns a bool that is the current visibility setting of this renderable.
131  virtual Boole GetVisible() const = 0;
132  /// @brief Gets whether or not this renderable is being drawn.
133  /// @details This function will check the visibility of all parent objects to see if it is being
134  /// drawn. This will not tell you whether or not this renderable has it's own visibility setting
135  /// enabled. For that see: GetVisible().
136  /// @return Returns a bool representing the visibility of this renderable.
137  virtual Boole IsVisible() const = 0;
138  /// @brief Forces this renderable to be shown.
139  virtual void Show() = 0;
140  /// @brief Forces this renderable to hide.
141  virtual void Hide() = 0;
142 
143  ///////////////////////////////////////////////////////////////////////////////
144  // Serialization
145 
146  /// @brief Convert this class to an XML::Node ready for serialization.
147  /// @param ParentNode The point in the XML hierarchy that this renderable should be appended to.
148  virtual void ProtoSerialize(XML::Node& ParentNode) const;
149  /// @brief Convert the properties of this class to an XML::Node ready for serialization.
150  /// @param SelfRoot The root node containing all the serialized data for this instance.
151  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
152 
153  /// @brief Take the data stored in an XML Node and overwrite this object with it.
154  /// @param SelfRoot An XML::Node containing the data to populate this class with.
155  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
156  /// @brief Take the data stored in an XML Node and overwrite the properties of this object with it.
157  /// @param SelfRoot An XML::Node containing the data to populate this class with.
158  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
159 
160  /// @brief Gets the most derived serializable name of this Renderable.
161  /// @note When creating a new Renderable class verify this method has a valid return for it in order for serialization to work properly.
162  /// @return Returns the name of the XML tag from the most derived class of "this".
163  virtual String GetDerivedSerializableName() const;
164  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
165  /// @return A string containing the name of this class.
166  static String GetSerializableName();
167 
168  ///////////////////////////////////////////////////////////////////////////////
169  // Internal Methods
170 
171  /// @internal
172  /// @brief Gets whether or not this renderable is dirty.
173  /// @return Returns true if this renderable is dirty, false otherwise.
174  Boole _IsDirty() const;
175  /// @internal
176  /// @brief Refreshes the render data of this renderable.
177  virtual void _Clean() = 0;
178  /// @internal
179  /// @brief Marks this renderable as dirty, and informs other renderables if needed.
180  virtual void _MarkDirty() = 0;
181  /// @internal
182  /// @brief Appends the vertices of this renderable to another vector.
183  /// @param RenderData The vector of vertex's to append to.
184  virtual void _AppendRenderData(ScreenRenderData& RenderData) = 0;
185  };//Renderable
186  }//UI
187 }//Mezzanine
188 
189 #endif
Basic class for all structures that get inserted into the rendering hierarchy.
Definition: renderable.h:58
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
Boole Visible
Stores whether this Renderable is to be rendered (also dependent on parent visibility).
Definition: renderable.h:75
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is the base class for all widgets.
Definition: widget.h:126
String Name
The unique name of this Renderable.
Definition: renderable.h:81
#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 class stores all vertices pertaining to a layer sorted by their priority for rendering...
Definition: screen.h:115
Boole Dirty
Stores whether this Renderables vertices need to be regenerated.
Definition: renderable.h:78
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
RenderableType
A small enum to describe the type of renderable this is.
Definition: renderable.h:62
Screen * ParentScreen
A pointer to the Screen that created this Renderable.
Definition: renderable.h:72