14#include "../geometry/module.hpp"
15#include "../layout/module.hpp"
16#include "../macros.hpp"
18namespace hi {
inline namespace v1 {
46template<axis Axis = axis::both>
63 hi_axiom(loop::main().on_thread());
64 hi_assert_not_null(
parent);
69 auto aperture = std::make_unique<scroll_aperture_widget>(
this);
71 this, aperture->content_width, aperture->aperture_width, aperture->offset_x);
73 this, aperture->content_height, aperture->aperture_height, aperture->offset_y);
75 if (to_bool(
axis & axis::horizontal)) {
81 if (to_bool(
axis & axis::vertical)) {
87 _aperture = aperture.get();
91 _grid.add_cell(0, 0,
std::move(aperture));
108 return _aperture->make_widget<
Widget>(std::forward<Args>(args)...);
115 co_yield *_vertical_scroll_bar;
116 co_yield *_horizontal_scroll_bar;
123 for (
auto&
cell : _grid) {
124 cell.set_constraints(
cell.value->update_constraints());
130 void set_layout(widget_layout
const&
context)
noexcept override
133 _grid.set_layout(
context.shape, theme().baseline_adjustment());
136 for (hilet&
cell : _grid) {
137 auto shape =
cell.shape;
139 if (
cell.value.get() == _aperture) {
143 if (
not _vertical_scroll_bar->visible()) {
144 shape.rectangle = aarectangle{0, shape.y(), _layout.width(), shape.height()};
146 if (
not _horizontal_scroll_bar->visible()) {
147 shape.rectangle = aarectangle{shape.x(), 0, shape.width(), _layout.height()};
151 cell.value->set_layout(
context.transform(shape, 0.0f));
155 void draw(draw_context
const&
context)
noexcept override
158 for (hilet&
cell : _grid) {
164 [[
nodiscard]] hitbox hitbox_test(point2 position)
const noexcept override
166 hi_axiom(loop::main().on_thread());
173 if (
layout().contains(position)) {
174 r =
std::max(r, hitbox{
id, _layout.elevation});
186 scroll_aperture_widget *_aperture;
187 horizontal_scroll_bar_type *_horizontal_scroll_bar;
188 vertical_scroll_bar_type *_vertical_scroll_bar;
Defines scroll_bar_widget.
Defines scroll_aperture_widget.
axis
An enumeration of the 3 axis for 3D geometry.
Definition axis.hpp:19
@ partial
A widget is partially enabled.
@ collapse
The widget is collapsed.
@ 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_id id
The numeric identifier of a widget.
Definition widget_intf.hpp:23
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
2D constraints.
Definition box_constraints.hpp:25
Scroll bar widget This widget is used in a pair of a vertical and horizontal scrollbar as a child of ...
Definition scroll_bar_widget.hpp:37
The scroll widget allows a content widget to be shown in less space than is required.
Definition scroll_widget.hpp:47
Widget & make_widget(Args &&...args) noexcept
Add a content widget directly to this scroll widget.
Definition scroll_widget.hpp:106
scroll_widget(widget *parent) noexcept
Constructs an empty scroll widget.
Definition scroll_widget.hpp:61
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget_layout const & layout() const noexcept override
Get the current layout for this widget.
Definition widget.hpp:169
int semantic_layer
The draw layer of the widget.
Definition widget.hpp:66
observer< extent2 > minimum
The minimum size this widget is allowed to be.
Definition widget.hpp:79
widget(widget *parent) noexcept
Definition widget.hpp:87
virtual hitbox hitbox_test_from_parent(point2 position) const noexcept
Call hitbox_test from a parent widget.
Definition widget.hpp:132
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42
observer< extent2 > maximum
The maximum size this widget is allowed to be.
Definition widget.hpp:83