Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PointerShaderEffect.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
6#include <PhosphorPointer/phosphorpointer_export.h>
7
10
11#include <QJsonObject>
12#include <QList>
13#include <QString>
14#include <QStringList>
15#include <QVariant>
16#include <QVariantMap>
17
18namespace PhosphorPointerShaders {
19
49struct PHOSPHORPOINTER_EXPORT PointerShaderEffect
50{
52 enum class Layer {
55 Below,
59 Above,
60 };
61
68 static QString layerToken(Layer layer);
69
71 QString id;
72
74 QString name;
75
77 QString description;
78
80 QString author;
81
83 QString version;
84
86 QString category;
87
92
96
98 QString sourceDir;
99
101 bool isUserEffect = false;
102
104 QString previewPath;
105
108
112 double reach = 64.0;
113
116 QString reachParam;
117
124 double trailSeconds = 1.0;
125
141 bool samplesTrail = true;
142
155 double trailWindowSeconds = 0.0;
156
166
168 bool needsCursor = false;
169
172 bool isMultipass = false;
173
176 QStringList bufferShaderPaths;
177
180 bool bufferFeedback = false;
181
184 double bufferScale = 1.0;
185
188
195 static constexpr double kMinReach = 1.0;
196 static constexpr double kMaxReach = 1024.0;
197
203 {
204 QString id;
205 QString name;
206 QString type;
207 QString description;
208 QString group;
209 QVariant defaultValue;
210 QVariant minValue;
211 QVariant maxValue;
212 QVariant stepValue;
213 };
214 QList<ParameterInfo> parameters;
215
219 {
220 QString path;
221 QString wrap;
222
223 bool operator==(const TextureSlot& other) const
224 {
225 return path == other.path && wrap == other.wrap;
226 }
227 bool operator!=(const TextureSlot& other) const
228 {
229 return !(*this == other);
230 }
231 };
232 QList<TextureSlot> textures;
233
244
250 static PointerShaderEffect fromJson(const QJsonObject& obj, const QString& sourceDir = QString(),
251 bool isUser = false);
252
253 bool isValid() const
254 {
255 return !id.isEmpty() && !fragmentShaderPath.isEmpty();
256 }
257
267 [[nodiscard]] double resolvedTrailWindow(const QVariantMap& params) const;
268
273 [[nodiscard]] double resolvedReach(const QVariantMap& params) const;
274
275private:
281 [[nodiscard]] double resolvedParam(const QString& paramId, const QVariantMap& params, double fallback) const;
282};
283
284} // namespace PhosphorPointerShaders
285
Q_DECLARE_TYPEINFO(PhosphorPointerShaders::PointerShaderEffect::TextureSlot, Q_RELOCATABLE_TYPE)
Definition PointerFrameState.h:16
constexpr double kMaxBufferScale
Definition CustomParamsKey.h:37
constexpr double kMinBufferScale
Lower / upper bounds on a multipass bufferScale (FBO downscale factor).
Definition CustomParamsKey.h:36
QMap< QString, QVariantMap > PackPresets
Pack-declared named parameter presets: preset name → { paramId → value }.
Definition ShaderPresetParse.h:32
Declared parameter.
Definition PointerShaderEffect.h:203
QVariant stepValue
Definition PointerShaderEffect.h:212
QString id
Definition PointerShaderEffect.h:204
QString group
Definition PointerShaderEffect.h:208
QString type
"float", "int", "bool", "color"
Definition PointerShaderEffect.h:206
QString name
Definition PointerShaderEffect.h:205
QString description
Definition PointerShaderEffect.h:207
QVariant maxValue
Definition PointerShaderEffect.h:211
QVariant minValue
Definition PointerShaderEffect.h:210
QVariant defaultValue
Definition PointerShaderEffect.h:209
User texture slot.
Definition PointerShaderEffect.h:219
QString path
Definition PointerShaderEffect.h:220
bool operator!=(const TextureSlot &other) const
Definition PointerShaderEffect.h:227
QString wrap
Definition PointerShaderEffect.h:221
bool operator==(const TextureSlot &other) const
Definition PointerShaderEffect.h:223
Metadata for a single pointer shader effect.
Definition PointerShaderEffect.h:50
bool isUserEffect
Whether this pack was loaded from the user-local directory.
Definition PointerShaderEffect.h:101
QString id
Stable identifier, the registry lookup key.
Definition PointerShaderEffect.h:71
PhosphorShaders::PackPresets presets
Pack-declared named parameter presets: preset name -> { paramId -> value }.
Definition PointerShaderEffect.h:243
double resolvedReach(const QVariantMap &params) const
The pack's reach in logical px for the given friendly parameter map: the reachParam value when declar...
bool isMultipass
Opt-in multipass.
Definition PointerShaderEffect.h:172
static QString layerToken(Layer layer)
The metadata spelling of layer, the inverse of what fromJson parses.
QString reachParam
Optional name of an int/float parameter whose resolved value replaces reach (same idea as the surface...
Definition PointerShaderEffect.h:116
static constexpr double kMaxReach
Definition PointerShaderEffect.h:196
QList< TextureSlot > textures
Definition PointerShaderEffect.h:232
double resolvedTrailWindow(const QVariantMap &params) const
How far back this pack reads the trail, in seconds, for the given friendly parameter map: the trailWi...
Layer layer
Paint layer relative to the cursor. Default Below.
Definition PointerShaderEffect.h:107
bool isValid() const
Definition PointerShaderEffect.h:253
QString author
Author attribution.
Definition PointerShaderEffect.h:80
QString vertexShaderPath
Optional vertex shader path (same resolution rules).
Definition PointerShaderEffect.h:95
double reach
How far, in logical px, from any trail point or press point the pack may paint.
Definition PointerShaderEffect.h:112
bool needsCursor
Bind the cursor sprite as uCursorSprite. Default false.
Definition PointerShaderEffect.h:168
static constexpr double kMinBufferScale
Definition PointerShaderEffect.h:186
QString sourceDir
Resolved absolute directory containing this pack's assets.
Definition PointerShaderEffect.h:98
QString description
One-line description for settings UI.
Definition PointerShaderEffect.h:77
static constexpr double kMinReach
Bounds on resolvedReach, in logical px.
Definition PointerShaderEffect.h:195
QList< ParameterInfo > parameters
Definition PointerShaderEffect.h:214
static PointerShaderEffect fromJson(const QJsonObject &obj, const QString &sourceDir=QString(), bool isUser=false)
Parse a pack's metadata.json root.
Layer
Where the chain paints relative to the cursor.
Definition PointerShaderEffect.h:52
@ Below
The chain paints under KWin's cursor (or the hardware cursor plane) and never touches cursor visibili...
Definition PointerShaderEffect.h:55
double trailWindowSeconds
How far back, in seconds, the pack's stages actually READ the trail.
Definition PointerShaderEffect.h:155
QString fragmentShaderPath
Fragment shader path.
Definition PointerShaderEffect.h:91
QString category
Category for settings-UI grouping ("Trail", "Glow", "Click", ...).
Definition PointerShaderEffect.h:86
QString previewPath
Preview image path (absolute once resolved). Empty when none.
Definition PointerShaderEffect.h:104
bool bufferFeedback
Last frame's buffer is sampleable as iChannel<N>.
Definition PointerShaderEffect.h:180
QString trailWindowParam
Optional name of an int/float parameter whose resolved value replaces trailWindowSeconds,...
Definition PointerShaderEffect.h:165
QString version
Semantic version of this pack.
Definition PointerShaderEffect.h:83
QStringList bufferShaderPaths
Buffer-pass shader paths (max kMaxBufferPasses), resolved like fragmentShaderPath.
Definition PointerShaderEffect.h:176
double bufferScale
Render-target scale relative to the canvas, clamped to [kMinBufferScale, kMaxBufferScale] at parse ti...
Definition PointerShaderEffect.h:184
static constexpr double kMaxBufferScale
Definition PointerShaderEffect.h:187
bool samplesTrail
Whether any of the pack's stages actually reads uPointerTrail.
Definition PointerShaderEffect.h:141
double trailSeconds
How long, in seconds, after the last motion or button event the pack still needs frames.
Definition PointerShaderEffect.h:124
QString name
Human-readable display name.
Definition PointerShaderEffect.h:74