2025-10-11 01:29:33 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-02-08 12:09:02 +01:00
|
|
|
#include "ILog.hpp"
|
|
|
|
|
#include "RenderImageManager.hpp"
|
|
|
|
|
#include "resource.hpp"
|
2026-01-23 23:00:35 +00:00
|
|
|
|
2025-10-11 01:29:33 +02:00
|
|
|
namespace pixelarium::application
|
|
|
|
|
{
|
|
|
|
|
|
2025-10-12 21:47:17 +02:00
|
|
|
/// @brief Defines a concept for a gallery type
|
|
|
|
|
/// @tparam P The resource pool type of the gallery concept
|
2026-01-23 23:00:35 +00:00
|
|
|
template <typename P, class D>
|
|
|
|
|
concept GalleryT = requires(P& p) { static_cast<resources::IResourcePool<P, D>&>(p); };
|
2025-10-12 21:47:17 +02:00
|
|
|
|
|
|
|
|
/// @brief Interface for a Pixelarium gallery.
|
|
|
|
|
///
|
|
|
|
|
/// Defines generic functionality for a gallery of a specific
|
|
|
|
|
/// resource type given by the template argument.
|
|
|
|
|
/// @tparam GalleryT The type of IResourcePool that the given implementation
|
|
|
|
|
/// provides a gallery for.
|
2025-10-11 01:29:33 +02:00
|
|
|
template <typename GalleryT>
|
|
|
|
|
class IPixelariumGallery
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~IPixelariumGallery() = default;
|
|
|
|
|
virtual void RenderGallery() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-12 21:47:17 +02:00
|
|
|
/// @brief Implements IPixelariumGallery for a ImageResourcePool
|
2025-10-11 01:29:33 +02:00
|
|
|
class PixelariumImageGallery : IPixelariumGallery<resources::ImageResourcePool>
|
|
|
|
|
{
|
|
|
|
|
using Pool = resources::ImageResourcePool;
|
|
|
|
|
using Log = utils::log::ILog;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
PixelariumImageGallery(const Log& log, resources::ImageResourcePool& pool)
|
2026-01-23 23:00:35 +00:00
|
|
|
: pool_{pool}, log_{log}, render_manager_(std::make_unique<application::RenderImageManager>(pool, log))
|
2025-10-11 01:29:33 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderGallery() override;
|
|
|
|
|
|
|
|
|
|
void RenderImages();
|
|
|
|
|
|
|
|
|
|
void Add(resources::ResourceKey key) { this->render_manager_->Add(key); }
|
|
|
|
|
|
|
|
|
|
void SetLoadFunction(const std::function<void()>& fun) { this->load_image_ = fun; };
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::function<void()> load_image_{};
|
|
|
|
|
Pool& pool_;
|
|
|
|
|
const Log& log_;
|
2026-01-23 23:00:35 +00:00
|
|
|
std::unique_ptr<application::RenderImageManager> render_manager_;
|
2025-10-11 01:29:33 +02:00
|
|
|
bool image_listp_{true};
|
|
|
|
|
bool auto_show_selectd_image_{true};
|
|
|
|
|
size_t selected_image_{0};
|
|
|
|
|
};
|
|
|
|
|
} // namespace pixelarium::application
|