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

Opaque QML value-type wrapper around shared_ptr<const Curve>. More...

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

Public Member Functions

 PhosphorCurve ()=default
 
 PhosphorCurve (std::shared_ptr< const Curve > curve)
 
std::shared_ptr< const Curvecurve () const
 The wrapped pointer. May be null on a default-constructed handle.
 
QString typeId () const
 Stable curve type-id string ("cubic-bezier", "spring", "elastic-out", …).
 
QString toString () const
 Serialize to wire format. Empty when null.
 
bool isNull () const
 Null-handle check for QML code: if (!curve.isNull()) ....
 
bool operator== (const PhosphorCurve &other) const
 Equality compares via Curve::equals so curves with floating-point parameters compare tightly rather than through the string form.
 
bool operator!= (const PhosphorCurve &other) const
 

Static Public Member Functions

static void setDefaultRegistry (CurveRegistry *registry)
 Set the process-wide default CurveRegistry used by fromString.
 
static CurveRegistrydefaultRegistry ()
 Read-only view of the process-wide default CurveRegistry pointer installed via setDefaultRegistry.
 
static PhosphorCurve fromString (const QString &str)
 Parse via CurveRegistry — handles every curve type the registry knows, including user-authored curves registered by CurveLoader.
 
static PhosphorCurve fromEasing (const PhosphorEasing &easing)
 Wrap an Easing value as a polymorphic PhosphorCurve.
 
static PhosphorCurve fromSpring (const PhosphorSpring &spring)
 Wrap a Spring value as a polymorphic PhosphorCurve.
 

Detailed Description

Opaque QML value-type wrapper around shared_ptr<const Curve>.

Q_GADGET per Phase 4 decision O. Holds a polymorphic curve reference without exposing the Curve hierarchy to QML — plugin authors who only need to pass a curve through the system (curve → ProfilePhosphorMotionAnimation) can use PhosphorCurve as an opaque token, while authors that need specific parameters construct PhosphorEasing / PhosphorSpring directly.

Serialization round-trips through CurveRegistry — a PhosphorCurve constructed from a string resolves whatever curve type the registry knows about (including third-party curves registered via CurveRegistry::registerFactory, which is how Phase 4's CurveLoader extends the known set from user-authored JSON).

Immutability

The wrapped shared_ptr<const Curve> is immutable — consistent with the Curve contract that subclasses must not be mutated after construction. Mutating needs a rebuild (PhosphorCurve::fromEasing(...), fromSpring(...), or fromString(...)) which replaces the stored pointer.

Constructor & Destructor Documentation

◆ PhosphorCurve() [1/2]

PhosphorAnimation::PhosphorCurve::PhosphorCurve ( )
default

◆ PhosphorCurve() [2/2]

PhosphorAnimation::PhosphorCurve::PhosphorCurve ( std::shared_ptr< const Curve curve)
inlineexplicit

Member Function Documentation

◆ curve()

std::shared_ptr< const Curve > PhosphorAnimation::PhosphorCurve::curve ( ) const
inline

The wrapped pointer. May be null on a default-constructed handle.

◆ defaultRegistry()

static CurveRegistry * PhosphorAnimation::PhosphorCurve::defaultRegistry ( )
inlinestatic

Read-only view of the process-wide default CurveRegistry pointer installed via setDefaultRegistry.

Returns nullptr when no registry has been published yet. Used by PhosphorProfile:: fromJson to route parse requests through the same user-curve- aware registry that fromString consults — without this shared accessor, fromJson would see only built-ins via its function-local static registry and user-authored curves registered by CurveLoader::setDefaultRegistry would silently fail to resolve.

◆ fromEasing()

static PhosphorCurve PhosphorAnimation::PhosphorCurve::fromEasing ( const PhosphorEasing easing)
static

Wrap an Easing value as a polymorphic PhosphorCurve.

Allocates a shared_ptr<Easing> copy of the value.

◆ fromSpring()

static PhosphorCurve PhosphorAnimation::PhosphorCurve::fromSpring ( const PhosphorSpring spring)
static

Wrap a Spring value as a polymorphic PhosphorCurve.

◆ fromString()

static PhosphorCurve PhosphorAnimation::PhosphorCurve::fromString ( const QString &  str)
static

Parse via CurveRegistry — handles every curve type the registry knows, including user-authored curves registered by CurveLoader.

Returns a null-handle PhosphorCurve on parse failure (check via isNull()).

◆ isNull()

bool PhosphorAnimation::PhosphorCurve::isNull ( ) const
inline

Null-handle check for QML code: if (!curve.isNull()) ....

◆ operator!=()

bool PhosphorAnimation::PhosphorCurve::operator!= ( const PhosphorCurve other) const
inline

◆ operator==()

bool PhosphorAnimation::PhosphorCurve::operator== ( const PhosphorCurve other) const
inline

Equality compares via Curve::equals so curves with floating-point parameters compare tightly rather than through the string form.

◆ setDefaultRegistry()

static void PhosphorAnimation::PhosphorCurve::setDefaultRegistry ( CurveRegistry registry)
static

Set the process-wide default CurveRegistry used by fromString.

Must be called by the composition root (daemon / editor) before any QML code invokes fromString. The pointer must outlive all QML usage (typically a member of the daemon). When null, fromString returns a null-handle PhosphorCurve.

◆ toString()

QString PhosphorAnimation::PhosphorCurve::toString ( ) const
inline

Serialize to wire format. Empty when null.

◆ typeId()

QString PhosphorAnimation::PhosphorCurve::typeId ( ) const
inline

Stable curve type-id string ("cubic-bezier", "spring", "elastic-out", …).

Empty when the handle is null.


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