AronaCore/core/application/window_manager.h

39 lines
1.2 KiB
C++

#pragma once
#include "GLFW/glfw3.h"
#include "misc/singleton/singleton.h"
#include <map>
#include "imgui.h"
class plugin_host;
class window_manager : public singleton_t<window_manager> {
public:
window_manager();
void init(singleton_initliazer& initliazer) override;
void release(singleton_release_guard& release_guard) 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:
void update_host_window();
GLFWwindow* main_window_;
std::map<plugin_host*, GLFWwindow*> host_window_map_;
std::map<plugin_host*, ImVec2> host_window_pos_map_;
};
DEFINE_SINGLETON_INSTANCE(window_manager)