12#include "../layout/module.hpp"
13#include "../macros.hpp"
16namespace hi {
inline namespace v1 {
52 hi_axiom(loop::main().on_thread());
73 hi_axiom(first_column < last_column);
74 hi_axiom(first_row < last_row);
75 auto tmp = std::make_unique<Widget>(
this, std::forward<Args>(args)...);
76 return static_cast<Widget&
>(add_widget(first_column, first_row, last_column, last_row,
std::move(
tmp)));
111 for (hilet&
cell : _grid) {
112 co_yield *
cell.value;
120 for (
auto&
cell : _grid) {
121 cell.set_constraints(
cell.value->update_constraints());
124 return _grid.constraints(os_settings::left_to_right());
126 void set_layout(widget_layout
const&
context)
noexcept override
129 _grid.set_layout(
context.shape, theme().baseline_adjustment());
132 for (hilet&
cell : _grid) {
136 void draw(draw_context
const&
context)
noexcept override
139 for (hilet&
cell : _grid) {
144 [[
nodiscard]] hitbox hitbox_test(point2 position)
const noexcept override
146 hi_axiom(loop::main().on_thread());
150 for (hilet&
cell : _grid) {
151 r =
cell.value->hitbox_test_from_parent(position, r);
171 hi_axiom(loop::main().on_thread());
172 hi_axiom(first_column < last_column);
173 hi_axiom(first_row < last_row);
175 if (_grid.cell_in_use(first_column, first_row, last_column, last_row)) {
176 hi_log_fatal(
"cell ({},{}) of grid_widget is already in use", first_column, first_row);
180 _grid.add_cell(first_column, first_row, last_column, last_row,
std::move(
widget));
181 hi_log_info(
"grid_widget::add_widget({}, {}, {}, {})", first_column, first_row, last_column, last_row);
183 ++global_counter<
"grid_widget:add_widget:constrain">;
@ window_reconstrain
Request that widget get constraint on the next frame.
@ partial
A widget is partially enabled.
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:56
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
A GUI widget that lays out child-widgets in a grid with variable sized cells.
Definition grid_widget.hpp:40
Widget & make_widget(std::size_t first_column, std::size_t first_row, std::size_t last_column, std::size_t last_row, Args &&...args)
Add a widget directly to this grid-widget.
Definition grid_widget.hpp:71
Widget & make_widget(std::size_t column, std::size_t row, Args &&...args)
Add a widget directly to this grid-widget.
Definition grid_widget.hpp:88
Widget & make_widget(std::string_view address, Args &&...args)
Add a widget directly to this grid-widget.
Definition grid_widget.hpp:102
grid_widget(widget *parent) noexcept
Constructs an empty grid widget.
Definition grid_widget.hpp:50
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
int semantic_layer
The draw layer of the widget.
Definition widget.hpp:66
widget(widget *parent) noexcept
Definition widget.hpp:87
bool process_event(gui_event const &event) const noexcept override
Send a event to the window.
Definition widget.hpp:178
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42