TGUI  0.9.1
SeparatorLine.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2021 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_SEPARATOR_LINE_HPP
27 #define TGUI_SEPARATOR_LINE_HPP
28 
29 #include <TGUI/Widgets/ClickableWidget.hpp>
30 #include <TGUI/Renderers/SeparatorLineRenderer.hpp>
31 
33 
34 namespace tgui
35 {
47  class TGUI_API SeparatorLine : public ClickableWidget
48  {
49  public:
50 
51  typedef std::shared_ptr<SeparatorLine> Ptr;
52  typedef std::shared_ptr<const SeparatorLine> ConstPtr;
53 
54 
62  SeparatorLine(const char* typeName = "SeparatorLine", bool initRenderer = true);
63 
64 
70  static SeparatorLine::Ptr create(Layout2d size = {"100%", 1});
71 
72 
81 
82 
88  const SeparatorLineRenderer* getSharedRenderer() const;
89 
96  const SeparatorLineRenderer* getRenderer() const;
97 
98 
105  void draw(BackendRenderTargetBase& target, RenderStates states) const override;
106 
107 
109  protected:
110 
116  void rendererChanged(const String& property) override;
117 
118 
120  // Makes a copy of the widget
122  Widget::Ptr clone() const override
123  {
124  return std::make_shared<SeparatorLine>(*this);
125  }
126 
127 
129  protected:
130 
131  // Cached renderer properties
132  Color m_colorCached = Color::Black;
133 
135  };
136 
138 }
139 
141 
142 #endif // TGUI_SEPARATOR_LINE_HPP
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Clickable widget.
Definition: ClickableWidget.hpp:40
Wrapper for colors.
Definition: Color.hpp:52
static const Color Black
Black predefined color.
Definition: Color.hpp:236
Class to store the position or size of a widget.
Definition: Layout.hpp:262
Definition: SeparatorLineRenderer.hpp:37
Widget that is drawn as a filled rectangle and can be used as a line to visually separate widgets fro...
Definition: SeparatorLine.hpp:48
static SeparatorLine::Ptr copy(SeparatorLine::ConstPtr separator)
Makes a copy of another separator.
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the widget to a render target.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: SeparatorLine.hpp:122
SeparatorLineRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
std::shared_ptr< SeparatorLine > Ptr
Shared widget pointer.
Definition: SeparatorLine.hpp:51
static SeparatorLine::Ptr create(Layout2d size={"100%", 1})
Creates a new separator widget.
std::shared_ptr< const SeparatorLine > ConstPtr
Shared constant widget pointer.
Definition: SeparatorLine.hpp:52
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
SeparatorLineRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
Wrapper class to store strings.
Definition: String.hpp:74
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:73
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition: RenderStates.hpp:39