7#include "gui_window.hpp"
8#include "gui_window_win32.hpp"
9#include "gui_system_delegate.hpp"
10#include "../GFX/gfx_device.hpp"
11#include "../thread.hpp"
12#include "../unfair_recursive_mutex.hpp"
13#include "../event_queue.hpp"
25class keyboard_bindings;
31 static inline os_handle instance;
40 thread_id
const thread_id;
62 virtual void init() noexcept
64 if (
auto delegate = _delegate.lock()) {
65 delegate->init(*
this);
69 virtual void deinit() noexcept
71 if (
auto delegate = _delegate.lock()) {
72 delegate->deinit(*
this);
95 virtual void exit(
int exit_code) = 0;
104 return *_event_queue;
116 void run(std::invocable
auto &&function)
noexcept
132 template<
typename... Args>
138 auto window = std::make_unique<gui_window_win32>(*
this, std::forward<Args>(args)...);
148 void render(utc_nanoseconds display_time_point)
152 for (
auto &window : _windows) {
153 window->render(display_time_point);
154 if (window->is_closed()) {
159 std::erase(_windows,
nullptr);
166 if (
auto delegate = _delegate.lock()) {
167 if (
auto exit_code = delegate->last_window_closed(*
this)) {
168 this->exit(*exit_code);
181 return thread_id == current_thread_id();
196 void set_theme_mode(tt::theme_mode mode) noexcept;
223 size_t _previous_num_windows = 0;
Definition event_queue.hpp:40
Graphics system.
Definition gfx_system.hpp:21
Graphics system.
Definition gui_system.hpp:29
virtual void init() noexcept
Initialize after construction.
Definition gui_system.hpp:62
void set_theme(tt::theme const &new_theme) noexcept
Set the theme for the system.
void run(std::invocable auto &&function) noexcept
Run the function now or on from the GUI's event loop.
Definition gui_system.hpp:116
static std::unique_ptr< gui_system > make_unique(std::weak_ptr< gui_system_delegate > delegate={}) noexcept
Make a gui_system instance.
void run_from_event_queue(std::invocable auto &&function) noexcept
Run the function from the GUI's event queue.
Definition gui_system.hpp:109
tt::theme const & theme() const noexcept
Get the theme.
gui_window & make_window(Args &&...args)
Create a new window.
Definition gui_system.hpp:133
tt::event_queue const & event_queue() const noexcept
Get the event queue.
Definition gui_system.hpp:102
bool is_gui_thread() const noexcept
Check if this thread is the same as the gui thread.
Definition gui_system.hpp:179
void request_constrain() noexcept
Request all windows to constrain.
virtual int loop()=0
Start the GUI event loop.
Definition gui_system_delegate.hpp:11
Definition gui_window.hpp:39
Definition keyboard_bindings.hpp:17
theme_book keeps track of multiple themes.
Definition theme_book.hpp:19
Definition vertical_sync.hpp:13
font_book keeps track of multiple fonts.
Definition font_book.hpp:30