HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
grid_cell.hpp
1
2
3#pragma once
4
5#include "../geometry/module.hpp"
6
7namespace hi { inline namespace v1 {
8
9namespace detail {
10
12 int32_t parent = -1;
13 uint32_t in_use : 1 = 0;
14 uint32_t leaf : 1 = 0;
15 uint32_t perminant_mark : 1 = 0;
16 uint32_t temporary_mark : 1 = 0;
17 uint32_t reserved : 28 = 0;
18
21 int32_t col_offset = 0;
22
25 int32_t row_offset = 0;
26
27 int8_t col_begin = 0;
28 int8_t col_end = 0;
29 int8_t row_begin = 0;
30 int8_t row_end = 0;
31
34 int8_t width_priority = 0;
35
38 int8_t height_priority = 0;
39
43 int8_t margin_left = 0;
44
48 int8_t margin_bottom = 0;
49
53 int8_t margin_right = 0;
54
58 int8_t margin_top = 0;
59
63
67
71
75
79
83
87 int32_t left;
88
92 int32_t bottom;
93
97 int32_t width;
98
102 int32_t height;
103
107 int8_t num_cols = 0;
108
112 int8_t num_rows = 0;
113
118
123
128
133};
134
135}
136
142public:
143 constexpr grid_cell(grid_cell const&) = delete;
144 constexpr grid_cell(grid_cell&& other) noexcept;
145 constexpr grid_cell& operator=(grid_cell const&) = delete;
146 constexpr grid_cell& operator=(grid_cell&& other) noexcept;
147 [[nodiscard]] constexpr friend bool operator==(grid_cell const&, grid_cell const&) noexcept = default;
148
149 constexpr ~grid_cell();
150 constexpr grid_cell() noexcept = default;
151 constexpr grid_cell(grid& grid) noexcept;
152
153 constexpr grid_cell(grid_cell const& parent, uint8_t col_begin, uint8_t row_begin, uint8_t col_end, uint8_t row_end) noexcept
154 :
155 grid_cell(*parent._grid)
156 {
157 set_parent(parent);
158 set_location(col_begin, row_begin, col_end, row_end);
159 }
160
161 constexpr grid_cell(grid_cell const& parent, uint8_t col_begin, uint8_t row_begin) noexcept : grid_cell(*parent._grid)
162 {
163 set_parent(parent);
164 set_location(col_begin, row_begin);
165 }
166
167 constexpr grid_cell(grid_cell const& parent, std::string_view address) noexcept : grid_cell(*parent._grid)
168 {
169 set_parent(parent);
170 set_location(address);
171 }
172
175 [[nodiscard]] constexpr bool empty() const noexcept;
176
181 constexpr void clear() noexcept;
182
190 constexpr void set_location(uint8_t col_begin, uint8_t row_begin, uint8_t col_end, uint8_t row_end) noexcept;
191
198 constexpr void set_location(uint8_t col, uint8_t row) noexcept
199 {
200 return set_location(col, col + 1, row, row + 1);
201 }
202
207 constexpr void set_location(std::string_view address) noexcept
208 {
209 [ col_begin, row_begin, col_end, row_end ] = parse_spreadsheet_range(address);
210 return set_location(col_begin, row_begin, col_end, row_end)
211 }
212
215 constexpr void set_location() noexcept
216 {
217 return set_location(0, 0);
218 }
219
224 constexpr void set_parent(grid_cell const& parent) noexcept;
225
232 constexpr void unset_parent(grid_cell const& parent) noexcept;
233
234 constexpr void set_priority(int8_t width_priority, int8_t height_priority) noexcept;
235
236 constexpr void set_priority(int8_t priority = 0) noexcept
237 {
238 return set_priority(priority, priority);
239 }
240
241 constexpr void set_margin(hi::margins margin) noexcept;
242
243 constexpr void set_margin(float margins) noexcept
244 {
245 return set_margin(hi::margins{margin});
246 }
247
248 constexpr void set_constraints(hi::extent2 minimum, hi::extent2 maximum, hi::extent2 wrap) noexcept;
249
250 constexpr void set_constraints(hi::extent2 minimum, hi::extent2 maximum) noexcept
251 {
252 return set_constraints(minimum, maximum, minimum);
253 }
254
255 constexpr void set_constraints(hi::extent2 size) noexcept
256 {
257 return set_constraints(size);
258 }
259
260 constexpr void set_size(hi::extent2 size) noexcept;
261
262 [[nodiscard]] constexpr aarectangle rectangle() const noexcept;
263
264private:
265 grid *_grid = nullptr;
266 size_t _id = 0;
267};
268
269}} // namespace hi::v1
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
The layout-algorithm:
Definition grid.hpp:24
Definition grid_cell.hpp:11
int32_t width
The width of this cell.
Definition grid_cell.hpp:97
int32_t left
The left position of this cell relative to the parent.
Definition grid_cell.hpp:87
int8_t num_rows
Number of rows based on the locations of this cell's children.
Definition grid_cell.hpp:112
int8_t width_priority
The priority when the change the width compared to other cells in the row.
Definition grid_cell.hpp:34
int32_t wrapped_height
The taller height when the cell can wrap.
Definition grid_cell.hpp:74
int32_t row_offset
Offset in the row table.
Definition grid_cell.hpp:25
int8_t row_before_margin
The top-margin calculated from children.
Definition grid_cell.hpp:122
int32_t maximum_width
The maximum width.
Definition grid_cell.hpp:70
int8_t margin_right
The right-margin for this cell.
Definition grid_cell.hpp:53
int32_t col_offset
Offset in the column table.
Definition grid_cell.hpp:21
int8_t row_after_margin
The bottom margin calculated from children.
Definition grid_cell.hpp:132
int32_t wrapped_width
The thinner width when the cell can wrap.
Definition grid_cell.hpp:62
int8_t height_priority
The priority when the change the height compared to other cells in the column.
Definition grid_cell.hpp:38
int8_t margin_left
The left-margin for this cell.
Definition grid_cell.hpp:43
int8_t num_cols
Number of columns based on the locations of this cell's children.
Definition grid_cell.hpp:107
int32_t minimum_height
The minimum height.
Definition grid_cell.hpp:78
int8_t col_after_margin
The right-margin (rtl: left-margin) calculated from children.
Definition grid_cell.hpp:127
int32_t bottom
The bottom position of this cell relative to the parent.
Definition grid_cell.hpp:92
int8_t col_before_margin
The left-margin (rtl: right-margin) calculated from children.
Definition grid_cell.hpp:117
int8_t margin_bottom
The bottom-margin for this cell.
Definition grid_cell.hpp:48
int32_t maximum_height
The maximum height.
Definition grid_cell.hpp:82
int32_t minimum_width
The preferred width.
Definition grid_cell.hpp:66
int8_t margin_top
The top-margin for this cell.
Definition grid_cell.hpp:58
int32_t height
The height of this cell.
Definition grid_cell.hpp:102
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 void set_location(uint8_t col, uint8_t row) noexcept
Set the location of a cell.
Definition grid_cell.hpp:198
constexpr bool empty() const noexcept
Check if this cell has a location.
Definition grid_cell_impl.hpp:38
constexpr void set_location(std::string_view address) noexcept
Set the location and span of a cell based on the spreadsheet address.
Definition grid_cell.hpp:207
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