diff options
Diffstat (limited to 'src/client/window/basic_window.hh')
| -rw-r--r-- | src/client/window/basic_window.hh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/client/window/basic_window.hh b/src/client/window/basic_window.hh new file mode 100644 index 0000000..292cc64 --- /dev/null +++ b/src/client/window/basic_window.hh @@ -0,0 +1,52 @@ +#ifndef CLIENT_WINDOW_BASIC_WINDOW_HH_ +#define CLIENT_WINDOW_BASIC_WINDOW_HH_ + +#include <glm/glm.hpp> + +#include "client/entity/player.hh" +#include "client/render/render.hh" +#include "client/render/struct.hh" + +namespace client { +namespace window { + +// All window objects should derive from basic_window, and make use of multiple +// inheritance for specific behaviours. +class basic_window { +protected: + // Colours borrowed from arc-dark(er). + static constexpr glm::vec3 primary_clr{0.21f, 0.23f, 0.29f}; // dark + static constexpr glm::vec3 secondary_clr{0.29f, 0.32f, 0.38f}; // less dark + static constexpr glm::vec3 tertiary_clr{0.48, 0.50, 0.54}; // less dark ^2 + static constexpr glm::vec3 highlight_clr{0.32, 0.58, 0.88}; // light blue + static constexpr glm::vec3 font_colour{0.88, 0.88, 0.88}; // light grey + +protected: + static constexpr float OUTLINE_WIDTH = 2.0f; + float get_item_size() const noexcept { return this->size.x / 10.0f; } + +protected: + glm::vec2 pos; + glm::vec2 size; + +public: + // Test if a vec2 v is inside a square starting at position p with size s. + static bool is_inside(const glm::vec2& v, const glm::vec2& p, + const glm::vec2& s) noexcept; + // Test if v is inside this->pos, this->size + bool is_inside(const glm::vec2& v) const noexcept; + +public: + basic_window(const client::render::relative_arg& pos, + const client::render::relative_arg& size) noexcept + : pos(pos.to_vec2()), size(size.to_vec2()) {} + virtual ~basic_window() noexcept {} + + virtual bool maybe_handle_event(const SDL_Event&) noexcept { return false; } + virtual void draw() noexcept; +}; + +} // namespace window +} // namespace client + +#endif |
