arc-motion 0.4.0

Physics-first animation & motion engine for GPUI: analytical ODE springs, cubic bezier, FLIP shared layout, presence, drag/rubber-band, inertia, and SVG path morphing.
Documentation
//! Ported from Arc (MIT) © 2026 Elia Kuratli
//! Reduced-motion wrappers over `gpui_kit::App::reduce_motion()` and
//! `gpui_kit::base::set_reduce_motion_preference`.

use gpui_kit::{
    App,
    base::{ReduceMotionPreference, set_reduce_motion_preference},
};

/// Returns whether reduced motion is currently active in GPUI.
#[inline]
pub fn is_reduced_motion(cx: &App) -> bool {
    cx.reduce_motion()
}

/// Application-level reduced motion override (used by `arc-gallery` toggle and tests).
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum ReducedMotionChoice {
    #[default]
    System,
    Reduce,
    Allow,
}

pub fn set_reduced_motion(choice: ReducedMotionChoice, cx: &mut App) {
    let pref = match choice {
        ReducedMotionChoice::System => ReduceMotionPreference::System,
        ReducedMotionChoice::Reduce => ReduceMotionPreference::Reduce,
        ReducedMotionChoice::Allow => ReduceMotionPreference::Allow,
    };
    set_reduce_motion_preference(pref, cx);
}

#[cfg(test)]
mod tests {
    use gpui_kit::TestAppContext;

    use super::*;

    #[gpui_kit::test]
    fn reduced_motion_toggle_updates_app_flag(cx: &mut TestAppContext) {
        cx.update(|cx| {
            gpui_kit::init(cx);
            set_reduced_motion(ReducedMotionChoice::Reduce, cx);
            assert!(is_reduced_motion(cx));
            set_reduced_motion(ReducedMotionChoice::Allow, cx);
            assert!(!is_reduced_motion(cx));
        });
    }
}