TGUI  0.8-dev
Group.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_GROUP_HPP
27 #define TGUI_GROUP_HPP
28 
29 
30 #include <TGUI/Container.hpp>
31 #include <TGUI/Renderers/GroupRenderer.hpp>
32 
34 
35 namespace tgui
36 {
43  class TGUI_API Group : public Container
44  {
45  public:
46 
47  typedef std::shared_ptr<Group> Ptr;
48  typedef std::shared_ptr<const Group> ConstPtr;
49 
50 
57  Group(const Layout2d& size = {RelLayout{1}, RelLayout{1}});
58 
59 
68  static Group::Ptr create(const Layout2d& size = {RelLayout{1}, RelLayout{1}});
69 
70 
79  static Group::Ptr copy(Group::ConstPtr group);
80 
81 
89  {
90  return aurora::downcast<GroupRenderer*>(m_renderer.get());
91  }
92 
93 
100  virtual void setSize(const Layout2d& size) override;
102 
103 
110  virtual sf::Vector2f getContentSize() const override;
111 
112 
120  virtual sf::Vector2f getChildWidgetsOffset() const override;
121 
122 
129  virtual bool mouseOnWidget(sf::Vector2f pos) const override;
130 
131 
135  virtual void leftMousePressed(sf::Vector2f pos) override;
136 
137 
145  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
146 
147 
149  protected:
150 
157  virtual void rendererChanged(const std::string& property) override;
158 
159 
161  // Makes a copy of the widget
163  virtual Widget::Ptr clone() const override
164  {
165  return std::make_shared<Group>(*this);
166  }
167 
168 
170  protected:
171 
172  // Cached renderer properties
173  Padding m_paddingCached;
174 
175 
177  };
178 
180 }
181 
183 
184 #endif // TGUI_GROUP_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
std::shared_ptr< const Group > ConstPtr
Shared constant widget pointer.
Definition: Group.hpp:48
Definition: GroupRenderer.hpp:36
Class to store the position or size of a widget.
Definition: Layout.hpp:205
Group widget.
Definition: Group.hpp:43
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Definition: Transformable.hpp:123
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:62
Container widget.
Definition: Container.hpp:47
std::shared_ptr< Group > Ptr
Shared widget pointer.
Definition: Group.hpp:47
GroupRenderer * getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed...
Definition: Group.hpp:88
Class to create a relative layout without using a string.
Definition: Layout.hpp:189
Definition: Outline.hpp:37
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don&#39;t know its exact type.
Definition: Group.hpp:163