light/modules/window/public/window.hpp
2025-07-25 15:07:13 +03:30

98 lines
1.6 KiB
C++

#pragma once
#include <math/vec2.hpp>
namespace lt {
class Event;
class Window
{
public:
struct Properties
{
std::string title;
math::uvec2 size;
bool vsync, visible;
};
static Scope<Window> create(const std::function<void(Event &)> &callback);
Window() = default;
virtual ~Window();
Window(Window &&) = delete;
Window(const Window &) = delete;
auto operator=(Window &&) -> Window & = delete;
auto operator=(const Window &) -> Window & = delete;
virtual void poll_events() = 0;
virtual void on_event(const Event &event) = 0;
virtual void set_properties(const Properties &properties, bool affectVisibility = false) = 0;
virtual void set_title(const std::string &title) = 0;
virtual void set_size(const math::uvec2 &size) = 0;
void close()
{
b_Closed = true;
}
virtual void set_v_sync(bool vsync, bool toggle = false) = 0;
virtual void set_visibility(bool visible, bool toggle = false) = 0;
[[nodiscard]] auto get_properties() const -> const Properties &
{
return m_properties;
}
[[nodiscard]] auto get_title() const -> const std::string &
{
return m_properties.title;
}
[[nodiscard]] auto get_size() const -> const math::uvec2 &
{
return m_properties.size;
}
[[nodiscard]] auto is_closed() const -> bool
{
return b_Closed;
}
[[nodiscard]] auto is_v_sync() const -> bool
{
return m_properties.vsync;
}
[[nodiscard]] auto is_visible() const -> bool
{
return m_properties.visible;
}
virtual auto get_handle() -> void * = 0;
protected:
auto get_properties_handle() -> Properties &
{
return m_properties;
}
private:
Properties m_properties {};
bool b_Closed {};
};
} // namespace lt