AronaCore/core/application/window_manager.h
2024-02-28 11:20:18 +08:00

42 lines
1.3 KiB
C++

#pragma once
#include "GLFW/glfw3.h"
#include "misc/singleton/singleton.h"
#include <map>
class plugin_host;
class window_manager : public singleton_t<window_manager> {
public:
window_manager();
void init(singleton_initliazer& initliazer) override;
void release() override;
void tick();
bool should_close() const { return glfwWindowShouldClose(main_window_); }
void destroy_all_plugin_host_window();
GLFWwindow* create_main_window(const char* title, int width, int height);
void request_exit() const { glfwSetWindowShouldClose(main_window_, GLFW_TRUE); }
GLFWwindow* get_main_window() const { return main_window_; }
GLFWwindow* create_plugin_host_window(plugin_host* host);
void destroy_plugin_host_window(plugin_host* host);
void resize_plugin_host_window(plugin_host* host, int width, int height);
void idle_plugin_host_window() const;
const char* get_name() override { return "window_manager"; }
private:
#pragma region idle_thread
void start_idle_thread();
void stop_idle_thread();
void idle_thread_func();
std::thread idle_thread_;
std::atomic_bool idle_thread_running_;
#pragma endregion
GLFWwindow* main_window_;
std::map<plugin_host*, GLFWwindow*> host_window_map_;
};
DEFINE_SINGLETON_INSTANCE(window_manager)