MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
linelist.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 _uilinelist_h
41 #define _uilinelist_h
42 
43 #include "colourvalue.h"
44 #include "uienumerations.h"
45 #include "UI/renderable.h"
46 
47 namespace Mezzanine
48 {
49  class UIManager;
50  namespace UI
51  {
52  class VertexData;
53  class ScreenRenderData;
54  class LineListRenderer;
55  ///////////////////////////////////////////////////////////////////////////////
56  /// @class LineList
57  /// @headerfile uilinelist.h
58  /// @brief This is an object comprised of a series of lines.
59  /// @details This class isn't an object, but rather just a series of lines. As such it
60  /// doesn't have a position or size. The position functions exist only to create additional
61  /// points for the lines to connect.
62  ///////////////////////////////////////
63  class MEZZ_LIB LineList : public Renderable
64  {
65  public:
66  /// @brief Basic container type for the storage of all the points in 2D space that create the line to be rendered.
67  typedef std::vector<Vector2> PointVector;
68  protected:
69  friend class ExtendedRenderableFactory;
70  /// @internal
71  /// @brief The colour of the line.
73  /// @internal
74  /// @brief The points in 2D space that create this line.
76  /// @internal
77  /// @brief The internal renderer responsible for generating this lines vertices.
79  /// @internal
80  /// @brief The pixel thickness of the each line segment in this linelist.
82  /// @internal
83  /// @brief A bool indicating whether or not an additional segment should be generated between the first and last points.
84  bool Closed;
85  /// @internal
86  /// @brief Determines the "higher ZOrder" of this Quad compared to all other renderables on screen.
88  //public:
89  /// @brief Class constructor.
90  /// @param RendName The name to give to this Linelist.
91  /// @param PScreen Pointer to the parent Screen that created this linelist.
92  LineList(const String& RendName, Screen* PScreen);
93  /// @brief Class destructor.
94  virtual ~LineList();
95  public:
96  /// @brief Starts a new line list.
97  /// @details If this function is called while lines have already been defined, it will
98  /// clear the current list of lines and start a new list.
99  /// @param LineThickness The thickness of the line to draw in pixels.
100  /// @param LineColour The colour of the line.
101  /// @return Returns a reference to this.
102  LineList& Begin(const Whole& LineThickness, const ColourValue& LineColour);
103  /// @brief Adds a new point/line to the list via 2 reals.
104  /// @param X Relative coordinate on the X vector.
105  /// @param Y Relative coordinate on the Y vector.
106  /// @return Returns a reference to this.
107  LineList& AddPoint(const Real& X, const Real& Y);
108  /// @brief Adds a new point/line to the list via a vector2.
109  /// @param Position A vector2 representing the relative position on screen.
110  /// @return Returns a reference to this.
111  LineList& AddPoint(const Vector2& Position);
112  /// @brief Adds a new point/line to the list via 2 reals.
113  /// @param X Coordinate on the X vector.
114  /// @param Y Coordinate on the Y vector.
115  /// @return Returns a reference to this.
116  LineList& AddActualPoint(const Real& X, const Real& Y);
117  /// @brief Adds a new point/line to the list via a vector2.
118  /// @param Position A vector2 representing the position on screen.
119  /// @return Returns a reference to this.
120  LineList& AddActualPoint(const Vector2& Position);
121  /// @brief Finalizes the list and prepares it for rendering.
122  /// @param Closed Whether or not the line list connects back to it's starting position. If
123  /// true this will create one last line connecting the last provided position with the first.
124  void End(bool Closed = false);
125 
126  ///////////////////////////////////////////////////////////////////////////////
127  // Utility Methods
128 
129  /// @copydoc Renderable::GetRenderableType() const
130  RenderableType GetRenderableType() const;
131  /// @brief Gets the vector of points stored by this linelist.
132  /// @return Returns a const reference to the vector of points stored by this linelist.
133  const PointVector& GetPoints() const;
134  /// @brief Gets whether or not this linelist is enclosed.
135  /// @return Returns true if this linelist has an extra line connecting the first and last entries.
136  bool IsClosed() const;
137  /// @brief Gets the colour of this linelist.
138  /// @return Returns a const reference to the colourvalue for this linelist.
139  const ColourValue& GetLineColour() const;
140  /// @brief Gets the thickness of the line generated by this linelist.
141  /// @return Returns a const reference to the real storing the line thickness for this linelist.
142  const Real& GetLineThickness() const;
143 
144  ///////////////////////////////////////////////////////////////////////////////
145  // Visibility Methods
146 
147  /// @copydoc Renderable::SetVisible(bool visible)
148  virtual void SetVisible(bool visible);
149  /// @copydoc Renderable::GetVisible()
150  virtual bool GetVisible() const;
151  /// @copydoc Renderable::IsVisible()
152  virtual bool IsVisible() const;
153  /// @copydoc Renderable::Show()
154  virtual void Show();
155  /// @copydoc Renderable::Hide()
156  virtual void Hide();
157 
158  ///////////////////////////////////////////////////////////////////////////////
159  // Utility Methods
160 
161  /// @brief Updates the dimensions of this QuadRenderable based on the transform of it's parent.
162  /// @details This function is called automatically when a parent changes in size, and shouldn't need to be called manually.
163  virtual void UpdateDimensions();
164 
165  ///////////////////////////////////////////////////////////////////////////////
166  // Internal Methods
167 
168  /// @copydoc Renderable::_MarkDirty()
169  virtual void _MarkDirty();
170  /// @copydoc UI::Renderable::_AppendRenderData()
171  virtual void _AppendRenderData(ScreenRenderData& RenderData);
172  };//listlist
173  }//UI
174 }//Mezzanine
175 
176 #endif