14#include <egt/detail/meta.h>
16#include <egt/widget.h>
52 show_border = detail::bit(0),
115 void add(
const std::shared_ptr<Widget>& widget)
override;
127 virtual void add(
const std::shared_ptr<Widget>& widget,
size_t column,
size_t row);
136 virtual void add(
Widget& widget,
size_t column,
size_t row)
141 auto w = std::shared_ptr<Widget>(&widget, [](
Widget*) {});
154 virtual void add(
const std::shared_ptr<Widget>& widget,
const GridPoint& point)
156 add(widget, point.
x(), point.
y());
170 auto w = std::shared_ptr<Widget>(&widget, [](
Widget*) {});
194 return m_last_add_column;
204 return m_last_add_row;
225 return m_grid_size.width();
233 return m_grid_size.height();
249 if (detail::change_if_diff<>(m_grid_size, size))
261 if (detail::change_if_diff<>(m_horizontal_space, space))
273 return m_horizontal_space;
281 if (detail::change_if_diff<>(m_vertical_space, space))
293 return m_vertical_space;
316 using CellArray = std::vector<std::vector<std::weak_ptr<Widget>>>;
322 int m_last_add_column{-1};
324 int m_last_add_row{-1};
326 bool m_column_priority{
false};
402 return {m_selected_column, m_selected_row};
420 if (detail::change_if_diff<>(m_selection_highlight, highlight))
432 return m_selection_highlight;
439 size_t m_selected_column{0};
441 size_t m_selected_row{0};
Definition serialize.h:200
Utility class for managing a set of flags with the ability to observe changes to the flags.
Definition flags.h:40
A Frame is a Widget that has children widgets.
Definition frame.h:45
Drawing interface for 2D graphics.
Definition painter.h:45
Simple x,y coordinate.
Definition geometry.h:63
EGT_NODISCARD constexpr Dim x() const noexcept
Get the x value.
Definition geometry.h:192
EGT_NODISCARD constexpr Dim y() const noexcept
Get the y value.
Definition geometry.h:194
StaticGrid with selectable cells.
Definition grid.h:353
EGT_NODISCARD GridPoint selected() const
Get the selected cell.
Definition grid.h:400
SelectableGrid(Serializer::Properties &props)
Definition grid.h:392
Signal on_selected_changed
Event signal.
Definition grid.h:361
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
void selected(size_t column, size_t row)
Set the selected cell.
SelectableGrid(Frame &parent, const Rect &rect, const GridSize &size=GridSize(1, 1))
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
SelectableGrid(Frame &parent, const GridSize &size=GridSize(1, 1))
SelectableGrid(const GridSize &size=GridSize(1, 1))
void handle(Event &event) override
Handle an event.
void selection_highlight(DefaultDim highlight)
Set the dimension of the selection highlight.
Definition grid.h:418
SelectableGrid(const Rect &rect, const GridSize &size=GridSize(1, 1))
EGT_NODISCARD DefaultDim selection_highlight() const
Get the dimension of the selection highlight.
Definition grid.h:430
SelectableGrid(Serializer::Properties &props, bool is_derived)
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
Static grid organization for widgets.
Definition grid.h:43
EGT_NODISCARD size_t n_row() const
Get the number of rows.
Definition grid.h:231
virtual void add(Widget &widget, const GridPoint &point)
Add a widget to the grid into a specific cell.
Definition grid.h:165
void reallocate(const GridSize &size)
Reallocate the size of the grid keeping any existing cells intact.
void serialize_children(Serializer &serializer) const override
Serialize the widget's children to the specified serializer.
StaticGrid(Serializer::Properties &props)
Definition grid.h:94
CellArray m_cells
Cell array of the grid.
Definition grid.h:319
void reposition()
Re-position all child widgets.
EGT_NODISCARD size_t n_col() const
Get the number of columns.
Definition grid.h:223
void add(const std::shared_ptr< Widget > &widget) override
Add a widget to the next empty cell.
StaticGrid(const Rect &rect, const GridSize &size=GridSize(1, 1))
EGT_NODISCARD GridSize grid_size() const
Get the GridSize.
Definition grid.h:239
void layout() override
Perform layout of the Widget.
std::vector< std::vector< std::weak_ptr< Widget > > > CellArray
Type for cell array.
Definition grid.h:316
EGT_NODISCARD DefaultDim horizontal_space() const
Get the horizontal space.
Definition grid.h:271
Widget * get(const GridPoint &point)
Get a widget at the specified row and column.
void deserialize_children(const Deserializer &deserializer) override
Deserialize the children of this widget.
StaticGrid(Frame &parent, const GridSize &size=GridSize(1, 1))
EGT_NODISCARD bool column_priority() const
Get the column priority status.
Definition grid.h:210
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
virtual void add(const std::shared_ptr< Widget > &widget, size_t column, size_t row)
Add a widget to the grid into a specific cell.
virtual void add(Widget &widget, size_t column, size_t row)
Add a widget to the grid into a specific cell.
Definition grid.h:136
void horizontal_space(DefaultDim space)
Set the horizontal space i.e.
Definition grid.h:259
void remove(Widget *widget) override
Remove a child widget.
EGT_NODISCARD int last_add_row() const
Returns the last row used for an add() call.
Definition grid.h:202
void column_priority(bool value)
Set the column priority status.
Definition grid.h:218
virtual void add(const std::shared_ptr< Widget > &widget, const GridPoint &point)
Add a widget to the grid into a specific cell.
Definition grid.h:154
GridFlag
Grid flags.
Definition grid.h:48
EGT_NODISCARD DefaultDim vertical_space() const
Get the vertical space.
Definition grid.h:291
EGT_NODISCARD int last_add_column() const
Returns the last column used for an add() call.
Definition grid.h:192
void vertical_space(DefaultDim space)
Set the vertical space i.e.
Definition grid.h:279
StaticGrid(Frame &parent, const Rect &rect, const GridSize &size=GridSize(1, 1))
StaticGrid(const GridSize &size=GridSize(1, 1))
StaticGrid(Serializer::Properties &props, bool is_derived)
void grid_size(const GridSize size)
Set the GridSize.
Definition grid.h:247
int DefaultDim
Define the default dimension type used for geometry.
Definition geometry.h:34
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255