HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
window_widget.hpp
1// Copyright Take Vos 2020-2021.
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#pragma once
6
7#include "widget.hpp"
8#include "../label.hpp"
9#include "../weak_or_unique_ptr.hpp"
10
11namespace hi::inline v1 {
12class toolbar_widget;
13class system_menu_widget;
14class grid_widget;
15class grid_delegate;
16
17class window_widget final : public widget {
18public:
19 using super = widget;
21
23
24 template<typename Title>
25 window_widget(gui_window &window, Title &&title, std::weak_ptr<delegate_type> delegate = {}) noexcept :
26 super(window, nullptr), title(std::forward<Title>(title)), _content_delegate(std::move(delegate))
27 {
28 constructor_implementation();
29 }
30
35 [[nodiscard]] color background_color() noexcept;
36
41 [[nodiscard]] grid_widget &content() noexcept;
42
47 [[nodiscard]] toolbar_widget &toolbar() noexcept;
48
51 void set_resize_border_priority(bool left, bool right, bool bottom, bool top) noexcept;
52
54 [[nodiscard]] generator<widget *> children() const noexcept override;
55 widget_constraints const &set_constraints() noexcept override;
56 void set_layout(widget_layout const &layout) noexcept;
57 void draw(draw_context const &context) noexcept override;
58 [[nodiscard]] hitbox hitbox_test(point3 position) const noexcept override;
60private:
61 decltype(title)::token_type _title_cbt;
62
63 std::weak_ptr<delegate_type> _content_delegate;
64
65 aarectangle _content_rectangle;
66 std::unique_ptr<grid_widget> _content;
67
68 aarectangle _toolbar_rectangle;
69 std::unique_ptr<toolbar_widget> _toolbar;
70#if HI_OPERATING_SYSTEM == HI_OS_WINDOWS
71 system_menu_widget *_system_menu = nullptr;
72#endif
73
74 bool _left_resize_border_has_priority = true;
75 bool _right_resize_border_has_priority = true;
76 bool _bottom_resize_border_has_priority = true;
77 bool _top_resize_border_has_priority = true;
78
79 void constructor_implementation() noexcept;
80};
81
82} // namespace hi::inline v1
STL namespace.
This is a RGBA floating point color.
Definition color.hpp:37
A return value for a generator-function.
Definition generator.hpp:27
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:51
Definition gui_window.hpp:40
Definition hitbox.hpp:16
An observable value.
Definition observable.hpp:356
Definition grid_delegate.hpp:13
A GUI widget that lays out child-widgets in a grid with variable sized cells.
Definition grid_widget.hpp:37
Definition system_menu_widget.hpp:16
A toolbar widget is located at the top of a window and lays out its children horizontally.
Definition toolbar_widget.hpp:28
An interactive graphical object as part of the user-interface.
Definition widget.hpp:40
Definition widget_constraints.hpp:12
Definition widget_layout.hpp:17
Definition window_widget.hpp:17
color background_color() noexcept
The background color of the window.
T move(T... args)