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 "abstract_container_widget.hpp"
8#include "../label.hpp"
9
10namespace tt {
11
12class toolbar_widget;
13class grid_layout_widget;
14
16public:
18
21
22 void init() noexcept override;
23
24 [[nodiscard]] bool
25 update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override;
26 [[nodiscard]] void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept;
27 [[nodiscard]] hit_box hitbox_test(f32x4 window_position) const noexcept override;
28
29 [[nodiscard]] color backgroundColor() noexcept {
30 tt_axiom(gui_system_mutex.recurse_lock_count());
31 return theme::global->fillColor(_semantic_layer);
32 }
33
36 void set_resize_border_priority(bool left, bool right, bool bottom, bool top) noexcept
37 {
38 tt_axiom(gui_system_mutex.recurse_lock_count());
39 left_resize_border_has_priority = left;
40 right_resize_border_has_priority = right;
41 bottom_resize_border_has_priority = bottom;
42 top_resize_border_has_priority = top;
43 }
44
45 [[nodiscard]] std::shared_ptr<grid_layout_widget> content() const noexcept
46 {
47 tt_axiom(gui_system_mutex.recurse_lock_count());
48 tt_axiom(_content);
49 return _content;
50 }
51
52 [[nodiscard]] std::shared_ptr<toolbar_widget> toolbar() const noexcept
53 {
54 tt_axiom(gui_system_mutex.recurse_lock_count());
55 tt_axiom(_toolbar);
56 return _toolbar;
57 }
58
59 [[nodiscard]] bool is_toolbar() const noexcept override
60 {
61 return false;
62 }
63
64private:
65 label title;
69
70 bool left_resize_border_has_priority = true;
71 bool right_resize_border_has_priority = true;
72 bool bottom_resize_border_has_priority = true;
73 bool top_resize_border_has_priority = true;
74};
75
76} // namespace tt
This is a RGBA floating point color.
Definition color.hpp:39
Definition gui_window.hpp:39
Definition hit_box.hpp:15
Timestamp.
Definition hires_utc_clock.hpp:16
A localized text + icon label.
Definition label.hpp:76
int recurse_lock_count() const noexcept
This function should be used in tt_axiom() to check if the lock is held by current thread.
Definition unfair_recursive_mutex.hpp:60
Definition abstract_container_widget.hpp:11
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:100
Definition window_widget.hpp:15
void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept
Update the internal layout of the widget.
void init() noexcept override
Should be called right after allocating and constructing a 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.
Definition window_widget.hpp:36
bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override
Update the constraints of the widget.
hit_box hitbox_test(f32x4 window_position) const noexcept override
Find the widget that is under the mouse cursor.