Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorAnimation::Profile Class Reference

Configuration for a single animation event. More...

#include <phosphor-animation/include/PhosphorAnimation/Profile.h>

Public Member Functions

 Profile ()=default
 
 Profile (const Profile &)=default
 
Profileoperator= (const Profile &)=default
 
 Profile (Profile &&)=default
 
Profileoperator= (Profile &&)=default
 
qreal effectiveDuration () const
 
int effectiveMinDistance () const
 
SequenceMode effectiveSequenceMode () const
 
int effectiveStaggerInterval () const
 
Profile withDefaults () const
 Copy with every unset field filled from library defaults — curve is backfilled with a default-constructed Easing (OutCubic) when null, and duration / minDistance / sequenceMode / staggerInterval take their Default* constants.
 
QJsonObject toJson () const
 Serialize to JSON. Only set fields are emitted.
 
bool operator== (const Profile &other) const
 
bool operator!= (const Profile &other) const
 

Static Public Member Functions

static Profile fromJson (const QJsonObject &obj, const CurveRegistry &registry)
 Parse from JSON.
 

Public Attributes

std::shared_ptr< const Curvecurve
 nullptr = inherit from parent / library default (outCubic bezier).
 
std::optional< qreal > duration
 Animation length in ms. Spring curves derive their own settle time.
 
std::optional< intminDistance
 Skip threshold in px — animation skipped if distance < this and no size change.
 
std::optional< SequenceModesequenceMode
 
std::optional< intstaggerInterval
 Milliseconds between cascade starts.
 
std::optional< QStringpresetName
 Optional user-assigned preset name. Purely decorative for UI.
 

Static Public Attributes

static constexpr qreal DefaultDuration = 150.0
 
static constexpr int DefaultMinDistance = 0
 
static constexpr SequenceMode DefaultSequenceMode = SequenceMode::AllAtOnce
 
static constexpr int DefaultStaggerInterval = 30
 
static constexpr qreal MaxDurationMs = 60.0 * 60.0 * 1000.0
 
static constexpr int MaxStaggerIntervalMs = 60 * 60 * 1000
 
static constexpr int MaxMinDistancePx = 100000
 Upper bound on minDistance, in pixels.
 
static constexpr auto JsonFieldCurve = "curve"
 
static constexpr auto JsonFieldDuration = "duration"
 
static constexpr auto JsonFieldMinDistance = "minDistance"
 
static constexpr auto JsonFieldSequenceMode = "sequenceMode"
 
static constexpr auto JsonFieldStaggerInterval = "staggerInterval"
 
static constexpr auto JsonFieldPresetName = "presetName"
 

Detailed Description

Configuration for a single animation event.

Fields are std::optional so ProfileTree inheritance can distinguish "inherit from parent" (nullopt) from "explicitly set" (engaged). Use effective*() getters or withDefaults() for runtime values with library defaults filled in.

Constructor & Destructor Documentation

◆ Profile() [1/3]

PhosphorAnimation::Profile::Profile ( )
default

◆ Profile() [2/3]

PhosphorAnimation::Profile::Profile ( const Profile )
default

◆ Profile() [3/3]

PhosphorAnimation::Profile::Profile ( Profile &&  )
default

Member Function Documentation

◆ effectiveDuration()

qreal PhosphorAnimation::Profile::effectiveDuration ( ) const
inline

◆ effectiveMinDistance()

int PhosphorAnimation::Profile::effectiveMinDistance ( ) const
inline

◆ effectiveSequenceMode()

SequenceMode PhosphorAnimation::Profile::effectiveSequenceMode ( ) const
inline

◆ effectiveStaggerInterval()

int PhosphorAnimation::Profile::effectiveStaggerInterval ( ) const
inline

◆ fromJson()

static Profile PhosphorAnimation::Profile::fromJson ( const QJsonObject obj,
const CurveRegistry registry 
)
static

Parse from JSON.

Missing keys produce unset fields. Curve resolved via registry. duration / minDistance / staggerInterval that are out of range, OR that hold something which is not a JSON number, are rejected: logged and left unset, so the field inherits from a parent profile or falls back to the library default. The type check is not redundant — QJsonValue::toDouble(default) hands back the default for any non-number, and every library default passes the range checks, so without it a malformed value would land ENGAGED and block inheritance.

curve resolves through registry and is left NULL when the key is absent or names no registered curve, so an unknown curve inherits rather than pinning the library default. presetName takes any string as-is (it is decorative, so there is nothing to range-check), but a NON-string value is rejected, warned about, and leaves the field unset like the others.

Every diagnostic mentioned here is RATE-LIMITED to once per (field, reason) per process. Settings::animationProfile() parses through here with no cache and the daemon republishes on a settings slider's drag path, so an unlimited warning would emit tens of times a second for the length of a drag. A user debugging a hand-edited profile therefore sees the warning on the first parse only.

sequenceMode is the one exception. A value that is out of range or not a known enumerator is logged and replaced with DefaultSequenceMode ENGAGED, which blocks inheritance rather than allowing it. Leaving it unset would let a parent's Cascade through on a leaf whose own file says otherwise, which reads as the override having silently done nothing.

◆ operator!=()

◆ operator=() [1/2]

◆ operator=() [2/2]

◆ operator==()

◆ toJson()

QJsonObject PhosphorAnimation::Profile::toJson ( ) const

Serialize to JSON. Only set fields are emitted.

◆ withDefaults()

Profile PhosphorAnimation::Profile::withDefaults ( ) const

Copy with every unset field filled from library defaults — curve is backfilled with a default-constructed Easing (OutCubic) when null, and duration / minDistance / sequenceMode / staggerInterval take their Default* constants.

presetName is the ONE exception: it has no library default and stays disengaged, so callers must still treat it as optional (value_or), never dereference it blind.

Member Data Documentation

◆ curve

std::shared_ptr<const Curve> PhosphorAnimation::Profile::curve

nullptr = inherit from parent / library default (outCubic bezier).

◆ DefaultDuration

constexpr qreal PhosphorAnimation::Profile::DefaultDuration = 150.0
staticconstexpr

◆ DefaultMinDistance

constexpr int PhosphorAnimation::Profile::DefaultMinDistance = 0
staticconstexpr

◆ DefaultSequenceMode

constexpr SequenceMode PhosphorAnimation::Profile::DefaultSequenceMode = SequenceMode::AllAtOnce
staticconstexpr

◆ DefaultStaggerInterval

constexpr int PhosphorAnimation::Profile::DefaultStaggerInterval = 30
staticconstexpr

◆ duration

std::optional<qreal> PhosphorAnimation::Profile::duration

Animation length in ms. Spring curves derive their own settle time.

◆ JsonFieldCurve

constexpr auto PhosphorAnimation::Profile::JsonFieldCurve = "curve"
staticconstexpr

◆ JsonFieldDuration

constexpr auto PhosphorAnimation::Profile::JsonFieldDuration = "duration"
staticconstexpr

◆ JsonFieldMinDistance

constexpr auto PhosphorAnimation::Profile::JsonFieldMinDistance = "minDistance"
staticconstexpr

◆ JsonFieldPresetName

constexpr auto PhosphorAnimation::Profile::JsonFieldPresetName = "presetName"
staticconstexpr

◆ JsonFieldSequenceMode

constexpr auto PhosphorAnimation::Profile::JsonFieldSequenceMode = "sequenceMode"
staticconstexpr

◆ JsonFieldStaggerInterval

constexpr auto PhosphorAnimation::Profile::JsonFieldStaggerInterval = "staggerInterval"
staticconstexpr

◆ MaxDurationMs

constexpr qreal PhosphorAnimation::Profile::MaxDurationMs = 60.0 * 60.0 * 1000.0
staticconstexpr

◆ MaxMinDistancePx

constexpr int PhosphorAnimation::Profile::MaxMinDistancePx = 100000
staticconstexpr

Upper bound on minDistance, in pixels.

Sized well past any real display diagonal, so it never rejects a value a user could mean, while giving the validator a DOMAIN bound like its two siblings above rather than the int range: a minDistance of two billion pixels is not a large threshold, it is "never animate anything", which is exactly what these caps exist to refuse.

◆ MaxStaggerIntervalMs

constexpr int PhosphorAnimation::Profile::MaxStaggerIntervalMs = 60 * 60 * 1000
staticconstexpr

◆ minDistance

std::optional<int> PhosphorAnimation::Profile::minDistance

Skip threshold in px — animation skipped if distance < this and no size change.

◆ presetName

std::optional<QString> PhosphorAnimation::Profile::presetName

Optional user-assigned preset name. Purely decorative for UI.

◆ sequenceMode

std::optional<SequenceMode> PhosphorAnimation::Profile::sequenceMode

◆ staggerInterval

std::optional<int> PhosphorAnimation::Profile::staggerInterval

Milliseconds between cascade starts.


The documentation for this class was generated from the following file: