TGUI  0.9.1
Group.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_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 
58  Group(const char* typeName = "Group", bool initRenderer = true);
59 
60 
69  static Group::Ptr create(const Layout2d& size = {"100%", "100%"});
70 
71 
81 
82 
88  const GroupRenderer* getSharedRenderer() const;
89 
96  const GroupRenderer* getRenderer() const;
97 
98 
105  void setSize(const Layout2d& size) override;
106  using Widget::setSize;
107 
108 
113  Vector2f getInnerSize() const override;
114 
115 
123  Vector2f getChildWidgetsOffset() const override;
124 
125 
132  bool isMouseOnWidget(Vector2f pos) const override;
133 
134 
142  void draw(BackendRenderTargetBase& target, RenderStates states) const override;
143 
144 
146  protected:
147 
154  void rendererChanged(const String& property) override;
155 
156 
158  // Makes a copy of the widget
160  Widget::Ptr clone() const override
161  {
162  return std::make_shared<Group>(*this);
163  }
164 
165 
167  protected:
168 
169  // Cached renderer properties
170  Padding m_paddingCached;
171 
172 
174  };
175 
177 }
178 
180 
181 #endif // TGUI_GROUP_HPP
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Container widget.
Definition: Container.hpp:47
Definition: GroupRenderer.hpp:37
Group widget.
Definition: Group.hpp:44
static Group::Ptr create(const Layout2d &size={"100%", "100%"})
Creates a new group.
std::shared_ptr< const Group > ConstPtr
Shared constant widget pointer.
Definition: Group.hpp:48
void setSize(const Layout2d &size) override
Changes the size of the group.
GroupRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
std::shared_ptr< Group > Ptr
Shared widget pointer.
Definition: Group.hpp:47
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
static Group::Ptr copy(Group::ConstPtr group)
Makes a copy of another group.
Vector2f getInnerSize() const override
Returns the space available for widgets inside the container.
GroupRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
Vector2f getChildWidgetsOffset() const override
Returns the distance between the position of the container and a widget that would be drawn inside th...
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the child widgets to a render target.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: Group.hpp:160
Class to store the position or size of a widget.
Definition: Layout.hpp:262
Definition: Outline.hpp:39
Wrapper class to store strings.
Definition: String.hpp:74
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:73
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition: RenderStates.hpp:39