TGUI  0.8-dev
BoxLayoutRatios.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_RATIOS_HPP
27 #define TGUI_BOX_LAYOUT_RATIOS_HPP
28 
29 #include <TGUI/Widgets/BoxLayout.hpp>
30 
32 
33 namespace tgui
34 {
39  class TGUI_API BoxLayoutRatios : public BoxLayout
40  {
41  public:
42 
43  typedef std::shared_ptr<BoxLayoutRatios> Ptr;
44  typedef std::shared_ptr<const BoxLayoutRatios> ConstPtr;
45 
46 
48  // Default constructor
50  BoxLayoutRatios(const Layout2d& size = {"100%", "100%"});
51 
52 
61  void add(const tgui::Widget::Ptr& widget, const sf::String& widgetName = "") override;
62 
63 
71  void add(const tgui::Widget::Ptr& widget, float ratio, const sf::String& widgetName = "");
72 
73 
85  void insert(std::size_t index, const tgui::Widget::Ptr& widget, const sf::String& widgetName = "") override;
86 
87 
101  void insert(std::size_t index, const tgui::Widget::Ptr& widget, float ratio, const sf::String& widgetName = "");
102 
103 
111  bool remove(std::size_t index) override;
112  using BoxLayout::remove;
113 
114 
118  void removeAllWidgets() override;
119 
120 
128  void addSpace(float ratio);
129 
130 
139  void insertSpace(std::size_t index, float ratio);
140 
141 
153  bool setRatio(Widget::Ptr widget, float ratio);
154 
155 
167  bool setRatio(std::size_t index, float ratio);
168 
169 
177  float getRatio(Widget::Ptr widget) const;
178 
179 
187  float getRatio(std::size_t index) const;
188 
189 
191  protected:
192 
193  std::vector<float> m_ratios;
194 
195 
197  };
198 
199 
201 }
202 
204 
205 #endif // TGUI_BOX_LAYOUT_RATIOS_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< const BoxLayoutRatios > ConstPtr
Shared constant widget pointer.
Definition: BoxLayoutRatios.hpp:44
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:66
Abstract class for box layout containers.
Definition: BoxLayout.hpp:40
bool remove(const tgui::Widget::Ptr &widget) override
Removes a single widget that was added to the container.
std::shared_ptr< BoxLayoutRatios > Ptr
Shared widget pointer.
Definition: BoxLayoutRatios.hpp:43
Abstract class for box layout containers.
Definition: BoxLayoutRatios.hpp:39