5#include "grid_cell.hpp"
7namespace hi {
inline namespace v1 {
9constexpr ~grid_cell::grid_cell()
12 _grid->remove_cell(_id);
13 _grid->state |= grid_state::need_constrain;
17constexpr grid_cell::grid_cell(grid_cell&&
other) noexcept : _grid(
other._grid), _id(
other._id)
19 other._grid =
nullptr;
22constexpr grid_cell& grid_cell::operator=(grid_cell&&
other)
noexcept
25 _grid->remove_cell(_id);
26 _grid->state |= grid_state::need_constrain;
29 _grid = std::exchange(
other._grid,
nullptr);
33constexpr grid_cell::grid_cell(grid
const& grid) noexcept : _grid(
std::addressof(grid)), _id(grid.add_cell())
35 _grid->state |= grid_state::need_constrain;
40 return _grid->at(_id).in_use == 0;
46 _grid->state |= grid_state::need_constrain;
58 updated |=
compare_store(_grid->at(_id).col_begin, col_begin);
59 updated |=
compare_store(_grid->at(_id).row_begin, row_begin);
63 _grid->state |= grid_state::need_constrain;
70 _grid->state |= grid_state::need_constrain;
77 _grid->state |= grid_state::need_constrain;
81constexpr void grid_cell::set_priority(int8_t width_priority, int8_t height_priority)
noexcept
84 updated |=
compare_store((*_grid)[_id].width_priority, width_priority);
85 updated |=
compare_store((*_grid)[_id].height_priority, height_priority);
87 _grid->state |= grid_state::need_constrain;
91constexpr void grid_cell::set_margin(
hi::margins margin)
noexcept
94 updated |=
compare_store((*_grid)[_id].margin_left, round_cast<int8_t>(margin.left()));
95 updated |=
compare_store((*_grid)[_id].margin_bottom, round_cast<int8_t>(margin.bottom()));
96 updated |=
compare_store((*_grid)[_id].margin_right, round_cast<int8_t>(margin.right()));
97 updated |=
compare_store((*_grid)[_id].margin_top, round_cast<int8_t>(margin.top()));
99 _grid->state |= grid_state::need_constrain;
103constexpr void grid_cell::set_size(hi::extent size)
noexcept
105 hi_axiom((*_grid)[_id].parent == -1);
106 hi_axiom((*_grid)[_id].col_begin == 0);
107 hi_axiom((*_grid)[_id].row_begin == 0);
108 hi_axiom((*_grid)[_id].col_end == 1);
109 hi_axiom((*_grid)[_id].row_end == 1);
111 auto updated =
false;
112 updated |=
compare_store((*_grid)[_id].width, round_cast<int32_t>(size.width()));
113 updated |=
compare_store((*_grid)[_id].height, round_cast<int32_t>(size.height()));
115 _grid->state |= grid_state::need_layout;
119[[nodiscard]]
constexpr aarectangle grid_cell::rectangle() const noexcept
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition utility.hpp:212
A cell in a grid.
Definition grid_cell.hpp:141
constexpr void set_parent(grid_cell const &parent) noexcept
Set the parent for this child-cell.
Definition grid_cell_impl.hpp:67
constexpr bool empty() const noexcept
Check if this cell has a location.
Definition grid_cell_impl.hpp:38
constexpr void clear() noexcept
Clear the cell.
Definition grid_cell_impl.hpp:43
constexpr void unset_parent(grid_cell const &parent) noexcept
Remove the parent for this child-cell.
Definition grid_cell_impl.hpp:74
constexpr void set_location() noexcept
Set the location to the origin of the grid.
Definition grid_cell.hpp:215