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. | |
Process-wide reduced-motion preference tracker.
On macOS, reads [NSWorkspace sharedWorkspace].accessibilityDisplayShouldReduceMotion. On Windows, reads SystemParametersInfoW(SPI_GETCLIENTAREAANIMATION, ...). On other platforms, defaults to Full.
|
inlinestatic |
Convenience: the effective policy right now.
|
inlinestatic |
Convenience: the effective duration scale right now.
| 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.
|
noexcept |
Returns true if an override is currently in effect.
|
static |
Process-wide instance. Reads the OS value on first construction.
| 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()).
| MotionPolicy pulp::view::MotionPreferences::policy | ( | ) | const |
Current effective policy.
Honors override when set, else returns the last polled OS value.
| 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.
| 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.
| 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.
| 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.