Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::MotionPreferences Class Reference

Process-wide reduced-motion preference tracker. More...

#include <motion_preferences.hpp>

Public Member Functions

MotionPolicy policy () const
 Current effective policy.
double duration_scale () const
 Current duration scale (default 1.0).
void set_duration_scale (double scale)
 Set the duration scale.
void set_override (std::optional< MotionPolicy > p)
 Override the OS-reported policy.
bool has_override () const noexcept
 Returns true if an override is currently in effect.
bool poll ()
 Poll the OS for a changed reduced-motion setting.
void on_policy_changed (std::function< void(MotionPolicy)> callback)
 Register a callback that fires whenever the effective policy changes (via poll() or set_override()).
void reset_for_tests ()
 Reset state for tests: clear override, reset duration_scale to 1.0, drop callbacks, re-read OS value.

Static Public Member Functions

static MotionPreferences & instance ()
 Process-wide instance. Reads the OS value on first construction.
static MotionPolicy current ()
 Convenience: the effective policy right now.
static double current_duration_scale ()
 Convenience: the effective duration scale right now.

Detailed Description

Process-wide reduced-motion preference tracker.

On macOS, reads [NSWorkspace sharedWorkspace].accessibilityDisplayShouldReduceMotion. On Windows, reads SystemParametersInfoW(SPI_GETCLIENTAREAANIMATION, ...). On other platforms, defaults to Full.

Member Function Documentation

◆ current()

MotionPolicy pulp::view::MotionPreferences::current ( )
inlinestatic

Convenience: the effective policy right now.

◆ current_duration_scale()

double pulp::view::MotionPreferences::current_duration_scale ( )
inlinestatic

Convenience: the effective duration scale right now.

◆ duration_scale()

double pulp::view::MotionPreferences::duration_scale ( ) const

Current duration scale (default 1.0).

Clamped to [0.0, 2.0]. Only meaningful when policy() == Reduced; primitives may use it regardless if they want a softer slowdown under Full.

◆ has_override()

bool pulp::view::MotionPreferences::has_override ( ) const
noexcept

Returns true if an override is currently in effect.

◆ instance()

MotionPreferences & pulp::view::MotionPreferences::instance ( )
static

Process-wide instance. Reads the OS value on first construction.

◆ on_policy_changed()

void pulp::view::MotionPreferences::on_policy_changed ( std::function< void(MotionPolicy)> callback)

Register a callback that fires whenever the effective policy changes (via poll() or set_override()).

◆ policy()

MotionPolicy pulp::view::MotionPreferences::policy ( ) const

Current effective policy.

Honors override when set, else returns the last polled OS value.

◆ poll()

bool pulp::view::MotionPreferences::poll ( )

Poll the OS for a changed reduced-motion setting.

Returns true when the effective policy changes since the last poll. When an override is in effect, this is a no-op and returns false.

◆ reset_for_tests()

void pulp::view::MotionPreferences::reset_for_tests ( )

Reset state for tests: clear override, reset duration_scale to 1.0, drop callbacks, re-read OS value.

◆ set_duration_scale()

void pulp::view::MotionPreferences::set_duration_scale ( double scale)

Set the duration scale.

Clamped to [0.0, 2.0]. Sticks across override changes; not derived from the OS.

◆ set_override()

void pulp::view::MotionPreferences::set_override ( std::optional< MotionPolicy > p)

Override the OS-reported policy.

Pass std::nullopt to revert to OS detection. Intended for tests and the JS bridge.


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