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(window, nullptr), title(hi_forward(title))
33 {
34 constructor_implementation();
35 }
36
41 [[nodiscard]] color background_color() noexcept;
42
47 [[nodiscard]] grid_widget& content() noexcept;
48
53 [[nodiscard]] toolbar_widget& toolbar() noexcept;
54
57 void set_resize_border_priority(bool left, bool right, bool bottom, bool top) noexcept;
58
60 [[nodiscard]] generator<widget *> children() const noexcept override;
61 widget_constraints const& set_constraints() noexcept override;
62 void set_layout(widget_layout const& layout) noexcept;
63 void draw(draw_context const& context) noexcept override;
64 [[nodiscard]] hitbox hitbox_test(point3 position) const noexcept override;
65 bool handle_event(gui_event const& event) noexcept override;
67private:
68 aarectangle _content_rectangle;
69 widget_constraints _content_constraints;
70 std::unique_ptr<grid_widget> _content;
71
72 aarectangle _toolbar_rectangle;
73 widget_constraints _toolbar_constraints;
74 std::unique_ptr<toolbar_widget> _toolbar;
75#if HI_OPERATING_SYSTEM == HI_OS_WINDOWS
76 system_menu_widget *_system_menu = nullptr;
77#endif
78
79 bool _left_resize_border_has_priority = true;
80 bool _right_resize_border_has_priority = true;
81 bool _bottom_resize_border_has_priority = true;
82 bool _top_resize_border_has_priority = true;
83
84 void constructor_implementation() noexcept;
85};
86
87}} // namespace hi::v1
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
Functionality for labels, text and icons.
Defines widget.
STL namespace.
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
A user interface event.
Definition gui_event.hpp:66
A GUI widget that lays out child-widgets in a grid with variable sized cells.
Definition grid_widget.hpp:40
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:44
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget.hpp:198
widget(gui_window &window, widget *parent) noexcept
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
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.
void set_resize_border_priority(bool left, bool right, bool bottom, bool top) noexcept
Defining on which edges the resize handle has priority over widget at a higher layer.
color background_color() noexcept
The background color of the window.