MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
renderable.h
1 // © Copyright 2010 - 2014 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  /// @class Renderable
56  /// @headerfile uirenderable.h
57  /// @brief Basic class for all structures that get inserted into the rendering hierarchy.
58  /// @details
59  ///////////////////////////////////////
61  {
62  public:
63  /// @enum RenderableType
64  /// @brief A small enum to describe the type of renderable this is.
66  {
67  RT_LineList,
68  RT_Screen,
69  RT_Widget
70  };
71  protected:
72  friend class Widget;
73  /// @internal
74  /// @brief A pointer to the Screen that created this Renderable.
76  /// @internal
77  /// @brief Stores whether this Renderable is to be rendered (also dependent on parent visibility).
78  Boolean Visible;
79  /// @internal
80  /// @brief Stores whether this Renderables vertices need to be regenerated.
81  Boolean Dirty;
82  /// @internal
83  /// @brief The unique name of this Renderable.
85  /// @internal
86  /// @brief Implementation method for serializing additional sets of data.
87  /// @param SelfRoot The root node containing all the serialized data for this instance.
88  virtual void ProtoSerializeImpl(XML::Node& SelfRoot) const;
89  /// @internal
90  /// @brief Implementation method for deseriailizing additional sets of data.
91  /// @param SelfRoot An XML::Node containing the data to populate this class with.
92  virtual void ProtoDeSerializeImpl(const XML::Node& SelfRoot);
93  //public:
94  /// @brief Blank constructor.
95  /// @note This is primarily useful for (and used as) a basic constructor suitable for XML deserialization post-construction.
96  /// @param Parent The parent screen that created this renderable.
97  Renderable(Screen* Parent);
98  /// @brief Class constructor.
99  /// @param RendName The name to be given to this renderable.
100  /// @param Parent The parent screen that created this renderable.
101  Renderable(const String& RendName, Screen* Parent);
102  /// @brief Class destructor.
103  virtual ~Renderable();
104  public:
105  ///////////////////////////////////////////////////////////////////////////////
106  // Utility Methods
107 
108  /// @brief Gets the name of this renderable.
109  /// @return Returns a string containing the name of this renderable.
110  const String& GetName() const;
111  /// @brief Gets the type of renderable this is.
112  /// @return Returns a RenderableType enum value coressponding the type of renderable this is.
113  virtual RenderableType GetRenderableType() const = 0;
114  /// @brief Gets the parent screen of this renderable.
115  /// @return Returns a pointer to the screen this renderable belongs to.
116  Screen* GetScreen() const;
117 
118  ///////////////////////////////////////////////////////////////////////////////
119  // Visibility Methods
120 
121  /// @brief Sets the visibility of this renderable.
122  /// @param CanSee Bool determining whether or not this renderable should be visible.
123  virtual void SetVisible(Boolean CanSee) = 0;
124  /// @brief Gets the visibility setting of this renderable.
125  /// @return Returns a bool that is the current visibility setting of this renderable.
126  virtual Boolean GetVisible() const = 0;
127  /// @brief Gets whether or not this renderable is being drawn.
128  /// @details This function will check the visibility of all parent objects to see if it is being
129  /// drawn. This will not tell you whether or not this renderable has it's own visibility setting
130  /// enabled. For that see: GetVisible().
131  /// @return Returns a bool representing the visibility of this renderable.
132  virtual Boolean IsVisible() const = 0;
133  /// @brief Forces this renderable to be shown.
134  virtual void Show() = 0;
135  /// @brief Forces this renderable to hide.
136  virtual void Hide() = 0;
137 
138  ///////////////////////////////////////////////////////////////////////////////
139  // Serialization
140 
141  /// @brief Convert this class to an XML::Node ready for serialization.
142  /// @param ParentNode The point in the XML hierarchy that this renderable should be appended to.
143  virtual void ProtoSerialize(XML::Node& ParentNode) const;
144  /// @brief Convert the properties of this class to an XML::Node ready for serialization.
145  /// @param SelfRoot The root node containing all the serialized data for this instance.
146  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
147 
148  /// @brief Take the data stored in an XML Node and overwrite this object with it.
149  /// @param SelfRoot An XML::Node containing the data to populate this class with.
150  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
151  /// @brief Take the data stored in an XML Node and overwrite the properties of this object with it.
152  /// @param SelfRoot An XML::Node containing the data to populate this class with.
153  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
154 
155  /// @brief Gets the most derived serializable name of this Renderable.
156  /// @note When creating a new Renderable class verify this method has a valid return for it in order for serialization to work properly.
157  /// @return Returns the name of the XML tag from the most derived class of "this".
158  virtual String GetDerivedSerializableName() const;
159  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
160  /// @return A string containing the name of this class.
161  static String GetSerializableName();
162 
163  ///////////////////////////////////////////////////////////////////////////////
164  // Internal Methods
165 
166  /// @internal
167  /// @brief Gets whether or not this renderable is dirty.
168  /// @return Returns true if this renderable is dirty, false otherwise.
169  bool _IsDirty() const;
170  /// @internal
171  /// @brief Marks this renderable as dirty, and informs other renderables if needed.
172  virtual void _MarkDirty() = 0;
173  /// @internal
174  /// @brief Appends the vertices of this renderable to another vector.
175  /// @param RenderData The vector of vertex's to append to.
176  virtual void _AppendRenderData(ScreenRenderData& RenderData) = 0;
177  };//Renderable
178  }//UI
179 }//Mezzanine
180 
181 #endif