mirror of
https://github.com/storytold/soundcraft.git
synced 2026-11-09 20:04:53 +00:00
Merge pull request #1007 from Audiosyncrasy/smart-tool-shortcuts
Edit tools: F6+F7 / F7+F8 and Cmd/Ctrl+7 select the Smart Tool; Cmd/Ctrl+6 selects the Pencil
This commit is contained in:
4 files changed
+59
-10
No files matched your search
@@ -165,7 +165,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
always,
|
||||
shuffle_lock
|
||||
),
|
||||
cmd!(noundo "edit.tool", "Edit Tool", [], Some("F5-F10"), "{tool: zoom|trim|selector|grabber|scrubber|pencil|smart}", always, |e, p| {
|
||||
cmd!(noundo "edit.tool", "Edit Tool", [], Some("F5-F10, F6+F7, F7+F8, Cmd+6-7"), "{tool: zoom|trim|selector|grabber|scrubber|pencil|smart}", always, |e, p| {
|
||||
let t = str_param(p, "tool").and_then(soundcraft_model::Tool::from_id).ok_or_else(|| bad("edit.tool", "unknown tool"))?;
|
||||
e.session_mut().edit.tool = t;
|
||||
Ok(json!({"tool": t}))
|
||||
|
||||
@@ -179,14 +179,13 @@ fn fixed(app: &mut SoundApp, key: Key, m: Modifiers, mac: bool) -> bool {
|
||||
true
|
||||
}
|
||||
Key::F5 | Key::F6 | Key::F7 | Key::F8 | Key::F9 | Key::F10 if plain => {
|
||||
let tool = match key {
|
||||
Key::F5 => "zoom",
|
||||
Key::F6 => "trim",
|
||||
Key::F7 => "selector",
|
||||
Key::F8 => "grabber",
|
||||
Key::F9 => "scrubber",
|
||||
_ => "pencil",
|
||||
};
|
||||
let _ = app.run("edit.tool", json!({"tool": tool_key(app, key)}));
|
||||
true
|
||||
}
|
||||
// Cmd+6 / Cmd+7 (Ctrl off macOS) are Pencil and the Smart Tool. Cmd+1–5 keep their window and Session
|
||||
// keys: egui reports the numeric keypad's digits as the main keyboard's, so the two can't be told apart.
|
||||
Key::Num6 | Key::Num7 if mods_match(Modifiers::COMMAND, m, mac) => {
|
||||
let tool = if key == Key::Num6 { "pencil" } else { "smart" };
|
||||
let _ = app.run("edit.tool", json!({"tool": tool}));
|
||||
true
|
||||
}
|
||||
@@ -314,6 +313,22 @@ fn edit_mode_key(app: &mut SoundApp, pressed: Key) {
|
||||
let _ = app.run("edit.mode", json!({"mode": mode, "snap_to_grid": snap}));
|
||||
}
|
||||
|
||||
/// F5–F10 choose the Edit tools; F7 with F6 or F8 held, in either order, chooses the Smart Tool.
|
||||
fn tool_key(app: &SoundApp, pressed: Key) -> &'static str {
|
||||
let ctx = app.docking_context.as_ref();
|
||||
let held = |k: Key| ctx.is_some_and(|c| c.input(|i| i.key_down(k)));
|
||||
match pressed {
|
||||
Key::F6 | Key::F8 if held(Key::F7) => "smart",
|
||||
Key::F7 if held(Key::F6) || held(Key::F8) => "smart",
|
||||
Key::F5 => "zoom",
|
||||
Key::F6 => "trim",
|
||||
Key::F7 => "selector",
|
||||
Key::F8 => "grabber",
|
||||
Key::F9 => "scrubber",
|
||||
_ => "pencil",
|
||||
}
|
||||
}
|
||||
|
||||
/// What choosing Grid picks: in Grid the other Grid mode, from another mode the one used last.
|
||||
pub(crate) fn grid_mode(app: &SoundApp) -> &'static str {
|
||||
use soundcraft_model::EditMode;
|
||||
|
||||
@@ -281,6 +281,24 @@ fn shuffle_drags_leave_locked_clips_in_the_selection_out_of_it() {
|
||||
assert_eq!(starts(&app, &ids), vec![0, SEC]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f6_f7_and_f7_f8_in_either_order_choose_the_smart_tool() {
|
||||
let (mut app, ctx, _, _) = app("slip", "grabber", &[]);
|
||||
let tool = |app: &SoundApp| app.engine.session().edit.tool.id();
|
||||
for (first, second) in [(Key::F6, Key::F7), (Key::F7, Key::F6), (Key::F7, Key::F8), (Key::F8, Key::F7)] {
|
||||
frame(&ctx, &mut app, key(Key::F5));
|
||||
frame(&ctx, &mut app, vec![key_event(first, true, Modifiers::NONE)]);
|
||||
frame(&ctx, &mut app, key(second));
|
||||
frame(&ctx, &mut app, vec![key_event(first, false, Modifiers::NONE)]);
|
||||
assert_eq!(tool(&app), "smart", "{first:?}+{second:?}");
|
||||
}
|
||||
let alone = [(Key::F5, "zoom"), (Key::F6, "trim"), (Key::F7, "selector"), (Key::F8, "grabber"), (Key::F9, "scrubber"), (Key::F10, "pencil")];
|
||||
for (k, want) in alone {
|
||||
frame(&ctx, &mut app, key(k));
|
||||
assert_eq!(tool(&app), want, "{k:?} alone");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f4_pressed_before_f1_leaves_the_kind_of_grid_alone() {
|
||||
let (mut app, ctx, _, _) = app("grid", "grabber", &[]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Pro Tools keys for commands that had none: Grid and Nudge values, Commands Focus nudging and selection
|
||||
//! keys, playlists, F12, Ctrl+Tab off macOS and the window keys.
|
||||
//! keys, playlists, F12, Ctrl+Tab off macOS, the window keys and the Cmd+6/7 tool keys.
|
||||
|
||||
use egui::os::OperatingSystem;
|
||||
use egui::{Event, Key, Modifiers, Pos2, RawInput, Rect, vec2};
|
||||
@@ -299,3 +299,19 @@ fn shift_tab_extends_the_selection_and_tab_to_transient_stops_on_hits() {
|
||||
assert_eq!(start(&app), clip.start, "{os:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_6_and_7_choose_the_pencil_and_the_smart_tool() {
|
||||
for (os, cmd) in OSES {
|
||||
let (ctx, mut app) = rig(os);
|
||||
app.run("edit.tool", json!({"tool": "grabber"})).unwrap();
|
||||
press(&ctx, &mut app, Key::Num6, cmd);
|
||||
assert_eq!(app.engine.session().edit.tool.id(), "pencil", "{os:?}");
|
||||
if os == OperatingSystem::Mac {
|
||||
press(&ctx, &mut app, Key::Num7, Modifiers::CTRL);
|
||||
assert_eq!(app.engine.session().edit.tool.id(), "pencil", "the Mac's Control+7 is not Cmd+7");
|
||||
}
|
||||
press(&ctx, &mut app, Key::Num7, cmd);
|
||||
assert_eq!(app.engine.session().edit.tool.id(), "smart", "{os:?}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user