Tunal/crates/tunal/ui/motion.slint
astar76 c94b868b2e S005: overlay layer, menu with submenu, modal dialog, toast stack
Menus, dialogs and toasts draw on an own full-window layer so they can
play exit motion; gallery pages show them open for screenshots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 10:06:17 -06:00

53 lines
2.2 KiB
Text

// Motion tokens: Material 3 durations and easings. Wrap every duration in `Motion.time()`
// so reduced motion makes it instant.
// The flag Rust sets (portal enable-animations, or TUNAL_REDUCED_MOTION=1). Kept apart from
// Motion because easing properties can't be exported to Rust.
export global MotionPrefs {
in property <bool> reduced;
}
export global Motion {
out property <bool> reduced: MotionPrefs.reduced;
out property <duration> short1: 50ms;
out property <duration> short2: 100ms;
out property <duration> short3: 150ms;
out property <duration> short4: 200ms;
out property <duration> medium1: 250ms;
out property <duration> medium2: 300ms;
out property <duration> medium3: 350ms;
out property <duration> medium4: 400ms;
out property <duration> long1: 450ms;
out property <duration> long2: 500ms;
out property <duration> long3: 550ms;
out property <duration> long4: 600ms;
// Emphasized is a two-segment path in M3; this is its usual single-bezier stand-in.
out property <easing> emphasized: cubic-bezier(0.2, 0, 0, 1);
out property <easing> emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
out property <easing> emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
out property <easing> standard: cubic-bezier(0.2, 0, 0, 1);
out property <easing> standard-decelerate: cubic-bezier(0, 0, 0, 1);
out property <easing> standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
// Press squeeze (scale while held): small controls squeeze most, wide ones least.
out property <float> squeeze-small: 0.9;
out property <float> squeeze: 0.96;
out property <float> squeeze-large: 0.985;
// Scale a floating surface starts from (and leaves towards), never 0.
out property <float> enter-scale: 0.92;
// How long a toast without progress or action stays. A delay, not motion.
out property <duration> toast-timeout: 4s;
// One sweep of an indeterminate progress bar.
out property <duration> indeterminate-period: 1500ms;
// Hover time before a tooltip shows. A delay, not motion: reduced motion keeps it.
out property <duration> tooltip-delay: 500ms;
public pure function time(d: duration) -> duration {
reduced ? 0ms : d
}
}