mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
Merge pull request #10033 from dotCooCoo/fix/shortcuts-tools-tab
Keyboard Shortcuts: the Tools tab lists only the Tools panel's tools
This commit is contained in:
1 file changed
+28
-1
@@ -1134,6 +1134,12 @@ fn is_tool(def: &CommandDef) -> bool {
|
||||
matches!(def.kind, CommandKind::Tool { .. })
|
||||
}
|
||||
|
||||
/// A tool of the Tools panel: a tool in the app's scope. The tools of a workspace's own dialog
|
||||
/// (Content-Aware Fill, Liquify, Select and Mask, Vanishing Point and others) are scoped to that dialog, and neither tab lists them.
|
||||
fn is_app_tool(def: &CommandDef) -> bool {
|
||||
is_tool(def) && def.scope.is_app()
|
||||
}
|
||||
|
||||
/// The app's rule for the keys a command takes: a tool's shortcut is one key, alone or with Shift,
|
||||
/// or the tool's own default (the Quick Pen's Alt+P).
|
||||
fn accept(def: &CommandDef, binding: &Binding) -> Result<(), String> {
|
||||
@@ -1153,7 +1159,7 @@ fn options() -> Options {
|
||||
Options::default().with(|o| {
|
||||
o.area_tabs = true;
|
||||
o.own_areas = true;
|
||||
o.areas = vec![Area::new("tools", "Tools", is_tool), Area::new("menu", MENU_COMMANDS, |def| !is_tool(def))];
|
||||
o.areas = vec![Area::new("tools", "Tools", is_app_tool), Area::new("menu", MENU_COMMANDS, |def| !is_tool(def))];
|
||||
o.summary = false;
|
||||
o.accept = Some(Box::new(accept));
|
||||
o.import_formats = vec![Format::new("kys", "Shortcut set", &["kys"]), Format::new("json", "VectorCraft shortcut set", &["json"])];
|
||||
@@ -2287,6 +2293,27 @@ mod tests {
|
||||
assert_eq!(labels, ["Tools", "Menu Commands"]);
|
||||
}
|
||||
|
||||
/// The Tools tab lists the Tools panel's tools, each once, and none of the tools scoped to a workspace's dialog,
|
||||
/// which the window's keymap also holds.
|
||||
#[test]
|
||||
fn the_tools_tab_lists_only_the_apps_tools() {
|
||||
let (mut app, ctx) = app();
|
||||
open(&mut app);
|
||||
dialog_pass(&mut app, &ctx);
|
||||
dialog_pass(&mut app, &ctx);
|
||||
let keymap = app.shortcuts_dialog.as_ref().and_then(|d| d.keymap.as_ref()).expect("the dialog's keymap");
|
||||
let options = options();
|
||||
let tools = options.areas.iter().find(|a| a.id == "tools").expect("the Tools area");
|
||||
assert!(
|
||||
keymap.catalog().iter().any(|d| is_tool(d) && !d.scope.is_app()),
|
||||
"the window's keymap holds tools of a dialog's scope, which the Tools tab must leave out"
|
||||
);
|
||||
let listed: Vec<String> = keymap.catalog().iter().filter(|d| (tools.rows)(d)).map(|d| d.command.key()).collect();
|
||||
let want: Vec<String> = entries().iter().filter(|e| e.is_tool).map(|e| command_of(&e.key).key()).collect();
|
||||
assert_eq!(listed.iter().collect::<HashSet<_>>(), want.iter().collect::<HashSet<_>>());
|
||||
assert_eq!(listed.len(), want.len(), "each tool is listed once");
|
||||
}
|
||||
|
||||
/// An open dialog lists a live-effect plug-in installed while it is open, with the shortcut its
|
||||
/// set gives it, and drops the row while the plug-in is removed, keeping that shortcut in the
|
||||
/// set.
|
||||
|
||||
Reference in new issue
Block a user