HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
vulkan_widget.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#include "../GUI/gui_system.hpp"
10#include "../GFX/gfx_surface_delegate_vulkan.hpp"
11#include "widget.hpp"
12#include <vulkan/vulkan.hpp>
13
14namespace hi { inline namespace v1 {
15
19class vulkan_widget : public widget, public gfx_surface_delegate_vulkan {
20public:
21 using super = widget;
22
23 vulkan_widget(hi::gui_window& window, hi::widget *parent) noexcept : super(window, parent)
24 {
25 window.surface->add_delegate(this);
26 }
27
29 {
30 window.surface->remove_delegate(this);
31 }
32
33 widget_constraints const& set_constraints() noexcept override
34 {
35 _layout = {};
36 return _constraints = {{100, 50}, {200, 100}, {300, 100}, theme().margin};
37 }
38
39 void set_layout(hi::widget_layout const& layout) noexcept override
40 {
41 if (compare_store(_layout, layout)) {}
42 }
43
44 void draw(hi::draw_context const& context) noexcept override
45 {
46 if (*mode > widget_mode::invisible and overlaps(context, layout())) {
47 context.make_hole(_layout, _layout.rectangle());
48
49 draw_vulkan(aarectangle{_layout.to_window * _layout.rectangle()}, context.scissor_rectangle);
50 }
51 }
52};
53
54}} // namespace hi::v1
Defines widget.
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
A widget that draws directly into the swap-chain.
Definition vulkan_widget.hpp:19
widget_constraints const & set_constraints() noexcept override
Update the constraints of the widget.
Definition vulkan_widget.hpp:33
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
hi::theme const & theme() const noexcept
Get the theme.
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:62
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:48
The constraints of a widget.
Definition widget_constraints.hpp:26
The layout of a widget.
Definition widget_layout.hpp:37