12#include "../macros.hpp"
15hi_export_module(hikogui.widgets.overlay_widget);
17hi_export
namespace hi {
inline namespace v1 {
59 ++global_counter<
"overlay_widget:set_widget:constrain">;
72 template<
typename Widget,
typename... Args>
75 hi_axiom(loop::main().on_thread());
76 hi_assert(_content ==
nullptr);
78 auto tmp = std::make_unique<Widget>(
this, std::forward<Args>(args)...);
85 [[nodiscard]] generator<widget_intf &> children(
bool include_invisible)
noexcept override
93 _content_constraints = _content->update_constraints();
94 return _content_constraints;
97 void set_layout(widget_layout
const& context)
noexcept override
102 _layout.clipping_rectangle = context.rectangle() + theme().border_width();
104 auto const content_rectangle = context.rectangle();
105 _content_shape = box_shape{_content_constraints, content_rectangle, theme().baseline_adjustment()};
108 _content->set_layout(_layout.transform(_content_shape, context.rectangle()));
111 void draw(draw_context
const& context)
noexcept override
114 if (overlaps(context,
layout())) {
115 draw_background(context);
117 _content->draw(context);
121 [[nodiscard]] color background_color() const noexcept
override
123 return theme().color(semantic_color::fill, _layout.layer + 1);
126 [[nodiscard]] color foreground_color() const noexcept
override
128 return theme().color(semantic_color::border, _layout.layer + 1);
137 [[nodiscard]] hitbox hitbox_test(point2 position)
const noexcept override
139 hi_axiom(loop::main().on_thread());
142 return _content->hitbox_test_from_parent(position);
148 bool handle_event(gui_event
const& event)
noexcept override
156 box_constraints _content_constraints;
157 box_shape _content_shape;
159 void draw_background(draw_context
const& context)
noexcept
@ 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.
The HikoGUI namespace.
Definition array_generic.hpp:20
@ outside
The border is drawn outside the edge of a quad.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:33
Definition widget_intf.hpp:24
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget_intf.hpp:206
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:35
2D constraints.
Definition box_constraints.hpp:25
A GUI widget which may exist anywhere on a window overlaid above any other widget.
Definition overlay_widget.hpp:42
overlay_widget(widget_intf const *parent) noexcept
Constructs an empty overlay widget.
Definition overlay_widget.hpp:52
Widget & emplace(Args &&...args) noexcept
Add a content widget directly to this overlay widget.
Definition overlay_widget.hpp:73
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
void scroll_to_show() noexcept
Scroll to show the important part of the widget.
Definition widget_intf.hpp:312
widget() noexcept
Constructor for creating sub views.
Definition widget.hpp:55
bool process_event(gui_event const &event) const noexcept override
Send a event to the window.
Definition widget.hpp:130