2025-07-05 13:28:41 +03:30
|
|
|
#pragma once
|
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
#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:
|
2025-07-15 15:11:49 +03:30
|
|
|
struct Properties
|
|
|
|
{
|
|
|
|
std::string title;
|
|
|
|
|
2025-07-17 10:44:00 +03:30
|
|
|
math::uvec2 size;
|
2025-07-15 15:11:49 +03:30
|
|
|
|
|
|
|
bool vsync, visible;
|
|
|
|
};
|
|
|
|
|
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-11 01:42:56 +03:30
|
|
|
Window() = default;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-15 15:11:49 +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
|
|
|
|
2025-07-15 15:11:49 +03:30
|
|
|
auto operator=(Window &&) -> Window & = delete;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-15 15:11:49 +03:30
|
|
|
auto operator=(const Window &) -> Window & = delete;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
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-15 15:11:49 +03:30
|
|
|
virtual void set_properties(const Properties &properties, bool affectVisibility = false) = 0;
|
2025-07-05 13:28:41 +03:30
|
|
|
|
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-17 10:44:00 +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
|
|
|
|
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-15 15:11:49 +03:30
|
|
|
[[nodiscard]] auto get_properties() const -> const Properties &
|
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-17 10:44:00 +03:30
|
|
|
[[nodiscard]] auto get_size() const -> const math::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-15 15:11:49 +03:30
|
|
|
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
|