12#include "grid_layout.hpp"
16namespace hi {
inline namespace v1 {
63 template<
typename Widget,
typename... Args>
67 auto tmp = std::make_unique<Widget>(
window,
this, std::forward<Args>(args)...);
68 return static_cast<Widget&
>(add_widget(column_first, row_first, column_last, row_last,
std::move(tmp)));
79 template<
typename Widget,
typename... Args>
82 auto tmp = std::make_unique<Widget>(
window,
this, std::forward<Args>(args)...);
83 return static_cast<Widget&
>(add_widget(column, row, column + 1, row + 1,
std::move(tmp)));
94 template<
typename Widget,
typename... Args>
97 hilet[column_first, row_first, column_last, row_last] = parse_spreadsheet_range(address);
98 return make_widget<Widget>(column_first, row_first, column_last, row_last, std::forward<Args>(args)...);
102 [[nodiscard]] generator<widget *> children() const noexcept
override
104 for (
hilet& cell : _cells) {
105 co_yield cell.widget.get();
109 widget_constraints
const& set_constraints() noexcept override;
110 void set_layout(widget_layout const&
layout) noexcept override;
111 void draw(draw_context const& context) noexcept override;
112 [[nodiscard]] hitbox hitbox_test(point3 position) const noexcept override;
128 column_first(column_first),
129 row_first(row_first),
130 column_last(column_last),
136 [[nodiscard]] aarectangle
137 rectangle(grid_layout
const& columns, grid_layout
const& rows,
float container_height)
const noexcept
139 hilet[x0, x3] = columns.get_positions(column_first, column_last);
140 hilet[y0, y3] = rows.get_positions(row_first, row_last);
142 return {point2{x0, container_height - y3}, point2{x3, container_height - y0}};
145 [[nodiscard]] widget_baseline baseline(grid_layout
const& rows)
const noexcept
147 return rows.get_baseline(row_first, row_last);
154 grid_layout _columns;
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
The functions in this file are for handling spreadsheet addresses.
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
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 column, std::size_t row, Args &&...args)
Add a widget directly to this grid-widget.
Definition grid_widget.hpp:80
Widget & make_widget(std::size_t column_first, std::size_t row_first, std::size_t column_last, std::size_t row_last, Args &&...args)
Add a widget directly to this grid-widget.
Definition grid_widget.hpp:65
Widget & make_widget(std::string_view address, Args &&...args)
Add a widget directly to this grid-widget.
Definition grid_widget.hpp:95
grid_widget(gui_window &window, widget *parent) noexcept
Constructs an empty grid widget.
An interactive graphical object as part of the user-interface.
Definition widget.hpp:44
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget.hpp:198
widget *const parent
Pointer to the parent widget.
Definition widget.hpp:53
widget(gui_window &window, widget *parent) noexcept
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:48