Spinning Topp Logo BlackTopp Studios
inc
linelist.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 _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  /// @brief This is an object comprised of a series of lines.
57  /// @details This class isn't an object, but rather just a series of lines. As such it
58  /// doesn't have a position or size. The position functions exist only to create additional
59  /// points for the lines to connect.
60  ///////////////////////////////////////
61  class MEZZ_LIB LineList : public Renderable
62  {
63  public:
64  /// @brief Basic container type for the storage of all the points in 2D space that create the line to be rendered.
65  typedef std::vector<Vector2> PointVector;
66  protected:
67  friend class ExtendedRenderableFactory;
68  /// @internal
69  /// @brief The colour of the line.
71  /// @internal
72  /// @brief The points in 2D space that create this line.
73  PointVector Positions;
74  /// @internal
75  /// @brief The internal renderer responsible for generating this lines vertices.
77  /// @internal
78  /// @brief The pixel thickness of the each line segment in this linelist.
80  /// @internal
81  /// @brief A bool indicating whether or not an additional segment should be generated between the first and last points.
83  //public:
84  /// @brief Class constructor.
85  /// @param RendName The name to give to this Linelist.
86  /// @param PScreen Pointer to the parent Screen that created this linelist.
87  LineList(const String& RendName, Screen* PScreen);
88  /// @brief Class destructor.
89  virtual ~LineList();
90  public:
91  /// @brief Starts a new line list.
92  /// @details If this function is called while lines have already been defined, it will
93  /// clear the current list of lines and start a new list.
94  /// @param LineThickness The thickness of the line to draw in pixels.
95  /// @param LineColour The colour of the line.
96  /// @return Returns a reference to this.
97  LineList& Begin(const Whole& LineThickness, const ColourValue& LineColour);
98  /// @brief Adds a new point/line to the list via 2 reals.
99  /// @param X Relative coordinate on the X vector.
100  /// @param Y Relative coordinate on the Y vector.
101  /// @return Returns a reference to this.
102  LineList& AddPoint(const Real& X, const Real& Y);
103  /// @brief Adds a new point/line to the list via a vector2.
104  /// @param Position A vector2 representing the relative position on screen.
105  /// @return Returns a reference to this.
106  LineList& AddPoint(const Vector2& Position);
107  /// @brief Adds a new point/line to the list via 2 reals.
108  /// @param X Coordinate on the X vector.
109  /// @param Y Coordinate on the Y vector.
110  /// @return Returns a reference to this.
111  LineList& AddActualPoint(const Real& X, const Real& Y);
112  /// @brief Adds a new point/line to the list via a vector2.
113  /// @param Position A vector2 representing the position on screen.
114  /// @return Returns a reference to this.
115  LineList& AddActualPoint(const Vector2& Position);
116  /// @brief Finalizes the list and prepares it for rendering.
117  /// @param Closed Whether or not the line list connects back to it's starting position. If
118  /// true this will create one last line connecting the last provided position with the first.
119  void End(Boole Closed = false);
120 
121  ///////////////////////////////////////////////////////////////////////////////
122  // Utility Methods
123 
124  /// @copydoc Renderable::GetRenderableType() const
125  RenderableType GetRenderableType() const;
126  /// @brief Gets the vector of points stored by this linelist.
127  /// @return Returns a const reference to the vector of points stored by this linelist.
128  const PointVector& GetPoints() const;
129  /// @brief Gets whether or not this linelist is enclosed.
130  /// @return Returns true if this linelist has an extra line connecting the first and last entries.
131  Boole IsClosed() const;
132  /// @brief Gets the colour of this linelist.
133  /// @return Returns a const reference to the colourvalue for this linelist.
134  const ColourValue& GetLineColour() const;
135  /// @brief Gets the thickness of the line generated by this linelist.
136  /// @return Returns a const reference to the real storing the line thickness for this linelist.
137  const Real& GetLineThickness() const;
138 
139  ///////////////////////////////////////////////////////////////////////////////
140  // Visibility Methods
141 
142  /// @copydoc Renderable::SetVisible(Boole)
143  virtual void SetVisible(Boole CanSee);
144  /// @copydoc Renderable::GetVisible()
145  virtual Boole GetVisible() const;
146  /// @copydoc Renderable::IsVisible()
147  virtual Boole IsVisible() const;
148  /// @copydoc Renderable::Show()
149  virtual void Show();
150  /// @copydoc Renderable::Hide()
151  virtual void Hide();
152 
153  ///////////////////////////////////////////////////////////////////////////////
154  // Utility Methods
155 
156  /// @brief Updates the dimensions of this QuadRenderable based on the transform of it's parent.
157  /// @details This function is called automatically when a parent changes in size, and shouldn't need to be called manually.
158  virtual void UpdateDimensions();
159 
160  ///////////////////////////////////////////////////////////////////////////////
161  // Internal Methods
162 
163  /// @copydoc Renderable::_MarkDirty()
164  virtual void _MarkDirty();
165  /// @copydoc UI::Renderable::_AppendRenderData()
166  virtual void _AppendRenderData(ScreenRenderData& RenderData);
167  };//LineList
168  }//UI
169 }//Mezzanine
170 
171 #endif
ColourValue Colour
The colour of the line.
Definition: linelist.h:70
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
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
This is a renderer class specifically designed to draw lines.
Definition: linelist.cpp:60
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
Real Thickness
The pixel thickness of the each line segment in this linelist.
Definition: linelist.h:79
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
std::vector< Vector2 > PointVector
Basic container type for the storage of all the points in 2D space that create the line to be rendere...
Definition: linelist.h:65
PointVector Positions
The points in 2D space that create this line.
Definition: linelist.h:73
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
LineListRenderer * Renderer
The internal renderer responsible for generating this lines vertices.
Definition: linelist.h:76
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 Closed
A bool indicating whether or not an additional segment should be generated between the first and last...
Definition: linelist.h:82
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
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
This is an object comprised of a series of lines.
Definition: linelist.h:61