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*) {});
187 void add_at(
const std::shared_ptr<Widget>& widget,
size_t pos)
override;
219 return m_last_add_column;
229 return m_last_add_row;
250 return m_grid_size.width();
258 return m_grid_size.height();
274 if (detail::change_if_diff<>(m_grid_size, size))
286 if (detail::change_if_diff<>(m_horizontal_space, space))
298 return m_horizontal_space;
306 if (detail::change_if_diff<>(m_vertical_space, space))
318 return m_vertical_space;
341 using CellArray = std::vector<std::vector<std::weak_ptr<Widget>>>;
347 int m_last_add_column{-1};
349 int m_last_add_row{-1};
351 bool m_column_priority{
false};
427 return {m_selected_column, m_selected_row};
445 if (detail::change_if_diff<>(m_selection_highlight, highlight))
457 return m_selection_highlight;
464 size_t m_selected_column{0};
466 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:54
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:378
EGT_NODISCARD GridPoint selected() const
Get the selected cell.
Definition grid.h:425
SelectableGrid(Serializer::Properties &props)
Definition grid.h:417
Signal on_selected_changed
Event signal.
Definition grid.h:386
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:443
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:455
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:256
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:344
void reposition()
Re-position all child widgets.
EGT_NODISCARD size_t n_col() const
Get the number of columns.
Definition grid.h:248
void add(const std::shared_ptr< Widget > &widget) override
Add a widget to the next empty cell.
void add_at(const std::shared_ptr< Widget > &widget, size_t pos) override
Add a widget at a specific position.
StaticGrid(const Rect &rect, const GridSize &size=GridSize(1, 1))
EGT_NODISCARD GridSize grid_size() const
Get the GridSize.
Definition grid.h:264
void layout() override
Perform layout of the Widget.
std::vector< std::vector< std::weak_ptr< Widget > > > CellArray
Type for cell array.
Definition grid.h:341
EGT_NODISCARD DefaultDim horizontal_space() const
Get the horizontal space.
Definition grid.h:296
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:235
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:284
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:227
void column_priority(bool value)
Set the column priority status.
Definition grid.h:243
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:316
void remove_at(size_t pos) override
Remove the widget at the specific position.
EGT_NODISCARD int last_add_column() const
Returns the last column used for an add() call.
Definition grid.h:217
void vertical_space(DefaultDim space)
Set the vertical space i.e.
Definition grid.h:304
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:272
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