HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
window_widget.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2020-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#pragma once
10
11#include "widget.hpp"
12#include "../label.hpp"
13
14namespace hi { inline namespace v1 {
15class toolbar_widget;
16class system_menu_widget;
17class grid_widget;
18
25class window_widget final : public widget {
26public:
27 using super = widget;
28
29 observer<label> title;
30
31 window_widget(gui_window *window, forward_of<observer<label>> auto&& title) noexcept :
32 super(nullptr), _window(window), title(hi_forward(title))
33 {
34 hi_assert_not_null(_window);
35 constructor_implementation();
36 }
37
42 [[nodiscard]] color background_color() noexcept;
43
48 [[nodiscard]] grid_widget& content() noexcept;
49
54 [[nodiscard]] toolbar_widget& toolbar() noexcept;
55
57 [[nodiscard]] generator<widget const &> children(bool include_invisible) const noexcept override;
58 [[nodiscard]] box_constraints update_constraints() noexcept override;
59 void set_layout(widget_layout const& context) noexcept override;
60 void draw(draw_context const& context) noexcept override;
61 [[nodiscard]] hitbox hitbox_test(point2i position) const noexcept override;
62 bool handle_event(gui_event const& event) noexcept override;
63 bool process_event(gui_event const& event) const noexcept override;
64 [[nodiscard]] gui_window *window() const noexcept override;
65 [[nodiscard]] hi::theme const& theme() const noexcept override;
66 [[nodiscard]] gfx_surface const *surface() const noexcept override;
68private:
69 gui_window *_window;
70
71 std::unique_ptr<grid_widget> _content;
72 box_constraints _content_constraints;
73 box_shape _content_shape;
74
75 std::unique_ptr<toolbar_widget> _toolbar;
76 box_constraints _toolbar_constraints;
77 box_shape _toolbar_shape;
78
79 mutable bool _can_resize_width;
80 mutable bool _can_resize_height;
81
82#if HI_OPERATING_SYSTEM == HI_OS_WINDOWS
83 system_menu_widget *_system_menu = nullptr;
84#endif
85
86 void constructor_implementation() noexcept;
87};
88
89}} // namespace hi::v1
Functionality for labels, text and icons.
Defines widget.
#define hi_assert_not_null(x,...)
Assert if an expression is not nullptr.
Definition assert.hpp:223
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
STL namespace.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
This is a RGBA floating point color.
Definition color.hpp:42
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:211
A user interface event.
Definition gui_event.hpp:74
2D constraints.
Definition box_constraints.hpp:22
Definition box_shape.hpp:15
A GUI widget that lays out child-widgets in a grid with variable sized cells.
Definition grid_widget.hpp:39
The system menu widget.
Definition system_menu_widget.hpp:26
A toolbar widget is located at the top of a window and lays out its children horizontally.
Definition toolbar_widget.hpp:34
An interactive graphical object as part of the user-interface.
Definition widget.hpp:46
widget(widget *parent) noexcept
The layout of a widget.
Definition widget_layout.hpp:38
The top-level window widget.
Definition window_widget.hpp:25
grid_widget & content() noexcept
Get a reference to the window's content widget.
toolbar_widget & toolbar() noexcept
Get a reference to window's toolbar widget.
color background_color() noexcept
The background color of the window.