Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PointerShaderRegistry.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 <PhosphorPointer/phosphorpointer_export.h>
8
12
14
15#include <QList>
16#include <QObject>
17#include <QString>
18#include <QStringList>
19#include <QVariantMap>
20
21#include <memory>
22
23namespace PhosphorPointerShaders {
24
37class PHOSPHORPOINTER_EXPORT PointerShaderRegistry : public QObject
38{
39 Q_OBJECT
40
41public:
45 {
46 public:
48 : m_effect(std::move(effect))
49 {
50 }
51 [[nodiscard]] QString id() const override
52 {
53 return m_effect.id;
54 }
55 [[nodiscard]] QString displayName() const override
56 {
57 return m_effect.name;
58 }
59 [[nodiscard]] const PointerShaderEffect& effect() const
60 {
61 return m_effect;
62 }
63
64 private:
65 PointerShaderEffect m_effect;
66 };
67
68 explicit PointerShaderRegistry(QObject* parent = nullptr);
70
71 // ── Search paths (forwarded to the internal MetadataPackLoader) ───
76 const QStringList& paths, PhosphorFsLoader::LiveReload liveReload = PhosphorFsLoader::LiveReload::On,
78 [[nodiscard]] QStringList searchPaths() const;
81 void setUserPath(const QString& path);
84 void refresh();
85
86 // ── Lookup ─────────────────────────────────────────────────────────
87 [[nodiscard]] QList<PointerShaderEffect> availableEffects() const;
88 [[nodiscard]] PointerShaderEffect effect(const QString& id) const;
89 [[nodiscard]] bool hasEffect(const QString& id) const;
90
105 [[nodiscard]] static QVariantMap translatePointerParams(const PointerShaderEffect& effect,
106 const QVariantMap& friendlyParams);
107
110 [[nodiscard]] QVariantMap translatePointerParams(const QString& effectId, const QVariantMap& friendlyParams) const;
111
117 [[nodiscard]] static QString paramPreamble(const PointerShaderEffect& effect);
118
123 [[nodiscard]] static QString pointerEntryPrologue();
124 [[nodiscard]] static QList<PhosphorShaders::EntryCandidate> pointerEntryCandidates();
125
133 [[nodiscard]] static QString compositorVertexSource();
134
150 [[nodiscard]] static QStringList includePathsFor(const QString& packDir, const QString& packDataSubdir);
151
152Q_SIGNALS:
154
155private:
159 [[nodiscard]] const PointerShaderEffect* effectPtr(const QString& id) const;
160
161 // Declared before m_loader so it is destroyed after it: the loader holds
162 // a borrowed Registry pointer for its whole lifetime.
164 std::unique_ptr<PhosphorRegistry::MetadataPackLoader<PointerPack>> m_loader;
165};
166
167} // namespace PhosphorPointerShaders
const PointerShaderEffect & effect() const
Definition PointerShaderRegistry.h:59
QString displayName() const override
Definition PointerShaderRegistry.h:55
PointerPack(PointerShaderEffect effect)
Definition PointerShaderRegistry.h:47
QString id() const override
Definition PointerShaderRegistry.h:51
QList< PointerShaderEffect > availableEffects() const
bool hasEffect(const QString &id) const
static QList< PhosphorShaders::EntryCandidate > pointerEntryCandidates()
static QString pointerEntryPrologue()
Entry-point scaffold: a pack defines vec4 pPointer(vec2 uv) and the harness prepends this prologue (#...
static QVariantMap translatePointerParams(const PointerShaderEffect &effect, const QVariantMap &friendlyParams)
Translate a friendly parameter map into the slot keys both runtimes consume.
void addSearchPath(const QString &path, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On)
Single-path form of addSearchPaths.
PointerShaderRegistry(QObject *parent=nullptr)
PointerShaderEffect effect(const QString &id) const
void setUserPath(const QString &path)
Classify packs found under path as user-owned.
static QString compositorVertexSource()
The vertex stage the COMPOSITOR compiles for every pointer pack's main pass and buffer stages (classi...
void refresh()
Rescan the search paths now.
static QStringList includePathsFor(const QString &packDir, const QString &packDataSubdir)
Include search paths for a pack at packDir: its own neighbourhood {<packRoot>/shared,...
void addSearchPaths(const QStringList &paths, PhosphorFsLoader::LiveReload liveReload=PhosphorFsLoader::LiveReload::On, PhosphorFsLoader::RegistrationOrder order=PhosphorFsLoader::RegistrationOrder::LowestPriorityFirst)
QVariantMap translatePointerParams(const QString &effectId, const QVariantMap &friendlyParams) const
Registry-keyed convenience overload.
static QString paramPreamble(const PointerShaderEffect &effect)
The generated #define p_<id> <glsl-accessor> preamble for effect's declared parameters,...
Definition IFactoryBase.h:27
Definition Registry.h:88
RegistrationOrder
Caller's declared priority direction for registerDirectories / setDirectories input.
Definition WatchedDirectorySet.h:64
@ LowestPriorityFirst
[sys-lowest, ..., sys-highest, user] — the canonical strategy view.
Definition WatchedDirectorySet.h:69
LiveReload
Opt-in policy for directory watching.
Definition WatchedDirectorySet.h:40
@ On
Definition WatchedDirectorySet.h:42
Definition PointerFrameState.h:16
Metadata for a single pointer shader effect.
Definition PointerShaderEffect.h:50