Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
ProfileTree.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 <QHash>
10#include <QJsonObject>
11#include <QString>
12#include <QStringList>
13
14namespace PhosphorAnimation {
15
16class CurveRegistry;
17
24class PHOSPHORANIMATION_EXPORT ProfileTree
25{
26public:
27 ProfileTree() = default;
28
29 ProfileTree(const ProfileTree&) = default;
30 ProfileTree& operator=(const ProfileTree&) = default;
33
38 Profile resolve(const QString& path) const;
39
61 Profile overlayChainOnto(const QString& path, Profile base) const;
62
65 Profile directOverride(const QString& path) const;
66
67 bool hasOverride(const QString& path) const;
68
70 QStringList overriddenPaths() const;
71
79 bool hasAnyOverride() const;
80
82 void setOverride(const QString& path, const Profile& profile);
83
85 bool clearOverride(const QString& path);
86
88
91 {
92 return m_baseline;
93 }
94 void setBaseline(const Profile& profile);
95
98 QJsonObject toJson() const;
99
102 static ProfileTree fromJson(const QJsonObject& obj, const CurveRegistry& registry);
103
104 bool operator==(const ProfileTree& other) const;
105 bool operator!=(const ProfileTree& other) const
106 {
107 return !(*this == other);
108 }
109
110private:
111 static void overlay(Profile& dst, const Profile& src);
112
118 Profile overlayChain(const QString& path, Profile seed) const;
119
120 Profile m_baseline;
121 QHash<QString, Profile> m_overrides;
122 QStringList m_insertionOrder;
123};
124
125} // namespace PhosphorAnimation
String-id <-> curve factory registry.
Definition CurveRegistry.h:26
Hierarchical profile storage with walk-up inheritance.
Definition ProfileTree.h:25
bool operator==(const ProfileTree &other) const
static ProfileTree fromJson(const QJsonObject &obj, const CurveRegistry &registry)
Parse from JSON.
bool operator!=(const ProfileTree &other) const
Definition ProfileTree.h:105
ProfileTree & operator=(ProfileTree &&)=default
Profile directOverride(const QString &path) const
Direct override at path without walking parents.
ProfileTree & operator=(const ProfileTree &)=default
QStringList overriddenPaths() const
Every path with a direct override, in insertion order.
Profile resolve(const QString &path) const
Resolve effective Profile for path (walks parents, fills defaults).
bool hasOverride(const QString &path) const
ProfileTree(const ProfileTree &)=default
QJsonObject toJson() const
Serialize the entire tree.
bool clearOverride(const QString &path)
Remove the override at path. Returns true if one was removed.
void setOverride(const QString &path, const Profile &profile)
Install an explicit override. Empty path is rejected (no-op).
bool hasAnyOverride() const
True when no path in the tree carries an override.
Profile baseline() const
The baseline "global" profile — always participates in resolution.
Definition ProfileTree.h:90
ProfileTree(ProfileTree &&)=default
Profile overlayChainOnto(const QString &path, Profile base) const
Overlay ONLY this tree's override chain for path onto base — the tree's own baseline is ignored and n...
void setBaseline(const Profile &profile)
Configuration for a single animation event.
Definition Profile.h:33
Definition AnimatedValue.h:32