-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5de0b52
commit ac874ca
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (C) 2023 Albin Johansson (GNU General Public License v3.0) | ||
|
||
#pragma once | ||
|
||
#include "tactile/core/api.hpp" | ||
#include "tactile/core/container/smart_ptr.hpp" | ||
#include "tactile/core/context/meta_context.hpp" | ||
#include "tactile/core/functional/maybe.hpp" | ||
#include "tactile/core/prelude.hpp" | ||
|
||
namespace tactile { | ||
|
||
TACTILE_FWD(class ILayerVisitor) | ||
|
||
/** | ||
* \interface ILayer | ||
* \brief The common interface for all layer variants. | ||
*/ | ||
class TACTILE_CORE_API ILayer : public IMetaContext { | ||
public: | ||
TACTILE_INTERFACE_CLASS(ILayer); | ||
|
||
/** | ||
* \brief Inspects the layer using the given visitor. | ||
* | ||
* \param visitor the visitor to use. | ||
*/ | ||
virtual void accept(ILayerVisitor& visitor) = 0; | ||
|
||
/** | ||
* \brief Sets the associated identifier used in save files. | ||
* | ||
* \param id the new persistent identifier, if any. | ||
*/ | ||
virtual void set_persistent_id(Maybe<int32> id) = 0; | ||
|
||
/** | ||
* \brief Sets the opacity of the layer content. | ||
* | ||
* \param opacity the opacity value, will be clamped to [0, 1]. | ||
*/ | ||
virtual void set_opacity(float opacity) = 0; | ||
|
||
/** | ||
* \brief Sets the visibility of the layer content. | ||
* | ||
* \param visible true if the layer content should be rendered; false otherwise. | ||
*/ | ||
virtual void set_visible(bool visible) = 0; | ||
|
||
/** | ||
* \brief Returns the associated persistent identifier, if any. | ||
* | ||
* \return a layer identifier. | ||
*/ | ||
[[nodiscard]] | ||
virtual auto get_persistent_id() const -> Maybe<int32> = 0; | ||
|
||
/** | ||
* \brief Returns the layer content opacity. | ||
* | ||
* \return an opacity value in the interval [0, 1]. | ||
*/ | ||
[[nodiscard]] | ||
virtual auto get_opacity() const -> float = 0; | ||
|
||
/** | ||
* \brief Indicates whether the layer content is rendered. | ||
* | ||
* \return true if the content is visible; false otherwise. | ||
*/ | ||
[[nodiscard]] | ||
virtual auto is_visible() const -> bool = 0; | ||
|
||
/** | ||
* \brief Creates a clone of the layer. | ||
* | ||
* \note The layer clone may not be identical to the source layer, the only guarantee | ||
* is that the layer clone is logically equivalent. | ||
* | ||
* \return the new layer. | ||
*/ | ||
[[nodiscard]] | ||
virtual auto clone() const -> Shared<ILayer> = 0; | ||
}; | ||
|
||
} // namespace tactile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (C) 2023 Albin Johansson (GNU General Public License v3.0) | ||
|
||
#pragma once | ||
|
||
#include "tactile/core/api.hpp" | ||
#include "tactile/core/prelude.hpp" | ||
|
||
namespace tactile { | ||
|
||
TACTILE_FWD(class TileLayer) | ||
TACTILE_FWD(class ObjectLayer) | ||
TACTILE_FWD(class GroupLayer) | ||
|
||
/** | ||
* \brief Visitor type used to inspect non-const layers. | ||
*/ | ||
class TACTILE_CORE_API ILayerVisitor { | ||
public: | ||
TACTILE_INTERFACE_CLASS(ILayerVisitor); | ||
|
||
/** | ||
* \brief Visits a tile layer. | ||
* | ||
* \param layer the visited layer. | ||
*/ | ||
virtual void visit([[maybe_unused]] TileLayer& layer) | ||
{} | ||
|
||
/** | ||
* \brief Visits an object layer. | ||
* | ||
* \param layer the visited layer. | ||
*/ | ||
virtual void visit([[maybe_unused]] ObjectLayer& layer) | ||
{} | ||
|
||
/** | ||
* \brief Visits a group layer. | ||
* | ||
* \param layer the visited layer. | ||
*/ | ||
virtual void visit([[maybe_unused]] GroupLayer& layer) | ||
{} | ||
}; | ||
|
||
} // namespace tactile |