37 explicit grid(
const unsigned rows = 0,
const unsigned cols = 0);
77 unsigned add_row(
const unsigned count = 1);
129 const unsigned flags,
130 const unsigned border_size);
147 std::unique_ptr<widget>
swap_child(
const std::string&
id,
148 std::unique_ptr<widget>
w,
150 widget* new_parent =
nullptr);
158 void remove_child(
const unsigned row,
const unsigned col);
168 void remove_child(
const std::string&
id,
const bool find_all =
false);
259 virtual bool can_wrap()
const override;
278 const bool must_be_active)
override;
282 const bool must_be_active)
const override;
285 widget*
find(
const std::string_view
id,
const bool must_be_active)
override;
288 const widget*
find(
const std::string_view
id,
const bool must_be_active)
const override;
319 void set_rows_cols(
const unsigned rows,
const unsigned cols);
364 const std::string&
id()
const;
408 return std::exchange(
widget_,
nullptr);
456 return itor_->get_widget();
461 return itor_->get_widget();
466 return i.itor_ == this->
itor_;
471 return i.itor_ != this->
itor_;
void place(point origin, point size)
Places the widget in the cell.
unsigned border_size_
The size of the border, the actual configuration of the border is determined by the flags.
void layout_initialize(const bool full_initialization)
Forwards grid::layout_initialize to the cell.
void set_border_size(const unsigned border_size)
void set_widget(std::unique_ptr< widget > widget)
Acquires an owning reference to the given widget.
unsigned get_border_size() const
unsigned flags_
The flags for the border and cell setup.
void set_flags(const unsigned flags)
const std::string & id() const
Returns the id of the widget/.
point get_best_size() const
Returns the best size for the cell.
const widget * get_widget() const
std::unique_ptr< widget > free_widget()
Releases widget from ownership by this child and returns it in the form of a new shared_ptr.
point border_space() const
Returns the space needed for the border.
child(child &&) noexcept=default
Move constructor.
unsigned get_flags() const
bool can_wrap() const
Returns the can_wrap for the cell.
std::unique_ptr< widget > widget_
Pointer to the widget.
Iterator for the child items.
iterator(std::vector< child >::iterator itor)
std::vector< child >::iterator itor_
bool operator==(const iterator &i) const
bool operator!=(const iterator &i) const
void set_active(const bool active)
Activates all children.
virtual void impl_draw_children() override
See widget::impl_draw_children.
virtual bool has_widget(const widget &widget) const override
See widget::has_widget.
void request_placement(dispatcher &dispatcher, const event::ui_event event, bool &handled, bool &halt)
Attempts to lay out the grid without laying out the entire window.
virtual point calculate_best_size() const override
See widget::calculate_best_size.
std::unique_ptr< widget > swap_child(const std::string &id, std::unique_ptr< widget > w, const bool recurse, widget *new_parent=nullptr)
Exchanges a child in the grid.
bool disable_click_dismiss() const override
See widget::disable_click_dismiss.
static const unsigned HORIZONTAL_GROW_SEND_TO_CLIENT
static const unsigned HORIZONTAL_ALIGN_RIGHT
const grid::child & get_child(const unsigned row, const unsigned col) const
Gets the grid child in the specified cell.
virtual void place(const point &origin, const point &size) override
See widget::place.
void set_row_grow_factor(const unsigned row, const unsigned factor)
Sets the grow factor for a row.
void reduce_height(const unsigned maximum_height)
Tries to reduce the height of a container.
grid::child & get_child(const unsigned row, const unsigned col)
Gets the grid child in the specified cell.
virtual void set_visible_rectangle(const SDL_Rect &rectangle) override
See widget::set_visible_rectangle.
virtual iteration::walker_ptr create_walker() override
See widget::create_walker.
unsigned add_row(const unsigned count=1)
Adds a row to end of the grid.
const widget * get_widget(const unsigned row, const unsigned col) const
Returns the widget in the selected cell.
static const unsigned HORIZONTAL_SHIFT
void reduce_width(const unsigned maximum_width)
Tries to reduce the width of a container.
unsigned int get_rows() const
static const unsigned HORIZONTAL_MASK
point recalculate_best_size()
Recalculates the best size.
void set_column_grow_factor(const unsigned column, const unsigned factor)
Sets the grow factor for a column.
std::vector< child > children_
The child items.
static const unsigned VERTICAL_ALIGN_BOTTOM
static const unsigned BORDER_TOP
std::vector< unsigned > col_width_
The column widths in the grid.
void set_cols(const unsigned cols)
static const unsigned VERTICAL_ALIGN_CENTER
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
void set_rows(const unsigned rows)
static const unsigned VERTICAL_GROW_SEND_TO_CLIENT
widget * find(const std::string_view id, const bool must_be_active) override
See widget::find.
static const unsigned BORDER_BOTTOM
static const unsigned BORDER_RIGHT
static const unsigned HORIZONTAL_ALIGN_CENTER
void remove_child(const unsigned row, const unsigned col)
Removes and frees a widget in a cell.
friend class debug_layout_graph
grid(const unsigned rows=0, const unsigned cols=0)
virtual bool can_mouse_focus() const override
Whether the mouse move/click event go 'through' this widget.
void set_child_alignment(widget *widget, unsigned set_flag, unsigned mode_mask)
Modifies the widget alignment data of a child cell containing a specific widget.
void layout(const point &origin)
Layouts the children in the grid.
widget * get_widget(const unsigned row, const unsigned col)
Returns the widget in the selected cell.
unsigned cols_
The number of grid columns.
static const unsigned VERTICAL_MASK
void set_rows_cols(const unsigned rows, const unsigned cols)
Wrapper to set_rows and set_cols.
std::vector< unsigned > col_grow_factor_
The grow factor for all columns.
grid & operator=(const grid &)=delete
Delete the move assignment operator.
std::vector< unsigned > row_height_
The row heights in the grid.
static const unsigned VERTICAL_ALIGN_TOP
static const unsigned BORDER_LEFT
void set_child(std::unique_ptr< widget > widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.
unsigned int get_cols() const
static const unsigned BORDER_ALL
virtual void set_origin(const point &origin) override
See widget::set_origin.
virtual void demand_reduce_height(const unsigned maximum_height) override
See widget::demand_reduce_height.
grid(const grid &)=delete
Delete the copy constructor.
virtual bool can_wrap() const override
See widget::can_wrap.
virtual void layout_children() override
See widget::layout_children.
virtual void layout_initialize(const bool full_initialization) override
See widget::layout_initialize.
virtual void request_reduce_width(const unsigned maximum_width) override
See widget::request_reduce_width.
std::vector< unsigned > row_grow_factor_
The grow factor for all rows.
virtual void request_reduce_height(const unsigned maximum_height) override
See widget::request_reduce_height.
unsigned rows_
The number of grid rows.
static const unsigned HORIZONTAL_ALIGN_LEFT
static const unsigned VERTICAL_SHIFT
virtual void demand_reduce_width(const unsigned maximum_width) override
See widget::demand_reduce_width.
ui_event
The event sent to the dispatcher.
std::unique_ptr< class walker_base > walker_ptr
void set_single_child(grid &grid, std::unique_ptr< widget > widget)
Sets the single child in a grid.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
std::string::const_iterator iterator
Helper to implement private functions without modifying the header.