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 tt {
12
13class toolbar_widget;
14class system_menu_widget;
15class grid_widget;
16class grid_delegate;
17
18class window_widget final : public widget {
19public:
20 using super = widget;
22
24
25 template<typename Title>
26 window_widget(gui_window &window, Title &&title, std::weak_ptr<delegate_type> delegate = {}) noexcept :
27 super(window, nullptr), title(std::forward<Title>(title)), _content_delegate(std::move(delegate))
28 {
29 }
34 [[nodiscard]] color background_color() noexcept;
35
40 [[nodiscard]] grid_widget &content() noexcept;
41
46 [[nodiscard]] toolbar_widget &toolbar() noexcept;
47
50 void set_resize_border_priority(bool left, bool right, bool bottom, bool top) noexcept;
51
53 void init() noexcept override;
54 [[nodiscard]] bool constrain(utc_nanoseconds display_time_point, bool need_reconstrain) noexcept override;
55 [[nodiscard]] void layout(utc_nanoseconds display_time_point, bool need_layout) noexcept;
56 [[nodiscard]] hitbox hitbox_test(point2 position) const noexcept override;
58private:
59 decltype(title)::callback_ptr_type _title_callback;
60
61 std::weak_ptr<delegate_type> _content_delegate;
62 grid_widget *_content = nullptr;
63 toolbar_widget *_toolbar = nullptr;
64#if TT_OPERATING_SYSTEM == TT_OS_WINDOWS
65 system_menu_widget *_system_menu = nullptr;
66#endif
67
68 bool _left_resize_border_has_priority = true;
69 bool _right_resize_border_has_priority = true;
70 bool _bottom_resize_border_has_priority = true;
71 bool _top_resize_border_has_priority = true;
72};
73
74} // namespace tt
STL namespace.
This is a RGBA floating point color.
Definition color.hpp:36
Definition gui_window.hpp:39
Definition hitbox.hpp:14
A value which can be observed for modifications.
Definition observable.hpp:464
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:37
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:41
widget(gui_window &window, widget *parent) noexcept
Definition window_widget.hpp:18
color background_color() noexcept
The background color of the window.
grid_widget & content() noexcept
Get a reference to the window's content 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.
toolbar_widget & toolbar() noexcept
Get a reference to window's toolbar widget.
T move(T... args)