Add grid layout child adding helpers
This commit is contained in:
parent
a0e81aaf32
commit
5ddf8795d5
2 changed files with 29 additions and 2 deletions
|
|
@ -32,6 +32,11 @@ namespace psemek::ui
|
|||
virtual std::shared_ptr<element> set(std::size_t i, std::size_t j, std::shared_ptr<element> c);
|
||||
virtual std::shared_ptr<element> remove(std::size_t i, std::size_t j);
|
||||
|
||||
virtual void add_row();
|
||||
virtual void add_row(std::shared_ptr<element> c);
|
||||
virtual void add_column();
|
||||
virtual void add_column(std::shared_ptr<element> c);
|
||||
|
||||
virtual void set_outer_margin(bool value);
|
||||
virtual bool outer_margin() const { return outer_margin_; }
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,28 @@ namespace psemek::ui
|
|||
return set(i, j, nullptr);
|
||||
}
|
||||
|
||||
void grid_layout::add_row()
|
||||
{
|
||||
set_row_count(row_count() + 1);
|
||||
}
|
||||
|
||||
void grid_layout::add_row(std::shared_ptr<element> c)
|
||||
{
|
||||
set_row_count(row_count() + 1);
|
||||
set(row_count() - 1, 0, c);
|
||||
}
|
||||
|
||||
void grid_layout::add_column()
|
||||
{
|
||||
set_column_count(column_count() + 1);
|
||||
}
|
||||
|
||||
void grid_layout::add_column(std::shared_ptr<element> c)
|
||||
{
|
||||
set_column_count(column_count() + 1);
|
||||
set(0, column_count() - 1, c);
|
||||
}
|
||||
|
||||
void grid_layout::set_outer_margin(bool value)
|
||||
{
|
||||
outer_margin_ = value;
|
||||
|
|
@ -150,7 +172,7 @@ namespace psemek::ui
|
|||
|
||||
geom::box<float, 2> grid_layout::size_constraints() const
|
||||
{
|
||||
auto st = merged_style();
|
||||
auto st = merged_own_style();
|
||||
if (!st) return element::size_constraints();
|
||||
|
||||
auto row_column_size = row_column_sizes(children_);
|
||||
|
|
@ -186,7 +208,7 @@ namespace psemek::ui
|
|||
|
||||
void grid_layout::reshape(geom::box<float, 2> const & bbox)
|
||||
{
|
||||
auto st = merged_style();
|
||||
auto st = merged_own_style();
|
||||
if (!st) return;
|
||||
|
||||
float const margin = *st->outer_margin;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue