11#include "../GUI/module.hpp"
13namespace hi {
inline namespace v1 {
38template<fixed_string Name =
"">
42 constexpr static auto prefix = Name /
"overlay";
63 ++global_counter<
"overlay_widget:set_widget:constrain">;
76 template<
typename Widget,
typename... Args>
82 auto tmp = std::make_unique<Widget>(
this, std::forward<Args>(args)...);
89 [[nodiscard]] generator<widget const&> children(
bool include_invisible)
const noexcept override
96 _content_constraints = _content->update_constraints();
97 return _content_constraints;
100 void set_layout(widget_layout
const& context)
noexcept override
107 hilet content_rectangle = context.rectangle();
108 _content_shape = box_shape{_content_constraints, content_rectangle, theme<prefix>.cap_height(
this)};
111 _content->set_layout(layout.
transform(_content_shape, 1.0f, context.rectangle()));
114 void draw(widget_draw_context
const& context)
noexcept override
117 if (overlaps(context, layout)) {
118 draw_background(context);
120 _content->draw(context);
130 [[nodiscard]] hitbox hitbox_test(point2i position)
const noexcept override
135 return _content->hitbox_test_from_parent(position);
143 box_constraints _content_constraints;
144 box_shape _content_shape;
146 void draw_background(widget_draw_context
const& context)
noexcept
151 theme<prefix>.background_color(
this),
152 theme<prefix>.border_color(
this),
153 theme<prefix>.border_width(
this),
#define hi_assert(expression,...)
Assert if expression is true.
Definition assert.hpp:199
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
@ window_reconstrain
Request that widget get constraint on the next frame.
@ rectangle
The gui_event has rectangle data.
@ partial
A widget is partially enabled.
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
@ outside
The border is drawn outside the edge of a quad.
widget * parent
Pointer to the parent widget.
Definition widget.hpp:40
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:53
size_t semantic_layer
The draw layer of the widget.
Definition widget.hpp:85
constexpr widget_layout transform(box_shape const &child_shape, float child_elevation, aarectanglei new_clipping_rectangle) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:203
aarectanglei clipping_rectangle
The clipping rectangle.
Definition widget_layout.hpp:86
2D constraints.
Definition box_constraints.hpp:22
A GUI widget which may exist anywhere on a window overlaid above any other widget.
Definition overlay_widget.hpp:39
overlay_widget(widget *parent) noexcept
Constructs an empty overlay widget.
Definition overlay_widget.hpp:50
Widget & make_widget(Args &&...args) noexcept
Add a content widget directly to this overlay widget.
Definition overlay_widget.hpp:77