diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 71b200b..3adc6ce 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -527,7 +527,7 @@ fn preset_chord() -> String { .join(" / ") } -pub static FIXED: std::sync::LazyLock<[Fixed; 32]> = std::sync::LazyLock::new(|| { +pub static FIXED: std::sync::LazyLock<[Fixed; 35]> = std::sync::LazyLock::new(|| { [ // Not a chord at all but a way of pressing one, and the only place the // editor can say so: holding a key that moves a *value* runs it, and @@ -725,6 +725,27 @@ pub static FIXED: std::sync::LazyLock<[Fixed; 32]> = std::sync::LazyLock::new(|| category: Category::Clips, reach: Reach::Click("color-reset"), }, + // The transform card's own three, the same shape as the colour card's: + // up/down pick a band (position, scale, rotate, crop), left/right move + // it, and `r` resets to identity. + Fixed { + chord: "↑ / ↓".into(), + label: "Pick a transform band", + category: Category::Clips, + reach: Reach::Click("transform-row"), + }, + Fixed { + chord: "← / →".into(), + label: "Move the picked transform band", + category: Category::Clips, + reach: Reach::Click("transform-bar"), + }, + Fixed { + chord: "r".into(), + label: "Take the transform off the clip", + category: Category::Clips, + reach: Reach::Click("transform-reset"), + }, // The silence card's two apply keys. Card-local like every stroke above -- // they mean nothing while it is closed -- but the card is the one place in // this editor where a key rewrites forty places at once, so both of them diff --git a/crates/app/src/menus.rs b/crates/app/src/menus.rs index 35dcb3e..ab4fe71 100644 --- a/crates/app/src/menus.rs +++ b/crates/app/src/menus.rs @@ -142,7 +142,7 @@ impl RowItem { /// action a stroke already reaches -- the menu is a second way *to* the actions /// and never a second version of them -- so both the label and the hint come /// out of the keymap registry and the two can never disagree. -pub(crate) const MENU_ITEMS: [ActionId; 15] = [ +pub(crate) const MENU_ITEMS: [ActionId; 16] = [ ActionId::Cut, // The clipboard pair, which had no door but a chord: copy takes the clip the // menu names, and paste is the timeline's rather than this clip's -- the @@ -165,6 +165,7 @@ pub(crate) const MENU_ITEMS: [ActionId; 15] = [ // whichever half was clicked. ActionId::Dissolve, ActionId::Color, + ActionId::Transform, ActionId::Fit, ActionId::ToggleMute, ]; diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 65babbe..bd4c035 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -187,7 +187,7 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { }, // A grade is a picture setting and an audio clip has no picture. A fit // policy is a picture setting for the same reason. - ActionId::Color | ActionId::Fit => match ctx.clip { + ActionId::Color | ActionId::Fit | ActionId::Transform => match ctx.clip { Some((_, lane)) if lane.kind != LaneKind::Video => Enable::Hidden("this clip is sound"), _ => Enable::Yes, }, diff --git a/crates/app/src/transform_ui.rs b/crates/app/src/transform_ui.rs index 60dddaf..6c56e72 100644 --- a/crates/app/src/transform_ui.rs +++ b/crates/app/src/transform_ui.rs @@ -51,7 +51,10 @@ pub(crate) fn transform_snap(band: usize, value: f32) -> f32 { if band == ROTATE_BAND { let span = high - low + ROTATE_STEP; // one turn: 0..360 let wrapped = (value - low).rem_euclid(span); - low + (wrapped / ROTATE_STEP).round() * ROTATE_STEP + // The round can land exactly on `span` (315 rounds up to the 360 that + // never appears in the range) which needs one more wrap back to 0, + // not a clamp to a fourth stop past 270 -- `ROTATE_BAND`'s reason. + low + ((wrapped / ROTATE_STEP).round() * ROTATE_STEP).rem_euclid(span) } else { ((value / TRANSFORM_STEP).round() * TRANSFORM_STEP).clamp(low, high) } @@ -91,8 +94,9 @@ mod tests { assert_eq!(transform_snap(ROTATE_BAND, 46.0), 90.0); assert_eq!(transform_snap(ROTATE_BAND, 270.0), 270.0); // Past the last stop wraps back to the first, not clamps to the last. + // -45 is the same angle as 315 mod 360, so it lands on the same stop. assert_eq!(transform_snap(ROTATE_BAND, 315.0), 0.0); - assert_eq!(transform_snap(ROTATE_BAND, -45.0), 270.0); + assert_eq!(transform_snap(ROTATE_BAND, -45.0), 0.0); } #[test] diff --git a/crates/app/src/ui/inspector.rs b/crates/app/src/ui/inspector.rs index 2717ef1..382c170 100644 --- a/crates/app/src/ui/inspector.rs +++ b/crates/app/src/ui/inspector.rs @@ -211,6 +211,16 @@ impl Player { ActionId::Color, cx.listener(|this, _: &ClickEvent, _, cx| this.open_color(cx)), )) + .child(self.action_control( + "inspect-transform", + 0., + BG_RAISED(), + None, + "Transform", + "position, scale, rotation and crop for this clip", + ActionId::Transform, + cx.listener(|this, _: &ClickEvent, _, cx| this.open_transform(cx)), + )) .child(self.action_control( "inspect-eq", 0.,