2025-07-05 13:28:41 +03:30
|
|
|
#pragma once
|
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
#include <glm/glm.hpp>
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <renderer/graphics_context.hpp>
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
|
|
|
class Event;
|
|
|
|
|
|
|
|
struct WindowProperties
|
|
|
|
{
|
|
|
|
std::string title;
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
glm::uvec2 size;
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
bool vsync, visible;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Window
|
|
|
|
{
|
|
|
|
public:
|
2025-07-10 13:29:03 +03:30
|
|
|
static Scope<Window> create(const std::function<void(Event &)> &callback);
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
Window(): m_properties {}
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Window(const Window &) = delete;
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
Window &operator=(const Window &) = delete;
|
|
|
|
|
|
|
|
virtual ~Window() = default;
|
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
virtual void poll_events() = 0;
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
virtual void on_event(const Event &event) = 0;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
virtual void set_properties(
|
2025-07-05 13:28:41 +03:30
|
|
|
const WindowProperties &properties,
|
|
|
|
bool affectVisibility = false
|
|
|
|
) = 0;
|
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
virtual void set_title(const std::string &title) = 0;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-06 14:02:50 +03:30
|
|
|
/** pass 0 for width or height for single dimension resizing */
|
|
|
|
virtual void set_size(const glm::uvec2 &size, bool additive = false) = 0;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-06 14:02:50 +03:30
|
|
|
void close()
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
|
|
|
b_Closed = true;
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
virtual void set_v_sync(bool vsync, bool toggle = false) = 0;
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
virtual void set_visibility(bool visible, bool toggle = false) = 0;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_properties() const -> const WindowProperties &
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_properties;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_title() const -> const std::string &
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_properties.title;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto get_size() const -> const glm::uvec2 &
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_properties.size;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto is_closed() const -> bool
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
|
|
|
return b_Closed;
|
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto is_v_sync() const -> bool
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_properties.vsync;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
2025-07-06 14:02:50 +03:30
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
[[nodiscard]] auto is_visible() const -> bool
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 14:23:01 +03:30
|
|
|
return m_properties.visible;
|
2025-07-05 13:28:41 +03:30
|
|
|
}
|
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
virtual auto get_handle() -> void * = 0;
|
2025-07-05 16:07:51 +03:30
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
protected:
|
2025-07-05 16:07:51 +03:30
|
|
|
WindowProperties m_properties;
|
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
bool b_Closed { false };
|
2025-07-05 13:28:41 +03:30
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Light
|