30#include <TGUI/Container.hpp>
42 typedef std::shared_ptr<Grid>
Ptr;
74 Grid(
const char* typeName =
"Grid",
bool initRenderer =
true);
132 using Widget::setSize;
324 std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
330 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
342 void updatePositionsOfAllWidgets();
348 void updateWidgets();
356 return std::make_shared<Grid>(*
this);
363 bool m_autoSize =
true;
365 std::vector<std::vector<Widget::Ptr>> m_gridWidgets;
366 std::vector<std::vector<Padding>> m_objPadding;
367 std::vector<std::vector<Alignment>> m_objAlignment;
369 std::vector<float> m_rowHeight;
370 std::vector<float> m_columnWidth;
372 std::map<Widget::Ptr, unsigned int> m_connectedSizeCallbacks;
Container widget.
Definition Container.hpp:47
void removeAllWidgets() override
Removes all widgets that were added to the container.
Grid(const Grid ©)
Copy constructor.
Widget::Ptr getWidget(std::size_t row, std::size_t column) const
Returns the widget in a specific cell of the grid.
static Grid::Ptr copy(Grid::ConstPtr grid)
Makes a copy of another grid.
std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
void setSize(const Layout2d &size) override
Changes the size of the grid.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition Grid.hpp:354
Alignment getWidgetAlignment(const Widget::Ptr &widget) const
Returns the alignment of a given widget.
Alignment getWidgetAlignment(std::size_t row, std::size_t column) const
Returns the alignment of a given widget in its cell.
Padding getWidgetPadding(std::size_t row, std::size_t column) const
Returns the padding around a widget in a specific cell of the grid.
Alignment
The alignment of the widget in its cell.
Definition Grid.hpp:54
Padding getWidgetPadding(const Widget::Ptr &widget) const
Returns the padding around a widget.
bool getAutoSize() const
Returns whether the grid is auto-sized or not.
void addWidget(const Widget::Ptr &widget, std::size_t row, std::size_t column, Alignment alignment=Alignment::Center, const Padding &padding=Padding{0})
Adds a widget to the grid.
static Grid::Ptr create()
Creates a new grid widget.
std::map< Widget::Ptr, std::pair< std::size_t, std::size_t > > getWidgetLocations() const
Returns a list of widgets and the cell they are in.
void setWidgetPadding(const Widget::Ptr &widget, const Padding &padding=Padding(0, 0, 0, 0))
Changes padding of a given widget.
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
std::shared_ptr< Grid > Ptr
Shared widget pointer.
Definition Grid.hpp:42
bool remove(const Widget::Ptr &widget) override
Removes a single widget that was added to the container.
void setWidgetAlignment(std::size_t row, std::size_t column, Alignment alignment=Alignment::Center)
Changes the alignment of a given widget in its cell.
Grid(Grid &©)
Move constructor.
const std::vector< std::vector< Widget::Ptr > > & getGridWidgets() const
Returns the widgets and their positions in the grid.
std::shared_ptr< const Grid > ConstPtr
Shared constant widget pointer.
Definition Grid.hpp:43
void setWidgetPadding(std::size_t row, std::size_t column, const Padding &padding=Padding(0, 0, 0, 0))
Changes padding of a widget in a certain cell.
void setWidgetAlignment(const Widget::Ptr &widget, Alignment alignment=Alignment::Center)
Changes the alignment of a given widget in its cell.
void setAutoSize(bool autoSize)
Changes whether the grid is auto-sized or not.
Class to store the position or size of a widget.
Definition Layout.hpp:262
Definition Outline.hpp:39
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36