7#include "abstract_container_widget.hpp"
8#include "grid_layout_delegate.hpp"
9#include "../GUI/theme.hpp"
10#include "../cell_address.hpp"
11#include "../flow_layout.hpp"
30 if (
auto delegate_ = _delegate.lock()) {
31 delegate_->deinit(*
this);
35 void init() noexcept
override
37 if (
auto delegate_ = _delegate.lock()) {
38 delegate_->init(*
this);
54 template<
typename T,
typename... Args>
57 auto tmp = std::make_shared<T>(
window, shared_from_this(), std::forward<Args>(args)...);
59 return std::static_pointer_cast<T>(add_widget(address,
std::move(tmp)));
66 template<
typename T,
cell_address CellAddress,
typename... Args>
69 return make_widget_at_address<T>(CellAddress, std::forward<Args>(args)...);
79 [[nodiscard]] aarect
rectangle(flow_layout
const &columns, flow_layout
const &rows)
const noexcept
81 ttlet first_column_nr = address.column.
begin(columns.nr_items());
82 ttlet last_column_nr = address.column.
end(columns.nr_items());
83 ttlet first_row_nr = address.row.
begin(rows.nr_items());
84 ttlet last_row_nr = address.row.
end(rows.nr_items());
86 ttlet[x, width] = columns.get_offset_and_size(first_column_nr, last_column_nr);
87 ttlet[y, height] = rows.get_offset_and_size(first_row_nr, last_row_nr);
89 return {x, y, width, height};
92 [[nodiscard]] relative_base_line
base_line(flow_layout
const &rows)
const noexcept
94 ttlet aligned_row_nr = address.row.
aligned_to(rows.nr_items());
95 return rows.get_base_line(aligned_row_nr);
100 cell_address _current_address =
"L0T0"_ca;
105 flow_layout _columns;
108 [[nodiscard]]
static f32x4
109 calculate_cell_min_size(
std::vector<cell> const &cells, flow_layout &rows, flow_layout &columns)
noexcept;
ssize_t end(ssize_t size) const noexcept
Find one beyond the end of the cell.
Definition cell_address.hpp:45
ssize_t begin(ssize_t size) const noexcept
Find the begin of the cell.
Definition cell_address.hpp:29
ssize_t aligned_to(ssize_t size) const noexcept
Find on which cell this aligns to.
Definition cell_address.hpp:61
Definition cell_address.hpp:149
Definition gui_window.hpp:39
Definition abstract_container_widget.hpp:11
Definition grid_layout_widget.hpp:16
std::shared_ptr< T > make_widget(Args &&...args)
Add a widget directly to this widget.
Definition grid_layout_widget.hpp:67
std::shared_ptr< T > make_widget_at_address(cell_address address, Args &&...args)
Add a widget directly to this widget.
Definition grid_layout_widget.hpp:55
void init() noexcept override
Should be called right after allocating and constructing a widget.
Definition grid_layout_widget.hpp:35
bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override
Update the constraints of the widget.
void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept override
Update the internal layout of the widget.
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:100
float base_line() const noexcept
Get the base-line in local coordinates.
Definition widget.hpp:350
abstract_container_widget const & parent() const noexcept
Get a reference to the parent.
aarect rectangle() const noexcept
Get the rectangle in local coordinates.
Definition widget.hpp:340