embedded_gui/
transition_preset.rs1use crate::{
6 animation::Easing,
7 animation_timing::{
8 DEFAULT_DURATION_MS, MOOOK_DURATION_MS, PORT_HOLE_DURATION_MS, SHUTTER_DURATION_MS,
9 },
10 screen_transition::{ScreenTransitionEffect, ScreenTransitionSpec},
11};
12
13#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15pub enum TransitionPreset {
16 None,
18 WindowPush,
20 WindowPop,
22 WindowPushRound,
24 WindowPopRound,
26 ShutterUp,
28 ShutterDown,
29 ShutterLeft,
30 ShutterRight,
31 RoundFlipToLauncher,
33 RoundFlipFromLauncher,
35 PortHoleUp,
37 PortHoleDown,
38 PortHoleLeft,
39 PortHoleRight,
40 ModalPresent,
42 ModalDismiss,
44 TimelineSlide,
46 TimelinePeekIn,
48 TimelinePeekOut,
50 TimelinePinExpand,
52 TimelineScrubSettle,
54 Fade,
56}
57
58impl TransitionPreset {
59 pub const fn spec(self) -> ScreenTransitionSpec {
60 match self {
61 Self::None => ScreenTransitionSpec::none(),
62 Self::WindowPush => ScreenTransitionSpec::push_moook(MOOOK_DURATION_MS),
63 Self::WindowPop => ScreenTransitionSpec::pop_moook(MOOOK_DURATION_MS),
64 Self::WindowPushRound => ScreenTransitionSpec::port_hole_left(PORT_HOLE_DURATION_MS),
65 Self::WindowPopRound => ScreenTransitionSpec::port_hole_right(PORT_HOLE_DURATION_MS),
66 Self::ShutterUp => ScreenTransitionSpec::shutter_up(SHUTTER_DURATION_MS),
67 Self::ShutterDown => ScreenTransitionSpec::shutter_down(SHUTTER_DURATION_MS),
68 Self::ShutterLeft => ScreenTransitionSpec::shutter_left(SHUTTER_DURATION_MS),
69 Self::ShutterRight => ScreenTransitionSpec::shutter_right(SHUTTER_DURATION_MS),
70 Self::RoundFlipToLauncher => {
71 ScreenTransitionSpec::round_flip_right(PORT_HOLE_DURATION_MS)
72 }
73 Self::RoundFlipFromLauncher => {
74 ScreenTransitionSpec::round_flip_left(PORT_HOLE_DURATION_MS)
75 }
76 Self::PortHoleUp => ScreenTransitionSpec::port_hole_up(PORT_HOLE_DURATION_MS),
77 Self::PortHoleDown => ScreenTransitionSpec::port_hole_down(PORT_HOLE_DURATION_MS),
78 Self::PortHoleLeft => ScreenTransitionSpec::port_hole_left(PORT_HOLE_DURATION_MS),
79 Self::PortHoleRight => ScreenTransitionSpec::port_hole_right(PORT_HOLE_DURATION_MS),
80 Self::ModalPresent => ScreenTransitionSpec::modal_slide_up(DEFAULT_DURATION_MS),
81 Self::ModalDismiss => ScreenTransitionSpec::modal_slide_down(DEFAULT_DURATION_MS),
82 Self::TimelineSlide => {
83 ScreenTransitionSpec::slide_left(DEFAULT_DURATION_MS).with_easing(Easing::EaseInOut)
84 }
85 Self::TimelinePeekIn => ScreenTransitionSpec::slide_right(MOOOK_DURATION_MS / 2)
86 .with_easing(Easing::OutBack),
87 Self::TimelinePeekOut => {
88 ScreenTransitionSpec::slide_left(MOOOK_DURATION_MS / 2).with_easing(Easing::InSine)
89 }
90 Self::TimelinePinExpand => ScreenTransitionSpec::modal_slide_up(MOOOK_DURATION_MS / 2)
91 .with_easing(Easing::OutCubic),
92 Self::TimelineScrubSettle => ScreenTransitionSpec::slide_left(DEFAULT_DURATION_MS / 2)
93 .with_easing(Easing::OutBounce),
94 Self::Fade => ScreenTransitionSpec::fade(DEFAULT_DURATION_MS),
95 }
96 }
97
98 pub const fn effect(self) -> ScreenTransitionEffect {
99 self.spec().effect
100 }
101}
102
103impl From<TransitionPreset> for ScreenTransitionSpec {
104 fn from(value: TransitionPreset) -> Self {
105 value.spec()
106 }
107}