HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
vulkan_widget.hpp
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
5#include "../GUI/gui_system.hpp"
6#include "../GFX/gfx_surface_delegate_vulkan.hpp"
7#include "widget.hpp"
8#include <vulkan/vulkan.hpp>
9
10namespace hi::inline v1 {
11
15public:
16 using super = widget;
17
18 vulkan_widget(hi::gui_window& window, hi::widget *parent) noexcept : super(window, parent)
19 {
20 window.surface->add_delegate(this);
21 }
22
24 {
25 window.surface->remove_delegate(this);
26 }
27
28 widget_constraints const& set_constraints() noexcept override
29 {
30 _layout = {};
31 return _constraints = {{100, 50}, {200, 100}, {300, 100}, theme().margin};
32 }
33
34 void set_layout(hi::widget_layout const& layout) noexcept override
35 {
36 if (compare_store(_layout, layout)) {}
37 }
38
39
40
41 void draw(hi::draw_context const& context) noexcept override
42 {
43 if (*mode > widget_mode::invisible and overlaps(context, layout())) {
44 context.make_hole(_layout, _layout.rectangle());
45
46 draw_vulkan(aarectangle{_layout.to_window * _layout.rectangle()}, context.scissor_rectangle);
47 }
48 }
49};
50
51} // namespace hi::inline v1
Definition gfx_surface_delegate_vulkan.hpp:15
Definition theme.hpp:21
float margin
Distance between widgets and between widgets and the border of the container.
Definition theme.hpp:35
A widget that draws directly into the swap-chain.
Definition vulkan_widget.hpp:14
widget_constraints const & set_constraints() noexcept override
Update the constraints of the widget.
Definition vulkan_widget.hpp:28
An interactive graphical object as part of the user-interface.
Definition widget.hpp:39
Definition widget_constraints.hpp:13