diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/component.hpp | 25 | ||||
-rw-r--r-- | src/interfaces/component_renderer.hpp | 24 | ||||
-rw-r--r-- | src/interfaces/matrix.hpp | 4 | ||||
-rw-r--r-- | src/interfaces/scene.hpp | 11 | ||||
-rw-r--r-- | src/interfaces/status_manager.hpp | 3 | ||||
-rw-r--r-- | src/interfaces/statusline.hpp | 23 |
6 files changed, 76 insertions, 14 deletions
diff --git a/src/interfaces/component.hpp b/src/interfaces/component.hpp new file mode 100644 index 0000000..7e1b132 --- /dev/null +++ b/src/interfaces/component.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "interfaces/matrix.hpp" + +#include <memory> + +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) +class IComponent +{ +public: + using ComponentMatrix = IMatrix<char>; + + virtual ~IComponent() = default; + + [[nodiscard]] virtual auto get() const noexcept + -> const std::shared_ptr<ComponentMatrix> & = 0; + + [[nodiscard]] virtual auto get_need_render() const noexcept -> bool = 0; + + virtual void set_need_render(bool need_render) noexcept = 0; + + [[nodiscard]] virtual auto get_foreground_color() const noexcept -> uint32_t = 0; + + [[nodiscard]] virtual auto get_background_color() const noexcept -> uint32_t = 0; +}; diff --git a/src/interfaces/component_renderer.hpp b/src/interfaces/component_renderer.hpp new file mode 100644 index 0000000..fa8bc18 --- /dev/null +++ b/src/interfaces/component_renderer.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "interfaces/component.hpp" +#include "interfaces/cursor.hpp" + +#include "engine/data/vector2.hpp" + +#include <yacppdic/factory.hpp> + +#include <memory> + +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) +class IComponentRenderer +{ +public: + virtual ~IComponentRenderer() = default; + + virtual void render( + const std::shared_ptr<IComponent> &component, + const Vector2 &position) noexcept = 0; +}; + +using IComponentRendererFactory = yacppdic::Factory<std::unique_ptr<IComponentRenderer>( + const std::shared_ptr<ICursorController> &)>; diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp index 010138f..3ab102c 100644 --- a/src/interfaces/matrix.hpp +++ b/src/interfaces/matrix.hpp @@ -8,11 +8,13 @@ #include <memory> -template <typename Element> +template <typename ElementType> // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class IMatrix { public: + using Element = ElementType; + virtual ~IMatrix() noexcept = default; virtual void fill(Element element) noexcept = 0; diff --git a/src/interfaces/scene.hpp b/src/interfaces/scene.hpp index 903a299..daabb10 100644 --- a/src/interfaces/scene.hpp +++ b/src/interfaces/scene.hpp @@ -1,14 +1,18 @@ #pragma once +#include "interfaces/component.hpp" #include "interfaces/cursor.hpp" #include "interfaces/matrix.hpp" #include "engine/data/bounds.hpp" +#include "engine/data/vector2.hpp" #include <yacppdic/factory.hpp> #include <memory> #include <string_view> +#include <utility> +#include <vector> // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class IScene @@ -26,6 +30,13 @@ public: [[nodiscard]] virtual auto get_matrix() const noexcept -> const std::shared_ptr<IMatrix<MatrixElement>> & = 0; + + virtual void register_component( + const std::shared_ptr<IComponent> &component, + const Vector2 &position) noexcept = 0; + + [[nodiscard]] virtual auto get_components() const noexcept + -> std::vector<std::pair<std::shared_ptr<IComponent>, Vector2>> = 0; }; using ISceneFactory = yacppdic::Factory<std::unique_ptr<IScene>( diff --git a/src/interfaces/status_manager.hpp b/src/interfaces/status_manager.hpp index 18d6928..9c7234e 100644 --- a/src/interfaces/status_manager.hpp +++ b/src/interfaces/status_manager.hpp @@ -22,6 +22,9 @@ public: virtual void set_section_body( const StatusLineSection §ion, const std::string_view &body) noexcept = 0; + + [[nodiscard]] virtual auto get_statusline() const noexcept + -> std::shared_ptr<IStatusLine> = 0; }; using IStatusManagerFactory = yacppdic::Factory<std::unique_ptr<IStatusManager>( diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp index a71699e..ae25fd9 100644 --- a/src/interfaces/statusline.hpp +++ b/src/interfaces/statusline.hpp @@ -1,7 +1,8 @@ #pragma once -#include "interfaces/cursor.hpp" -#include "interfaces/scene.hpp" +#include "interfaces/component.hpp" + +#include "engine/data/bounds.hpp" #include <yacppdic/factory.hpp> @@ -20,22 +21,18 @@ enum StatusLineSection }; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -class IStatusLine +class IStatusLine : public IComponent { public: - virtual ~IStatusLine() noexcept = default; - - virtual void initialize_background() noexcept = 0; - + // NOLINTNEXTLINE(google-default-arguments) virtual void set_status( - const StatusLineSection §ion, + StatusLineSection section, const std::string_view &status, - std::size_t start = 1UL) noexcept = 0; + int32_t start = 1) noexcept = 0; virtual void - set_section_length(const StatusLineSection §ion, uint32_t length) noexcept = 0; + set_section_length(StatusLineSection section, int32_t length) noexcept = 0; }; -using IStatusLineFactory = yacppdic::Factory<std::unique_ptr<IStatusLine>( - const std::shared_ptr<ICursorController> &cursor_controller, - const std::shared_ptr<IScene> &scene)>; +using IStatusLineFactory = + yacppdic::Factory<std::unique_ptr<IStatusLine>(const Bounds &size)>; |