39class MotionPreferences {
88 MotionPreferences(const MotionPreferences&) = delete;
89 MotionPreferences& operator=(const MotionPreferences&) = delete;
103 mutable
std::mutex mtx_;
106 double duration_scale_ = 1.0;
119 switch (prefs.policy()) {
123 return configured_seconds *
124 static_cast<float>(prefs.duration_scale());
127 return configured_seconds;
143 default:
return "full";
void reset_for_tests()
Reset state for tests: clear override, reset duration_scale to 1.0, drop callbacks,...
static MotionPolicy current()
Convenience: the effective policy right now.
Definition motion_preferences.hpp:45
void set_override(std::optional< MotionPolicy > p)
Override the OS-reported policy.
MotionPolicy policy() const
Current effective policy.
static MotionPreferences & instance()
Process-wide instance. Reads the OS value on first construction.
void on_policy_changed(std::function< void(MotionPolicy)> callback)
Register a callback that fires whenever the effective policy changes (via poll() or set_override()).
double duration_scale() const
Current duration scale (default 1.0).
bool poll()
Poll the OS for a changed reduced-motion setting.
void set_duration_scale(double scale)
Set the duration scale.
bool has_override() const noexcept
Returns true if an override is currently in effect.
static double current_duration_scale()
Convenience: the effective duration scale right now.
Definition motion_preferences.hpp:48
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
float apply_motion_policy_to_duration(float configured_seconds)
Apply the current MotionPolicy to a configured duration.
Definition motion_preferences.hpp:117
const char * motion_policy_to_string(MotionPolicy p)
Returns the current policy string for fixture headers.
Definition motion_preferences.hpp:138
bool motion_policy_is_off()
Returns true when the current policy says "do not animate" — i.e.
Definition motion_preferences.hpp:133
@ s
Definition input_events.hpp:41
@ p
Definition input_events.hpp:40
@ scale
Definition css_animation.hpp:126
MotionPolicy motion_policy_from_string(const std::string_view s)
Parse a policy string (case-sensitive). Returns Full on unknown.
Definition motion_preferences.hpp:148
MotionPolicy
Reduced-motion policy.
Definition motion_preferences.hpp:28
@ Reduced
Animate, but scale duration by duration_scale.
Definition motion_preferences.hpp:30
@ Full
Animate normally.
Definition motion_preferences.hpp:29
@ Off
Skip animation; jump to the target value.
Definition motion_preferences.hpp:31