30#include <TGUI/Container.hpp>
32#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
33 #include <unordered_map>
38TGUI_MODULE_EXPORT
namespace tgui
46 using Ptr = std::shared_ptr<Grid>;
49 static constexpr const char StaticWidgetType[] =
"Grid";
80 Grid(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
138 using Widget::setSize;
232 TGUI_NODISCARD
const std::unordered_map<Widget::Ptr, std::pair<std::size_t, std::size_t>>&
getWidgetLocations()
const;
329 TGUI_NODISCARD
const std::vector<std::vector<Widget::Ptr>>&
getGridWidgets()
const;
347 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
353 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
359 TGUI_NODISCARD
Vector2f getMinimumSize()
const;
365 void updatePositionsOfAllWidgets();
371 void updateWidgets();
383 bool m_autoSize =
true;
385 std::vector<std::vector<Widget::Ptr>> m_gridWidgets;
386 std::vector<std::vector<Padding>> m_objPadding;
387 std::vector<std::vector<Alignment>> m_objAlignment;
389 std::vector<float> m_rowHeight;
390 std::vector<float> m_columnWidth;
392 std::unordered_map<Widget::Ptr, std::pair<std::size_t, std::size_t>> m_widgetCells;
394 std::unordered_map<Widget::Ptr, unsigned int> m_connectedSizeCallbacks;
Container widget.
Definition Container.hpp:49
bool setWidgetCell(const Widget::Ptr &widget, std::size_t row, std::size_t column, Alignment alignment=Alignment::Center, const Padding &padding=Padding{0})
Chooses the row and column in which a widget should be placed.
void removeAllWidgets() override
Removes all widgets that were added to the container.
TGUI_NODISCARD Padding getWidgetPadding(const Widget::Ptr &widget) const
Returns the padding around a widget.
Grid(const Grid ©)
Copy constructor.
TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
TGUI_NODISCARD Alignment getWidgetAlignment(std::size_t row, std::size_t column) const
Returns the alignment of a given widget in its cell.
std::shared_ptr< const Grid > ConstPtr
Shared constant widget pointer.
Definition Grid.hpp:47
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.
std::shared_ptr< Grid > Ptr
Shared widget pointer.
Definition Grid.hpp:46
TGUI_NODISCARD 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.
TGUI_NODISCARD Padding getWidgetPadding(std::size_t row, std::size_t column) const
Returns the padding around a widget in a specific cell of the grid.
static TGUI_NODISCARD Grid::Ptr copy(const Grid::ConstPtr &grid)
Makes a copy of another grid.
Alignment
The alignment of the widget in its cell.
Definition Grid.hpp:60
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
static TGUI_NODISCARD Grid::Ptr create()
Creates a new grid widget.
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.
Grid(Grid &©) noexcept
Move constructor.
TGUI_NODISCARD bool getAutoSize() const
Returns whether the grid is auto-sized or not.
void setWidgetPadding(const Widget::Ptr &widget, const Padding &padding=Padding(0, 0, 0, 0))
Changes padding of a given widget.
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.
TGUI_NODISCARD Widget::Ptr getWidget(std::size_t row, std::size_t column) const
Returns the widget in a specific cell of the grid.
TGUI_NODISCARD const std::vector< std::vector< Widget::Ptr > > & getGridWidgets() const
Returns the widgets and their positions in the grid.
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.
TGUI_NODISCARD Alignment getWidgetAlignment(const Widget::Ptr &widget) const
Returns the alignment of a given widget.
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.
TGUI_NODISCARD const std::unordered_map< Widget::Ptr, std::pair< std::size_t, std::size_t > > & getWidgetLocations() const
Returns a list of widgets and the cell they are in.
Class to store the position or size of a widget.
Definition Layout.hpp:305
Definition Outline.hpp:39
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39