TGUI  0.8-dev
BoxLayout.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2017 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_BOX_LAYOUT_HPP
27 #define TGUI_BOX_LAYOUT_HPP
28 
29 #include <TGUI/Widgets/Group.hpp>
30 #include <TGUI/Renderers/BoxLayoutRenderer.hpp>
31 
33 
34 namespace tgui
35 {
40  class TGUI_API BoxLayout : public Group
41  {
42  public:
43 
44  typedef std::shared_ptr<BoxLayout> Ptr;
45  typedef std::shared_ptr<const BoxLayout> ConstPtr;
46 
47 
49  // Default constructor
51  BoxLayout(const Layout2d& size = {"100%", "100%"});
52 
53 
58  BoxLayoutRenderer* getSharedRenderer();
59  const BoxLayoutRenderer* getSharedRenderer() const;
60 
66  BoxLayoutRenderer* getRenderer();
67  const BoxLayoutRenderer* getRenderer() const;
68 
69 
76  void setSize(const Layout2d& size) override;
77  using Widget::setSize;
78 
79 
87  void add(const tgui::Widget::Ptr& widget, const sf::String& widgetName = "") override;
88 
89 
100  virtual void insert(std::size_t index, const tgui::Widget::Ptr& widget, const sf::String& widgetName = "");
101 
102 
111  bool remove(const tgui::Widget::Ptr& widget) override;
112 
113 
122  virtual bool remove(std::size_t index);
123 
124 
133  Widget::Ptr get(std::size_t index) const;
134  using Container::get;
135 
136 
138  protected:
139 
146  void rendererChanged(const std::string& property) override;
147 
148 
150  // @brief Repositions and resize the widgets
152  virtual void updateWidgets() = 0;
153 
154 
156  protected:
157 
158  float m_spaceBetweenWidgetsCached = 0;
159 
160 
162  };
163 
164 
166 }
167 
169 
170 #endif // TGUI_BOX_LAYOUT_HPP
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Class to store the position or size of a widget.
Definition: Layout.hpp:243
std::shared_ptr< BoxLayout > Ptr
Shared widget pointer.
Definition: BoxLayout.hpp:44
Definition: BoxLayoutRenderer.hpp:36
Group widget.
Definition: Group.hpp:43
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:66
std::shared_ptr< const BoxLayout > ConstPtr
Shared constant widget pointer.
Definition: BoxLayout.hpp:45
Abstract class for box layout containers.
Definition: BoxLayout.hpp:40
Widget::Ptr get(const sf::String &widgetName) const
Returns a pointer to an earlier created widget.