Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Keyboard Shortcuts: Assign takes a held shortcut in one step (craft-libs#352)

aionggada39e78d7f9
diff --git a/Cargo.lock b/Cargo.lock
index 9aafb65e8..f8a1bf7f0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1001,7 +1001,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"rustix 1.1.5",
]
@@ -1009,7 +1009,7 @@ dependencies = [
[[package]]
name = "craft-cms"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"rayon",
]
@@ -1017,12 +1017,12 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
[[package]]
name = "craft-i18n"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"fixed_decimal",
"icu_decimal",
@@ -1045,7 +1045,7 @@ dependencies = [
[[package]]
name = "craft-keymap"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"craft-i18n",
"craft-ui",
@@ -1057,7 +1057,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"bytemuck",
"hayro",
@@ -1070,11 +1070,11 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"craft-winprint-gdi",
- "miniz_oxide 0.8.9",
- "roxmltree 0.20.0",
+ "miniz_oxide 0.9.1",
+ "roxmltree 0.21.2",
"tempfile",
"winprint",
"winsafe",
@@ -1083,7 +1083,7 @@ dependencies = [
[[package]]
name = "craft-ui"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"egui",
"log",
@@ -1096,7 +1096,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"chrono",
"dunce",
@@ -1121,7 +1121,7 @@ dependencies = [
[[package]]
name = "craft-window"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"egui",
"objc2 0.6.5",
@@ -2602,7 +2602,7 @@ dependencies = [
[[package]]
name = "hayro"
version = "0.7.1"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"bytemuck",
"hayro-interpret",
@@ -2622,7 +2622,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
[[package]]
name = "hayro-cmap"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"brotli",
"hayro-postscript",
@@ -2631,7 +2631,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -2649,7 +2649,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -2667,12 +2667,12 @@ dependencies = [
[[package]]
name = "hayro-postscript"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"flate2",
"hayro-ccitt",
@@ -3267,7 +3267,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.8.2"
-source = "git+https://github.com/storytold/craft-libs?rev=495e5971bc024aa96e6ed318cb6e7cd3a0103184#495e5971bc024aa96e6ed318cb6e7cd3a0103184"
+source = "git+https://github.com/storytold/craft-libs?rev=1deaba523eaf9388750e7a07e3253e7ee7568c32#1deaba523eaf9388750e7a07e3253e7ee7568c32"
dependencies = [
"base64 0.22.1",
"bumpalo",
diff --git a/Cargo.toml b/Cargo.toml
index 52489ff20..4b2941fb0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,10 +12,10 @@ repository = "https://github.com/storytold/designcraft"
[workspace.dependencies]
# Shared reader and writer; publish the immutable revision before this consumer.
-craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.1.0", default-features = false }
+craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.1.0", default-features = false }
# Shared keyboard bindings: chords, overrides, conflicts, egui dispatch, the Keyboard Shortcuts dialog.
-craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.1.0", features = ["egui", "ui"] }
-craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", features = ["egui"] }
+craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.1.0", features = ["egui", "ui"] }
+craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", features = ["egui"] }
# internal
designcraft-geom = { path = "crates/geom" }
designcraft-color = { path = "crates/color" }
@@ -78,20 +78,20 @@ zip = { version = "3", default-features = false, features = ["deflate"] }
indd = { git = "https://github.com/storytold/indd-utils", branch = "main" }
# Which paths stored in documents may be followed (craft-libs).
-craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184" }
+craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32" }
# Atomic file replacement for saves and exports (craft-libs).
-craft-atomic = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184" }
+craft-atomic = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32" }
# File › Print through the system print spooler (craft-libs).
-craft-print = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184" }
+craft-print = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32" }
# ICC colour management: working spaces, transforms, black point compensation (craft-libs).
-craft-cms = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184" }
+craft-cms = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32" }
# ui
# Shared frontend components; keep this dependency above the engine boundary.
-craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", features = ["serde"] }
+craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", features = ["serde"] }
# The application bar as the window's title bar (craft-libs).
-craft-window = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", features = ["egui"] }
+craft-window = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", features = ["egui"] }
egui = "0.37"
egui_extras = { version = "0.37", default-features = false, features = ["svg"] }
eframe = { version = "0.37", default-features = false }
@@ -129,14 +129,14 @@ debug = 0
# Opt-in cancelable macOS termination on the pinned winit 0.30 line.
[patch.crates-io]
-krilla = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.8.2" }
+krilla = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.8.2" }
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
-hayro = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.7.1" }
-hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.7.0" }
-hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.7.2" }
-hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.3.0" }
-hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.1.0" }
-hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "495e5971bc024aa96e6ed318cb6e7cd3a0103184", version = "=0.1.0" }
+hayro = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.7.1" }
+hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.7.0" }
+hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.7.2" }
+hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.3.0" }
+hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.1.0" }
+hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "1deaba523eaf9388750e7a07e3253e7ee7568c32", version = "=0.1.0" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
diff --git a/crates/ui-egui/src/shortcuts_dialog.rs b/crates/ui-egui/src/shortcuts_dialog.rs
index 531c6ba69..797b0cb71 100644
--- a/crates/ui-egui/src/shortcuts_dialog.rs
+++ b/crates/ui-egui/src/shortcuts_dialog.rs
@@ -357,6 +357,28 @@ mod tests {
assert_eq!(shortcut_of(h.state(), "app.palette").as_deref(), Some("Cmd+K"));
}
+ #[test]
+ fn assign_takes_a_held_shortcut_in_one_step_for_the_menus_and_the_keys() {
+ let mut app = app();
+ super::open(&mut app, Some(&CommandRef::new("app.paragraphStylesPanel")));
+ let mut h = harness(app);
+ click(&mut h, "New shortcut: None");
+ press(&mut h, Modifiers::COMMAND, Key::P);
+ assert!(has(&h, "⚠ Print…"), "Print is listed as holding the chord");
+ click(&mut h, "Assign");
+ click(&mut h, "OK");
+ assert!(!open(&h));
+ let app = h.state();
+ assert_eq!(shortcut_of(app, "file.print"), None, "the menus no longer show it on Print");
+ let bindings: Vec<String> = app.keymap.bindings(&CommandRef::new("app.paragraphStylesPanel")).iter().map(|b| b.trigger.to_string()).collect();
+ assert_eq!(bindings, ["Cmd+F11", "Cmd+P"]);
+ // The macOS menu bar holds Paragraph Styles' first shortcut; its new one runs in the app.
+ h.state_mut().native_shortcuts = [("app.paragraphStylesPanel".to_string(), "Cmd+F11".to_string())].into();
+ assert!(!crate::panel_docking::showing(h.state(), "paragraphStyles"));
+ press(&mut h, Modifiers::COMMAND, Key::P);
+ assert!(crate::panel_docking::showing(h.state(), "paragraphStyles"), "Cmd+P opens Paragraph Styles");
+ }
+
#[test]
fn cancel_puts_the_keys_and_the_sets_back() {
let mut h = opened();
diff --git a/docs/pdf-backend.md b/docs/pdf-backend.md
index 0bcd7992c..d53625fbd 100644
--- a/docs/pdf-backend.md
+++ b/docs/pdf-backend.md
@@ -1,7 +1,7 @@
# Shared PDF backend
DesignCraft pins `craft-pdf`, patched Krilla 0.8.2 and the six Hayro reader crates (with
-`hayro-cmap` and `hayro-postscript`) to craft-libs revision `495e5971bc024aa96e6ed318cb6e7cd3a0103184`. `craft-ui`,
+`hayro-cmap` and `hayro-postscript`) to craft-libs revision `1deaba523eaf9388750e7a07e3253e7ee7568c32`. `craft-ui`,
`craft-print` and the other craft-libs crates are pinned to the same revision. The reader migration is reviewed on top of the separate writer change.
## Writing
diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs
index c222bbe10..39d325a8e 100644
--- a/xtask/src/pdf_deps.rs
+++ b/xtask/src/pdf_deps.rs
@@ -4,7 +4,7 @@ use std::process::Command;
use serde_json::Value;
-const REV: &str = "495e5971bc024aa96e6ed318cb6e7cd3a0103184";
+const REV: &str = "1deaba523eaf9388750e7a07e3253e7ee7568c32";
const PACKAGES: &[(&str, &str)] = &[
("craft-pdf", "0.1.0"),
("krilla", "0.8.2"),