89 lines
1.9 KiB
C++
89 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
#include "graphic_context.hpp"
|
|
#include "uui/opengl/font_manager.hpp"
|
|
|
|
namespace uui
|
|
{
|
|
class GlWindow;
|
|
class GlApplication
|
|
{
|
|
friend class GlWindow;
|
|
|
|
public:
|
|
#ifdef DEBUG
|
|
constexpr static bool debug_mode = true;
|
|
#else
|
|
constexpr static bool debug_mode = false;
|
|
#endif
|
|
std::vector<std::shared_ptr<GlWindow>> windows;
|
|
|
|
GlApplication();
|
|
~GlApplication();
|
|
|
|
void run();
|
|
std::shared_ptr<GlWindow> create_window(int width, int height, const std::string& title);
|
|
std::shared_ptr<GlWindow> get_window(size_t index) const;
|
|
|
|
private:
|
|
static GlApplication* application_pointer;
|
|
};
|
|
|
|
class GlLabel;
|
|
class GlComponent;
|
|
class GlWindow
|
|
{
|
|
friend class GlApplication;
|
|
friend class GlComponent;
|
|
friend class GlLabel;
|
|
|
|
public:
|
|
std::string title;
|
|
std::vector<std::shared_ptr<GlComponent>> components;
|
|
|
|
GlWindow(const GlWindow&) = delete;
|
|
GlWindow(GlWindow&&) = delete;
|
|
~GlWindow();
|
|
|
|
std::shared_ptr<GlComponent> create_component(
|
|
const std::variant<int, float> x, const std::variant<int, float> y, const std::variant<int, float> width,
|
|
const std::variant<int, float> height);
|
|
std::shared_ptr<GlLabel> create_label(
|
|
const std::variant<int, float> x, const std::variant<int, float> y, const std::string& text,
|
|
const std::tuple<float, float, float, float>& text_color);
|
|
|
|
protected:
|
|
GlApplication* app;
|
|
|
|
GlFontManager font_manager;
|
|
|
|
int width;
|
|
int height;
|
|
bool need_resize_refresh;
|
|
|
|
bool iconified;
|
|
|
|
size_t index;
|
|
bool initialized;
|
|
|
|
GLFWwindow* glfw_window;
|
|
|
|
GLuint gl_program;
|
|
|
|
GlWindow(GlApplication* app, size_t index, int width, int height, const std::string& title);
|
|
|
|
void init();
|
|
void deinit();
|
|
void draw();
|
|
|
|
static void glfw_resize_callback(GLFWwindow* window, int width, int height);
|
|
static void glfw_iconify_callback(GLFWwindow* window, int iconified);
|
|
static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
|
};
|
|
|
|
} // namespace uui
|