diff --git a/crates/anim/src/effects.rs b/crates/anim/src/effects.rs index 37776f83..51a82a71 100644 --- a/crates/anim/src/effects.rs +++ b/crates/anim/src/effects.rs @@ -44,6 +44,15 @@ pub(crate) fn exit_base(effect: &str) -> &str { "swivelOut" => "swivel", "bounceOut" => "bounce", "dissolveOut" => "dissolve", + "blindsOut" => "blinds", + "boxOut" => "box", + "checkerboardOut" => "checkerboard", + "diamondOut" => "diamond", + "peekOut" => "peek", + "stripsOut" => "strips", + "sinkDown" => "rise", + "spinnerOut" => "spinner", + "contract" => "expand", other => other, } } diff --git a/crates/anim/src/tests.rs b/crates/anim/src/tests.rs index 1fd82d78..d3f07204 100644 --- a/crates/anim/src/tests.rs +++ b/crates/anim/src/tests.rs @@ -789,3 +789,15 @@ fn show_follows_links() { assert_eq!(s.follow(&p, &Action::LastViewed, None), LinkJump::None); assert_eq!(s.slide, 3); } + +/// #147: exits PowerPoint plays downward leave downward here too. +#[test] +fn sink_down_and_peek_out_to_bottom_move_down() { + for (effect, option) in [("sinkDown", ""), ("peekOut", "b"), ("floatOut", "d")] { + let mut a = anim(1, AnimClass::Exit, effect, AnimStart::OnClick); + a.option = option.into(); + let tl = Timeline::new(&slide_with(vec![a]), W, H); + let s = tl.state(ShapeId(1), None, 0, 0.5); + assert!(s.offset_y > 0.0, "{effect} {option}: {s:?}"); + } +} diff --git a/crates/anim/src/timeline.rs b/crates/anim/src/timeline.rs index e73acfd9..2932b173 100644 --- a/crates/anim/src/timeline.rs +++ b/crates/anim/src/timeline.rs @@ -471,7 +471,8 @@ fn build_spec(a: &Animation, xf: Xfrm, sw: f64, sh: f64, resolve: &dyn Fn(&deckc EffectSpec { class: a.class, effect, - option: a.option.clone(), + // Sink Down is Rise Up played backwards, leaving downward. + option: if a.effect == "sinkDown" { "d".into() } else { a.option.clone() }, accel: a.smooth_start, decel: a.smooth_end, bounce: a.bounce_end, diff --git a/crates/model/src/anim.rs b/crates/model/src/anim.rs index 3495d21e..667b3952 100644 --- a/crates/model/src/anim.rs +++ b/crates/model/src/anim.rs @@ -270,6 +270,15 @@ pub static ANIMATIONS: &[(&str, &str, AnimClass, u32, u32, &[&str])] = &[ ("swivelOut", "Swivel", AnimClass::Exit, 45, 2000, &["horz", "vert"]), ("bounceOut", "Bounce", AnimClass::Exit, 26, 2000, &[]), ("dissolveOut", "Dissolve Out", AnimClass::Exit, 9, 500, &[]), + ("blindsOut", "Blinds", AnimClass::Exit, 3, 500, &["horz", "vert"]), + ("boxOut", "Box", AnimClass::Exit, 4, 500, &["in", "out"]), + ("checkerboardOut", "Checkerboard", AnimClass::Exit, 5, 500, &["across", "down"]), + ("diamondOut", "Diamond", AnimClass::Exit, 8, 500, &["in", "out"]), + ("peekOut", "Peek Out", AnimClass::Exit, 12, 500, &["b", "l", "t", "r"]), + ("stripsOut", "Strips", AnimClass::Exit, 18, 500, &["lu", "ru", "ld", "rd"]), + ("sinkDown", "Sink Down", AnimClass::Exit, 37, 1000, &[]), + ("spinnerOut", "Spinner", AnimClass::Exit, 49, 1000, &[]), + ("contract", "Contract", AnimClass::Exit, 55, 500, &[]), ("lines", "Lines", AnimClass::Path, 64, 2000, &["down", "up", "right", "left"]), ("arcs", "Arcs", AnimClass::Path, 37, 2000, &["down", "up", "right", "left"]), ("turns", "Turns", AnimClass::Path, 43, 2000, &["down", "up", "right", "left"]), diff --git a/crates/pptx/src/maps.rs b/crates/pptx/src/maps.rs index c700d8eb..70b9f5cf 100644 --- a/crates/pptx/src/maps.rs +++ b/crates/pptx/src/maps.rs @@ -256,6 +256,12 @@ const SUBTYPES: &[(&str, &[(&str, u32)])] = &[ ("blinds", HV), ("swivel", HV), ("swivelOut", HV), + ("blindsOut", HV), + ("boxOut", INOUT), + ("checkerboardOut", &[("across", 10), ("down", 5)]), + ("diamondOut", INOUT), + ("peekOut", DIR4), + ("stripsOut", &[("lu", 9), ("ru", 3), ("ld", 12), ("rd", 6)]), ("checkerboard", &[("across", 10), ("down", 5)]), ("wheel", WHEEL), ("wheelOut", WHEEL), @@ -329,6 +335,25 @@ mod tests { use super::*; use crate::xml::parse; + /// #147: these exits, with their directions, fell back to a plain fade (PowerPoint's ids). + #[test] + fn exit_presets_import_as_their_own_effects() { + for (preset, sub, effect, option) in [ + (3, 10, "blindsOut", "horz"), + (4, 32, "boxOut", "out"), + (5, 5, "checkerboardOut", "down"), + (8, 16, "diamondOut", "in"), + (12, 4, "peekOut", "b"), + (18, 6, "stripsOut", "rd"), + (37, 0, "sinkDown", ""), + (49, 0, "spinnerOut", ""), + (55, 0, "contract", ""), + ] { + let e = effect_for_preset(AnimClass::Exit, preset).expect("known exit"); + assert_eq!((e, option_from_subtype(e, sub).as_str()), (effect, option), "preset {preset}"); + } + } + #[test] fn every_transition_kind_round_trips() { for (kind, _, _, _, opts) in deckcraft_model::anim::TRANSITIONS { diff --git a/crates/pptx/src/write/timing.rs b/crates/pptx/src/write/timing.rs index aa577ca7..56ba5a9d 100644 --- a/crates/pptx/src/write/timing.rs +++ b/crates/pptx/src/write/timing.rs @@ -208,14 +208,14 @@ fn filter_for(effect: &str, option: &str) -> &'static str { "randombar(horizontal)" } } - "blinds" => { + "blinds" | "blindsOut" => { if option == "vert" { "blinds(vertical)" } else { "blinds(horizontal)" } } - "box" => { + "box" | "boxOut" => { if option == "out" { "box(out)" } else { @@ -229,7 +229,7 @@ fn filter_for(effect: &str, option: &str) -> &'static str { "circle(in)" } } - "diamond" => { + "diamond" | "diamondOut" => { if option == "out" { "diamond(out)" } else { @@ -246,7 +246,7 @@ fn filter_for(effect: &str, option: &str) -> &'static str { "plusOut" => "plus(out)", _ => "circle(in)", }, - "checkerboard" => { + "checkerboard" | "checkerboardOut" => { if option == "down" { "checkerboard(down)" } else { @@ -261,13 +261,13 @@ fn filter_for(effect: &str, option: &str) -> &'static str { "8" => "wheel(8)", _ => "wheel(1)", }, - "strips" => match option { + "strips" | "stripsOut" => match option { "ru" => "strips(upRight)", "ld" => "strips(downLeft)", "rd" => "strips(downRight)", _ => "strips(upLeft)", }, - "peek" => match option { + "peek" | "peekOut" => match option { "t" => "slide(fromTop)", "l" => "slide(fromLeft)", "r" => "slide(fromRight)", @@ -328,7 +328,12 @@ fn behaviors(w: &mut W, x: &mut Exp, ids: &mut Ids, e: &Eff) { anim_prop(w, ids, e, dur, "ppt_x", "#ppt_x", fx); anim_prop(w, ids, e, dur, "ppt_y", "#ppt_y", fy); } - "zoomOut" | "shrinkTurn" => { + "floatOut" | "sinkDown" => { + let to = if a.effect == "sinkDown" || a.option == "d" { "#ppt_y+.1" } else { "#ppt_y-.1" }; + anim_prop(w, ids, e, dur, "ppt_y", "#ppt_y", to); + anim_effect(w, ids, e, dur, "fade", true); + } + "zoomOut" | "shrinkTurn" | "spinnerOut" | "contract" => { anim_prop(w, ids, e, dur, "ppt_w", "#ppt_w", "0"); anim_prop(w, ids, e, dur, "ppt_h", "#ppt_h", "0"); anim_effect(w, ids, e, dur, "fade", true);