From 1972939ebde39a3e90a50b021b2322d028f344de Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 20 Mar 2022 20:37:43 +0100 Subject: refactor: move updating status from the move cursor command --- src/interfaces/cursor.hpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/interfaces/cursor.hpp') diff --git a/src/interfaces/cursor.hpp b/src/interfaces/cursor.hpp index 77c5096..ec2f60c 100644 --- a/src/interfaces/cursor.hpp +++ b/src/interfaces/cursor.hpp @@ -1,17 +1,30 @@ #pragma once +#include "interfaces/publisher.hpp" +#include "interfaces/subscriber.hpp" + #include "engine/data/vector2.hpp" #include -class ICursorController +enum CursorEvent +{ + POSITION_CHANGE +}; + +class ICursorController : public IPublisher { public: - virtual ~ICursorController() noexcept = default; + using Event = CursorEvent; + using Context = Vector2; + using Subscriber = std::shared_ptr>; + + ~ICursorController() noexcept override = default; virtual void move(const Vector2 &direction, const uint32_t &amount) noexcept = 0; - virtual void move_to(const Vector2 &position) noexcept = 0; + // NOLINTNEXTLINE(google-default-arguments) + virtual void move_to(const Vector2 &position, bool silent = false) noexcept = 0; [[nodiscard]] virtual Vector2 where() const noexcept = 0; @@ -20,4 +33,10 @@ public: static void hide() noexcept; static void show() noexcept; + + void subscribe(const Event &event, + const Subscriber &subscriber) noexcept override = 0; + + void notify_subscribers(const Event &event, + const Context &context) const noexcept override = 0; }; -- cgit v1.2.3-18-g5258