Put Cut All Automation on the clipboard.
The command cleared every automation lane in the selection and left the clipboard empty, so the cut could not be pasted. It now uses the same copy-and-clear path as Cut Pan Automation.
This commit is contained in:
parent
522e59f8f5
commit
9ef16e1e6c
|
|
@ -25,7 +25,9 @@ pub fn specs() -> Vec<CommandSpec> {
|
|||
p,
|
||||
"edit.clear_clip_gain"
|
||||
)),
|
||||
cmd!("edit.cut_all_automation", "All Automation", ["Edit", "Cut Special"], None, "{}", has_range, |e, p| clear_automation(e, p, None)),
|
||||
cmd!("edit.cut_all_automation", "All Automation", ["Edit", "Cut Special"], None, "{tracks?, start?, end?}", has_range, |e, p| {
|
||||
super::edit_more::cut_all_automation(e, p)
|
||||
}),
|
||||
cmd!("edit.clear_all_automation", "All Automation", ["Edit", "Clear Special"], None, "{}", has_range, |e, p| clear_automation(e, p, None)),
|
||||
cmd!("edit.clear_pan_automation", "Pan Automation", ["Edit", "Clear Special"], None, "{}", has_range, |e, p| clear_automation(
|
||||
e,
|
||||
|
|
|
|||
|
|
@ -277,6 +277,10 @@ fn nonempty_range(e: &Engine, p: &Value, id: &str) -> Result<Range> {
|
|||
if r.is_empty() { Err(bad(id, "the selection is empty")) } else { Ok(r) }
|
||||
}
|
||||
|
||||
pub(super) fn cut_all_automation(e: &mut Engine, p: &Value) -> Result<Value> {
|
||||
auto_copy(e, p, Lanes::All, true, "edit.cut_all_automation")
|
||||
}
|
||||
|
||||
fn auto_copy(e: &mut Engine, p: &Value, which: Lanes, cut: bool, id: &str) -> Result<Value> {
|
||||
let tracks = tracks_required(e, id, p)?;
|
||||
let r = nonempty_range(e, p, id)?;
|
||||
|
|
@ -982,6 +986,21 @@ mod tests {
|
|||
assert_eq!(starts(&e, t), vec![0, 900, 1000]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cut_all_automation_can_be_pasted() {
|
||||
let (mut e, t, _) = session_with_clips(&[(0, 1000)]);
|
||||
e.execute("automation.set_point", &json!({"track": t.0, "param": "volume", "at": 100, "value": -6.0})).unwrap();
|
||||
e.execute("automation.set_point", &json!({"track": t.0, "param": "volume", "at": 400, "value": -12.0})).unwrap();
|
||||
let cut = e.execute("edit.cut_all_automation", &json!({"start": 50, "end": 250})).unwrap();
|
||||
assert!(cut["lanes"].as_u64().unwrap() >= 1, "{cut}");
|
||||
assert!(e.clipboard.automation.iter().any(|lanes| !lanes.is_empty()));
|
||||
let lane = e.session().track(t).unwrap().lane(&AutoParam::Volume).unwrap().clone();
|
||||
assert!(lane.points.iter().all(|p| p.at != 100), "the cut point is gone: {:?}", lane.points);
|
||||
e.execute("edit.paste_to_current_automation", &json!({"at": 1000})).unwrap();
|
||||
let vol = e.session().track(t).unwrap().lane(&AutoParam::Volume).unwrap().clone();
|
||||
assert!(vol.points.iter().any(|p| p.at >= 1000 && (p.value + 6.0).abs() < 1e-2), "paste wrote nothing at -6 dB: {:?}", vol.points);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copy_and_paste_automation_only() {
|
||||
let (mut e, t, _) = session_with_clips(&[(0, 1000)]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue