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;
59 bool handle_event(gui_event const& event) noexcept override;
61private:
62 decltype(title)::token_type _title_cbt;
63
64 std::weak_ptr<delegate_type> _content_delegate;
65
66 aarectangle _content_rectangle;
67 widget_constraints _content_constraints;
68 std::unique_ptr<grid_widget> _content;
69
70 aarectangle _toolbar_rectangle;
71 widget_constraints _toolbar_constraints;
72 std::unique_ptr<toolbar_widget> _toolbar;
73#if HI_OPERATING_SYSTEM == HI_OS_WINDOWS
74 system_menu_widget *_system_menu = nullptr;
75#endif
76
77 bool _left_resize_border_has_priority = true;
78 bool _right_resize_border_has_priority = true;
79 bool _bottom_resize_border_has_priority = true;
80 bool _top_resize_border_has_priority = true;
81
82 void constructor_implementation() noexcept;
83};
84
85} // namespace hi::inline v1
STL namespace.
This is a RGBA floating point color.
Definition color.hpp:39
A return value for a generator-function.
Definition generator.hpp:28
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:52
A user interface event.
Definition gui_event.hpp:58
Definition gui_window.hpp:39
Definition hitbox.hpp:16
An observable value.
Definition observable.hpp:359
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:39
Definition widget_constraints.hpp:13
Definition widget_layout.hpp:18
Definition window_widget.hpp:17
color background_color() noexcept
The background color of the window.
T move(T... args)