Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
AnimationShaderRegistry.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include <PhosphorAnimation/phosphoranimation_export.h>
8
9#include <PhosphorRegistry/IFactoryBase.h>
10#include <PhosphorRegistry/MetadataPackLoader.h>
11#include <PhosphorRegistry/Registry.h>
12
14
15#include <QList>
16#include <QObject>
17#include <QString>
18#include <QStringList>
19#include <QVariantMap>
20
21#include <memory>
22
24
79class PHOSPHORANIMATION_EXPORT AnimationShaderRegistry : public QObject
80{
81 Q_OBJECT
82
83public:
90 class AnimationPack final : public PhosphorRegistry::IFactoryBase
91 {
92 public:
94 : m_effect(std::move(effect))
95 {
96 }
97 [[nodiscard]] QString id() const override
98 {
99 return m_effect.id;
100 }
101 [[nodiscard]] QString displayName() const override
102 {
103 return m_effect.name;
104 }
105 [[nodiscard]] const AnimationShaderEffect& effect() const
106 {
107 return m_effect;
108 }
109
110 private:
111 AnimationShaderEffect m_effect;
112 };
113
114 explicit AnimationShaderRegistry(QObject* parent = nullptr);
116
117 // ── Search paths (forwarded to the internal MetadataPackLoader) ───
120 const QStringList& paths, PhosphorFsLoader::LiveReload liveReload = PhosphorFsLoader::LiveReload::On,
122 [[nodiscard]] QStringList searchPaths() const;
123 void setUserPath(const QString& path);
124 void refresh();
125
126 // Lookup -------------------------------------------------------------------
127
128 QList<AnimationShaderEffect> availableEffects() const;
129 AnimationShaderEffect effect(const QString& id) const;
130 bool hasEffect(const QString& id) const;
131 QStringList effectIds() const;
132
171 QVariantMap translateAnimationParams(const QString& effectId, const QVariantMap& friendlyParams) const;
172
177 static QVariantMap translateAnimationParams(const AnimationShaderEffect& effect, const QVariantMap& friendlyParams);
178
190 static QString paramPreamble(const AnimationShaderEffect& effect);
191
198 static QString animationEntryPrologue();
199
209 static QList<PhosphorShaders::EntryCandidate> animationEntryCandidates();
210
211Q_SIGNALS:
213
214private:
215 // Generic id-keyed storage + change-notify for the discovered effect
216 // packs. m_loader (below) populates it from disk; the lookup methods
217 // read it. Declared before m_loader so it is destroyed AFTER the loader:
218 // the loader holds a borrowed Registry pointer (used during live rescans
219 // in reconcile(), not at teardown), which must stay valid for the loader's
220 // whole lifetime.
221 PhosphorRegistry::Registry<AnimationPack> m_registry;
222 // On-disk scan + hot-reload. Parses each pack's metadata.json into an
223 // AnimationPack and reconciles m_registry; its onCommitted hook
224 // re-emits effectsChanged.
225 std::unique_ptr<PhosphorRegistry::MetadataPackLoader<AnimationPack>> m_loader;
226};
227
228} // namespace PhosphorAnimationShaders
Registry entry: a discovered animation effect as a PhosphorRegistry factory.
Definition AnimationShaderRegistry.h:91
QString displayName() const override
Definition AnimationShaderRegistry.h:101
QString id() const override
Definition AnimationShaderRegistry.h:97
AnimationPack(AnimationShaderEffect effect)
Definition AnimationShaderRegistry.h:93
const AnimationShaderEffect & effect() const
Definition AnimationShaderRegistry.h:105
Registry of available animation shader transition effects.
Definition AnimationShaderRegistry.h:80
void addSearchPaths(const QStringList &paths, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On, PhosphorFsLoader::RegistrationOrder order=PhosphorFsLoader::RegistrationOrder::LowestPriorityFirst)
QVariantMap translateAnimationParams(const QString &effectId, const QVariantMap &friendlyParams) const
Translate a friendly parameter map into the canonical slot keys consumed by both runtimes that drive ...
static QList< PhosphorShaders::EntryCandidate > animationEntryCandidates()
The direction-dispatched entry candidates (T1.5), in priority order: • vec4 pTransition(vec2 uv,...
static QString animationEntryPrologue()
The T1.4/T1.5 entry-point prologue for animation shaders: #version, the animation_uniforms....
QList< AnimationShaderEffect > availableEffects() const
void addSearchPath(const QString &path, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On)
static QString paramPreamble(const AnimationShaderEffect &effect)
Build the generated #define p_<id> <glsl-accessor> preamble for effect's declared parameters so autho...
AnimationShaderEffect effect(const QString &id) const
static QVariantMap translateAnimationParams(const AnimationShaderEffect &effect, const QVariantMap &friendlyParams)
Static counterpart for callers that already hold the resolved AnimationShaderEffect (e....
Definition AnimationShaderContract.h:10
RegistrationOrder
Caller's declared priority direction for registerDirectories / setDirectories input.
Definition WatchedDirectorySet.h:58
@ LowestPriorityFirst
[sys-lowest, ..., sys-highest, user] — the canonical strategy view.
LiveReload
Opt-in policy for directory watching.
Definition WatchedDirectorySet.h:34
Metadata for a single animation shader effect (transition).
Definition AnimationShaderEffect.h:45