diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
| commit | e4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch) | |
| tree | ed58c3c246e3af1af337697695d780aa31f6ad9a /src/client/window/button_window.hh | |
| parent | 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff) | |
Update to most recent version (old initial commit)
Diffstat (limited to 'src/client/window/button_window.hh')
| -rw-r--r-- | src/client/window/button_window.hh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/client/window/button_window.hh b/src/client/window/button_window.hh new file mode 100644 index 0000000..6847696 --- /dev/null +++ b/src/client/window/button_window.hh @@ -0,0 +1,40 @@ +#ifndef CLIENT_WINDOW_BUTTON_WINDOW_HH_ +#define CLIENT_WINDOW_BUTTON_WINDOW_HH_ + +#include <functional> +#include <string> + +#include "client/input.hh" +#include "client/render/render.hh" +#include "client/window/basic_window.hh" + +namespace client { +namespace window { + +class button_window : public basic_window { +protected: + std::string name; + std::function<void()> callback; + bool is_pressed; + +private: + void handle_mousebuttondown(const SDL_Event& event) noexcept; + void handle_mousebuttonup(const SDL_Event& event) noexcept; + const glm::vec3& get_draw_colour() noexcept; + +public: + template <typename... Args> + button_window(const std::string_view n, const decltype(callback)& c, + Args&&... args) noexcept + : basic_window(std::forward<Args>(args)...), name(n), callback(c), + is_pressed(false) {} + virtual ~button_window() noexcept {} + + virtual bool maybe_handle_event(const SDL_Event& event) noexcept override; + virtual void draw() noexcept override; +}; + +} // namespace window +} // namespace client + +#endif |
