7#include "gui_window.hpp"
8#include "gui_window_win32.hpp"
9#include "gui_system_delegate.hpp"
10#include "../GFX/gfx_system.hpp"
11#include "../GFX/gfx_device.hpp"
12#include "../thread.hpp"
13#include "../unfair_recursive_mutex.hpp"
26 static inline os_handle instance;
28 thread_id
const thread_id;
30 gui_system() noexcept : thread_id(current_thread_id()), _delegate() {}
42 virtual void init() noexcept
44 if (
auto delegate = _delegate.lock()) {
45 delegate->init(*
this);
49 virtual void deinit() noexcept
51 if (
auto delegate = _delegate.lock()) {
52 delegate->deinit(*
this);
61 virtual void run_from_event_queue(
std::function<
void()> function) = 0;
77 virtual void exit(
int exit_code) = 0;
86 template<
typename... Args>
92 auto window = std::make_unique<gui_window_win32>(std::forward<Args>(args)...);
106 for (
auto &window : _windows) {
107 window->render(display_time_point);
108 if (window->is_closed()) {
113 std::erase(_windows,
nullptr);
120 if (
auto delegate = _delegate.lock()) {
121 if (
auto exit_code = delegate->last_window_closed(*
this)) {
135 return thread_id == current_thread_id();
146 return *start_subsystem_or_terminate(_global,
nullptr, subsystem_init, subsystem_deinit);
155 size_t _previous_num_windows;
157 [[nodiscard]]
static gui_system *subsystem_init() noexcept;
158 static
void subsystem_deinit() noexcept;
Graphics system.
Definition gui_system.hpp:24
virtual void init() noexcept
Initialize after construction.
Definition gui_system.hpp:42
gui_window & make_window(Args &&...args)
Create a new window.
Definition gui_system.hpp:87
bool is_gui_thread() const noexcept
Check if this thread is the same as the gui thread.
Definition gui_system.hpp:133
static gui_system & global() noexcept
Get a reference to the global gui_system.
Definition gui_system.hpp:144
virtual int loop()=0
Start the GUI event loop.
Definition gui_window.hpp:36