light/modules/window/public/window.hpp

99 lines
1.6 KiB
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#pragma once
#include <math/vec2.hpp>
2025-07-05 13:28:41 +03:30
2025-07-11 00:05:48 +03:30
namespace lt {
2025-07-05 13:28:41 +03:30
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);
2025-07-05 13:28:41 +03:30
2025-07-11 01:42:56 +03:30
Window() = default;
2025-07-05 13:28:41 +03:30
virtual ~Window();
Window(Window &&) = delete;
2025-07-05 13:28:41 +03:30
Window(const Window &) = delete;
2025-07-05 16:07:51 +03:30
auto operator=(Window &&) -> Window & = delete;
2025-07-05 13:28:41 +03:30
auto operator=(const Window &) -> Window & = delete;
2025-07-05 13:28:41 +03:30
virtual void poll_events() = 0;
2025-07-05 16:07:51 +03:30
virtual void on_event(const Event &event) = 0;
2025-07-05 13:28:41 +03:30
virtual void set_properties(const Properties &properties, bool affectVisibility = false) = 0;
2025-07-05 13:28:41 +03:30
virtual void set_title(const std::string &title) = 0;
2025-07-05 13:28:41 +03:30
virtual void set_size(const math::uvec2 &size) = 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
virtual void set_v_sync(bool vsync, bool toggle = false) = 0;
2025-07-05 16:07:51 +03:30
virtual void set_visibility(bool visible, bool toggle = false) = 0;
2025-07-05 13:28:41 +03:30
[[nodiscard]] auto get_properties() const -> const Properties &
2025-07-05 13:28:41 +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
{
return m_properties.title;
2025-07-05 13:28:41 +03:30
}
[[nodiscard]] auto get_size() const -> const math::uvec2 &
2025-07-05 13:28:41 +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
{
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
{
return m_properties.visible;
2025-07-05 13:28:41 +03:30
}
virtual auto get_handle() -> void * = 0;
2025-07-05 16:07:51 +03:30
protected:
auto get_properties_handle() -> Properties &
{
return m_properties;
}
private:
Properties m_properties {};
2025-07-05 16:07:51 +03:30
2025-07-11 01:42:56 +03:30
bool b_Closed {};
2025-07-05 13:28:41 +03:30
};
2025-07-11 00:05:48 +03:30
} // namespace lt