Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
AnimationAppRule.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 <PhosphorAnimation/phosphoranimation_export.h>
7
8#include <QList>
9#include <QString>
10#include <QVariantMap>
11
12#include <optional>
13
14class QJsonArray;
15class QJsonObject;
16
18
59struct PHOSPHORANIMATION_EXPORT AnimationAppRule
60{
61 enum class Kind {
62 Shader,
63 Timing,
64 };
65
70 QString classPattern;
71
75 QString eventPath;
76
77 Kind kind = Kind::Shader;
78
79 // ─── Shader-kind payload (kind == Shader only) ────────────────
83 QString effectId;
88 QVariantMap shaderParams;
89
90 // ─── Timing-kind payload (kind == Timing only) ────────────────
94 QString curve;
97 int durationMs = 0;
98
99 bool operator==(const AnimationAppRule& other) const noexcept;
100 bool operator!=(const AnimationAppRule& other) const noexcept
101 {
102 return !(*this == other);
103 }
104
105 QJsonObject toJson() const;
106
127 static std::optional<AnimationAppRule> fromJson(const QJsonObject& obj);
128};
129
139class PHOSPHORANIMATION_EXPORT AnimationAppRuleList
140{
141public:
143
144 int size() const noexcept
145 {
146 return m_rules.size();
147 }
148 bool isEmpty() const noexcept
149 {
150 return m_rules.isEmpty();
151 }
158 AnimationAppRule at(int index) const;
159 QList<AnimationAppRule> entries() const
160 {
161 return m_rules;
162 }
163
169 bool append(const AnimationAppRule& rule);
170 void removeAt(int index);
171 void move(int from, int to);
172 void clear() noexcept
173 {
174 m_rules.clear();
175 }
183 int setEntries(const QList<AnimationAppRule>& rules);
184
190 std::optional<AnimationAppRule> resolveShader(const QString& windowClass, const QString& eventPath) const;
191
194 std::optional<AnimationAppRule> resolveTiming(const QString& windowClass, const QString& eventPath) const;
195
196 QJsonArray toJson() const;
197 static AnimationAppRuleList fromJson(const QJsonArray& arr);
198
199 bool operator==(const AnimationAppRuleList& other) const noexcept
200 {
201 return m_rules == other.m_rules;
202 }
203 bool operator!=(const AnimationAppRuleList& other) const noexcept
204 {
205 return !(*this == other);
206 }
207
208private:
211 std::optional<AnimationAppRule> firstMatchOfKind(AnimationAppRule::Kind kind, const QString& windowClass,
212 const QString& eventPath) const;
213
214 QList<AnimationAppRule> m_rules;
215};
216
217} // namespace PhosphorAnimationShaders
Ordered list of AnimationAppRule entries with first-match resolver.
Definition AnimationAppRule.h:140
int size() const noexcept
Definition AnimationAppRule.h:144
static AnimationAppRuleList fromJson(const QJsonArray &arr)
void clear() noexcept
Definition AnimationAppRule.h:172
bool operator!=(const AnimationAppRuleList &other) const noexcept
Definition AnimationAppRule.h:203
bool operator==(const AnimationAppRuleList &other) const noexcept
Definition AnimationAppRule.h:199
bool append(const AnimationAppRule &rule)
Append rule.
int setEntries(const QList< AnimationAppRule > &rules)
Replace the entire list (used by setters that take a full already-built list, e.g.
bool isEmpty() const noexcept
Definition AnimationAppRule.h:148
std::optional< AnimationAppRule > resolveTiming(const QString &windowClass, const QString &eventPath) const
First matching Kind::Timing rule for the given (windowClass, eventPath).
AnimationAppRule at(int index) const
Random-access read.
std::optional< AnimationAppRule > resolveShader(const QString &windowClass, const QString &eventPath) const
First matching Kind::Shader rule for the given (windowClass, eventPath).
QList< AnimationAppRule > entries() const
Definition AnimationAppRule.h:159
Definition AnimationAppRule.h:17
One per-window animation override entry.
Definition AnimationAppRule.h:60
QString effectId
Shader effect id from the registry.
Definition AnimationAppRule.h:83
QString classPattern
Substring matched case-insensitively against EffectWindow::windowClass() (or the equivalent in the da...
Definition AnimationAppRule.h:70
bool operator!=(const AnimationAppRule &other) const noexcept
Definition AnimationAppRule.h:100
QString curve
Easing curve string in Profile's wire format ("x1,y1,x2,y2", "elastic-out:amp,per",...
Definition AnimationAppRule.h:94
bool operator==(const AnimationAppRule &other) const noexcept
Kind
Definition AnimationAppRule.h:61
QString eventPath
Animation event path from PhosphorAnimation::ProfilePaths::Window* (e.g.
Definition AnimationAppRule.h:75
QVariantMap shaderParams
Per-effect parameter map (same shape as the per-event tree).
Definition AnimationAppRule.h:88
static std::optional< AnimationAppRule > fromJson(const QJsonObject &obj)
Strict rule-level loader.