Skip to content

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

Merge designcraft#1810 (egui 0.37) into docking-trial; pin craft-libs to main a0916808

aiongg1da1f7028b41
diff --cc Cargo.lock
index 3849c0ab4,19899a2f7..e278722b7
--- a/Cargo.lock
+++ b/Cargo.lock
@@@ -954,7 -950,7 +950,7 @@@ dependencies =
[[package]]
name = "craft-atomic"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=e9546e191dd62f2bc1d61eca45dbdc2f1b3c1d8e#e9546e191dd62f2bc1d61eca45dbdc2f1b3c1d8e"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"rustix 1.1.5",
]
@@@ -962,7 -958,7 +958,7 @@@
[[package]]
name = "craft-cms"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=e9546e191dd62f2bc1d61eca45dbdc2f1b3c1d8e#e9546e191dd62f2bc1d61eca45dbdc2f1b3c1d8e"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"rayon",
]
@@@ -970,12 -966,12 +966,12 @@@
[[package]]
name = "craft-docpath"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=82a24b006eefa036b43c09a67fb9a3fbd17ffe63#82a24b006eefa036b43c09a67fb9a3fbd17ffe63"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
[[package]]
name = "craft-pdf"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"bytemuck",
"hayro",
@@@ -988,7 -984,7 +984,7 @@@
[[package]]
name = "craft-print"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=25da1314d443171b4adeaad2cd9454b273f35c6f#25da1314d443171b4adeaad2cd9454b273f35c6f"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"craft-winprint-gdi",
"miniz_oxide 0.8.9",
@@@ -1001,27 -997,12 +997,27 @@@
[[package]]
name = "craft-ui"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=25da1314d443171b4adeaad2cd9454b273f35c6f#25da1314d443171b4adeaad2cd9454b273f35c6f"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"egui",
+ "log",
+ "objc2 0.6.4",
+ "objc2-app-kit 0.3.2",
+ "objc2-foundation 0.3.2",
"serde",
]
+[[package]]
+name = "craft-window"
+version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
+dependencies = [
+ "egui",
+ "objc2 0.6.4",
+ "objc2-app-kit 0.3.2",
+ "wayland-client",
+]
+
[[package]]
name = "craft-winprint-gdi"
version = "0.1.0"
@@@ -2471,7 -2454,7 +2471,7 @@@ dependencies =
[[package]]
name = "hayro"
version = "0.7.1"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"bytemuck",
"hayro-interpret",
@@@ -2491,7 -2474,7 +2491,7 @@@ checksum = "9f4d0e94ddd48749f06bbe4e538
[[package]]
name = "hayro-cmap"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"brotli",
"hayro-postscript",
@@@ -2500,7 -2483,7 +2500,7 @@@
[[package]]
name = "hayro-interpret"
version = "0.7.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@@ -2518,7 -2501,7 +2518,7 @@@
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@@ -2536,12 -2519,13 +2536,12 @@@ dependencies =
[[package]]
name = "hayro-postscript"
version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "885c5ef0654933139a9b9546fc2c69e18d37f38aa2520f079092b1be18f1fcaa"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"flate2",
"hayro-ccitt",
@@@ -3042,7 -3026,7 +3042,7 @@@ dependencies =
[[package]]
name = "krilla"
version = "0.8.2"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
-source = "git+https://github.com/storytold/craft-libs?rev=9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef#9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
dependencies = [
"base64 0.22.1",
"bumpalo",
diff --cc Cargo.toml
index e91821350,4819a9b9e..afa0d7be9
--- a/Cargo.toml
+++ b/Cargo.toml
@@@ -12,7 -12,7 +12,7 @@@ repository = "https://github.com/storyt
[workspace.dependencies]
# Shared reader and writer; publish the immutable revision before this consumer.
- craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.1.0", default-features = false }
-craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.1.0", default-features = false }
++craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.1.0", default-features = false }
# internal
designcraft-geom = { path = "crates/geom" }
designcraft-color = { path = "crates/color" }
@@@ -75,24 -75,24 +75,26 @@@ zip = { version = "3", default-feature
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 = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5" }
-craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "82a24b006eefa036b43c09a67fb9a3fbd17ffe63" }
++craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f" }
# Atomic file replacement for saves and exports (craft-libs).
- craft-atomic = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5" }
-craft-atomic = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "e9546e191dd62f2bc1d61eca45dbdc2f1b3c1d8e" }
++craft-atomic = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f" }
# File › Print through the system print spooler (craft-libs).
- craft-print = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5" }
-craft-print = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "25da1314d443171b4adeaad2cd9454b273f35c6f" }
++craft-print = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f" }
# 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 = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5" }
-craft-cms = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "e9546e191dd62f2bc1d61eca45dbdc2f1b3c1d8e" }
++craft-cms = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f" }
# 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 = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", features = ["serde"] }
-craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "25da1314d443171b4adeaad2cd9454b273f35c6f", features = ["serde"] }
++craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", 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 = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", features = ["egui"] }
- egui = "0.36"
- egui_extras = { version = "0.36", default-features = false, features = ["svg"] }
- eframe = { version = "0.36", default-features = false }
- egui_kittest = "0.36"
++craft-window = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", features = ["egui"] }
+ egui = "0.37"
+ egui_extras = { version = "0.37", default-features = false, features = ["svg"] }
+ eframe = { version = "0.37", default-features = false }
+ egui_kittest = "0.37"
+ # Monotonic clock on native and web (`Instant`); screenshot settlement must not use wall time.
+ web-time = "1"
rfd = "0.17"
arboard = { version = "3.6", default-features = false }
@@@ -124,11 -124,24 +126,25 @@@ debug =
# Opt-in cancelable macOS termination on the pinned winit 0.30 line.
[patch.crates-io]
- krilla = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.8.2" }
- winit = { git = "https://github.com/storytold/winit.git", rev = "3d51077fd1a966f84df9ef287839dc84fd5b4ca7" }
- hayro = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.7.1" }
- hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.7.0" }
- hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.7.2" }
- hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.3.0" }
- hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.1.0" }
- hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", version = "=0.1.0" }
-krilla = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.8.2" }
++krilla = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.8.2" }
+ winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
-hayro = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.7.1" }
-hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.7.0" }
-hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.7.2" }
-hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.3.0" }
-hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef", version = "=0.1.0" }
++hayro = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.7.1" }
++hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.7.0" }
++hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.7.2" }
++hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.3.0" }
++hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", version = "=0.1.0" }
++hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", 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" }
+ epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui-winit = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui_glow = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui_extras = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+ egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
diff --cc crates/ui-egui/src/canvas.rs
index ae7d8c910,8d3e4af8b..fc614ab30
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@@ -727,18 -741,13 +744,23 @@@ pub fn show(app: &mut DesignApp, ui: &m
ui.ctx().set_cursor_icon(icon);
draw_cursor_badge(&painter, p, c, &t);
}
+ // A second viewport has no panels, dialogs or Quick Apply after its canvas: observe here,
+ // once, as the end of its pass. The root viewport observes at the end of `DesignApp::ui`.
+ if ui.ctx().viewport_id() != egui::ViewportId::ROOT {
+ ime_observe(app, ui.ctx());
+ }
}
+/// Whether the pointer this canvas's window last saw is in another of the app's windows: a
+/// floating panel's OS window, or the other window of New Window.
+fn pointer_elsewhere(app: &DesignApp, ctx: &egui::Context) -> bool {
+ let mut others = crate::panel_docking::native_viewports(app, ctx);
+ if app.second_window && !ctx.embed_viewports() {
+ others.extend([egui::ViewportId::ROOT, crate::second_window_viewport()]);
+ }
+ crate::cursors::pointer_elsewhere(ctx, &others)
+}
+
/// The loaded text cursor's badge beside the system cursor: lines of text, a closed chain
/// (a click threads) or a broken one (a click unthreads). Drawn in code.
fn draw_cursor_badge(painter: &egui::Painter, p: Pos2, c: Cursor, t: &Tokens) {
diff --cc crates/ui-egui/src/cursors.rs
index 2e3f64252,96cf7a116..3487a2673
--- a/crates/ui-egui/src/cursors.rs
+++ b/crates/ui-egui/src/cursors.rs
@@@ -343,49 -338,6 +343,49 @@@ pub fn show(ctx: &egui::Context, images
}
}
+/// Whether the pointer this viewport last saw has moved on to another of the app's windows,
+/// `others` (the current viewport among them is skipped): from the frame one of them reports the
+/// pointer until this viewport gets a pointer event again. That covers the pointer moving on from
+/// the other window to the desktop too, where this one still hears nothing. Always false where
+/// egui embeds viewports, so all of them share one window's pointer.
+pub(crate) fn pointer_elsewhere(ctx: &egui::Context, others: &[egui::ViewportId]) -> bool {
+ let own = ctx.viewport_id();
- let key = egui::Id::new(("pointer-elsewhere", own));
++ let key = egui::Id::unique(("pointer-elsewhere", own));
+ let before = ctx.data(|d| d.get_temp::<bool>(key)).unwrap_or(false);
+ let here = ctx
+ .input(|i| i.events.iter().any(|e| matches!(e, egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } | egui::Event::PointerGone)));
+ // A pointer that arrived: moving or pressing there. A pointer that only stayed (a hidden
+ // window keeps its last one) does not count, so it never takes the pointer from this window.
+ let arrived = |i: &egui::InputState| {
+ i.pointer.has_pointer() && i.events.iter().any(|e| matches!(e, egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. }))
+ };
+ let separate = !ctx.embed_viewports() && others.iter().any(|&v| v != own);
+ // Where this window has pointer events of its own too, another window's report counts only
+ // if this window's pointer lies inside that window: one just outside it (its edge, where
+ // both may hear the pointer) keeps belonging here, frame after frame.
+ let at = ctx.input(|i| i.viewport().inner_rect.zip(i.pointer.latest_pos()).map(|(r, p)| r.min + p.to_vec2()));
+ let there = separate && others.iter().any(|&v| v != own && ctx.input_for(v, |i| arrived(i) && (!here || covers(i.viewport().inner_rect, at))));
+ let now = separate && elsewhere(before, here, there);
+ if now != before {
+ ctx.data_mut(|d| d.insert_temp(key, now));
+ }
+ now
+}
+
+/// Whether a window at `rect` (desktop points) lies over the desktop point `at`; unknown when
+/// either is, which counts as covering.
+fn covers(rect: Option<egui::Rect>, at: Option<egui::Pos2>) -> bool {
+ rect.zip(at).is_none_or(|(r, p)| r.contains(p))
+}
+
+/// [`pointer_elsewhere`] for one frame: whether the pointer belonged to another window `before`,
+/// whether this window got a pointer event (`here`) and whether another window reports the
+/// pointer arriving (`there`). Both in one frame mean the pointer just crossed into the other
+/// window: this window's last events come from before the crossing.
+fn elsewhere(before: bool, here: bool, there: bool) -> bool {
+ there || (before && !here)
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --cc crates/ui-egui/src/dock.rs
index eed3fb9b3,aa8428469..7e2eb3d6c
--- a/crates/ui-egui/src/dock.rs
+++ b/crates/ui-egui/src/dock.rs
@@@ -135,9 -355,11 +135,9 @@@ pub fn float_only_windows(app: &mut Des
continue;
}
let label = crate::i18n::tr(&app.ui.language, panel_label(&id)).to_owned();
- let docks = !float_only(&id);
let mut open = true;
- let mut dock = false;
let mut w = egui::Window::new(label.clone())
- .id(egui::Id::new(("floating_panel", &id)))
+ .id(egui::Id::unique(("floating_panel", &id)))
.title_bar(false)
.default_pos(egui::pos2(at[0], at[1]))
.default_width(if id == "tabs" { 560.0 } else { 256.0 })
diff --cc crates/ui-egui/src/lib.rs
index b6a68c456,0141e16a4..73ac8f06c
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@@ -1476,18 -1597,6 +1673,18 @@@ impl DesignApp
self.open_dropped_at(path, None)
}
- /// Open or place each file dropped on the main window or on a floating panel's own window.
- /// `pointer` is in the main window's coordinates.
++ /// Open or place each file dropped on a floating panel's own window. `pointer` is in the main
++ /// window's coordinates.
+ #[cfg(not(target_arch = "wasm32"))]
+ pub(crate) fn open_dropped_files(&mut self, files: &[egui::DroppedFileHandle], pointer: Option<egui::Pos2>) {
+ for f in files {
+ let p = f.path().to_string_lossy().to_string();
+ if !p.is_empty() {
+ let _ = self.open_dropped_at(&p, pointer);
+ }
+ }
+ }
+
/// [`Self::open_dropped`] at the pointer: a graphic's top left lands where the file was
/// dropped on the canvas, text goes to a new frame on the document page there.
pub fn open_dropped_at(&mut self, path: &str, pointer: Option<egui::Pos2>) -> Result<Value, String> {
@@@ -1617,74 -1777,125 +1865,182 @@@
egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } => 1,
_ => events.iter().position(|e| matches!(e, egui::Event::Key { pressed: false, .. })).map_or(events.len(), |i| i + 1),
};
- if let egui::Event::PointerMoved(p) | egui::Event::PointerButton { pos: p, .. } = first {
- raw.events.push(egui::Event::PointerMoved(*p));
+ let batch: Vec<egui::Event> = events.drain(..n).collect();
+ self.injected_generation = self.input_generation();
+ self.injected_private = private;
+ self.injected_events = batch.clone();
+ self.injected_pending.store(true, std::sync::atomic::Ordering::Relaxed);
+ raw.events.extend(batch);
+ // Held until a settled UI pass runs with the fonts installed; a hidden logic tick, a
+ // discarded multipass first pass or a font-gated early return must not acknowledge it.
+ self.synthetic_injected = true;
+ }
+
+ /// Notify after enqueuing a native menu event, before waking the host. The returned callback
+ /// owns its state so the event handler never borrows the app.
+ pub fn native_action_notifier(&self, ctx: egui::Context) -> Box<dyn Fn() + Send + Sync> {
+ let pending = self.native_events_pending.clone();
+ Box::new(move || {
+ pending.store(true, std::sync::atomic::Ordering::Release);
+ ctx.request_repaint();
+ })
+ }
+
+ /// Poll from the first real UI pass, under the host's normal UI/watchdog guard. Resolve menu
+ /// choices before refreshing their IDs, then execute them once synthetic input has settled.
+ /// Event arrival already blocks logic deliveries, so a deferred action keeps its ordering
+ /// without executing native dialogs or menu commands from a hidden logic-only tick.
+ pub fn poll_native_actions(&mut self, ctx: &egui::Context, mut next: impl FnMut() -> Option<(String, Value)>) {
+ // Clear before draining: a notification arriving during the drain stays set for the
+ // next pass, even when its channel send races the final empty receive.
+ self.native_events_pending.swap(false, std::sync::atomic::Ordering::AcqRel);
+ while let Some((id, params)) = next() {
+ self.native_actions.push_back((id, params));
+ }
+ self.apply_native_actions(ctx);
+ }
+
+ fn synthetic_input_pending(&self) -> bool {
+ self.synthetic_injected || !self.control_synthetic.is_empty() || !self.synthetic.is_empty()
+ }
+
+ fn host_order_pending(&self) -> bool {
+ self.synthetic_input_pending() || !self.native_actions.is_empty() || self.native_events_pending.load(std::sync::atomic::Ordering::Acquire)
+ }
+
+ fn apply_native_actions(&mut self, ctx: &egui::Context) {
+ while !self.synthetic_input_pending() {
+ let Some((id, params)) = self.native_actions.pop_front() else { break };
+ menus::activate_native(self, ctx, &id, &params);
+ }
+ if self.host_order_pending() {
+ ctx.request_repaint();
+ }
+ }
+
+ /// The current state an injected batch belongs to.
+ fn input_generation(&self) -> InputGeneration {
+ InputGeneration {
+ document: self.active_document_epoch(),
+ dialog: self.ui.dialog.as_ref().map(|dialog| egui::Id::unique(&dialog.id)),
+ focus: self.egui_ctx.as_ref().and_then(|ctx| ctx.memory(|memory| memory.focused())),
+ }
+ }
+
+ /// Drop a batch whose document, dialog or focus changed before a UI pass could take it.
+ /// The batch is still in the host's pending raw input; remove exactly the events we appended
+ /// (contiguously, in order) so a subsequent forced paint cannot replay stale input.
+ fn discard_stale_injected_batch(&mut self, raw: &mut egui::RawInput) {
+ if !self.synthetic_injected || self.input_generation() == self.injected_generation {
+ return;
+ }
+ let events = std::mem::take(&mut self.injected_events);
+ if !events.is_empty()
+ && let Some(start) = raw.events.windows(events.len()).rposition(|window| window == events.as_slice())
+ {
+ raw.events.drain(start..start + events.len());
+ }
+ self.synthetic_injected = false;
+ self.injected_pending.store(false, std::sync::atomic::Ordering::Relaxed);
+ self.injected_private = false;
+ self.control_input_frame.store(false, std::sync::atomic::Ordering::Relaxed);
+ }
+
+ /// A font-gated first pass saw the events before any widget did. Put the same batch back at
+ /// the front of its queue (with the original provenance) so a later UI pass consumes it.
+ fn requeue_injected_batch(&mut self) {
+ if !std::mem::take(&mut self.synthetic_injected) {
+ return;
+ }
+ let events = std::mem::take(&mut self.injected_events);
+ if !events.is_empty() {
+ if self.injected_private {
+ self.control_synthetic.splice(0..0, events);
+ } else {
+ self.synthetic.splice(0..0, events);
+ }
}
- raw.events.extend(events.drain(..n));
+ self.injected_pending.store(false, std::sync::atomic::Ordering::Relaxed);
+ self.injected_private = false;
+ self.control_input_frame.store(false, std::sync::atomic::Ordering::Relaxed);
}
+ /// The document area: the start screen, or the document tabs over one or two canvas panes.
+ pub(crate) fn canvas_area(&mut self, ui: &mut egui::Ui, presenting: bool) {
+ let t = theme::Tokens::get(ui.ctx());
+ if self.session.active().is_none() {
+ chrome::start_screen(self, ui);
+ return;
+ }
+ if !presenting {
+ chrome::doc_tabs(self, ui);
+ }
+ let split_layout = (self.split && !presenting)
+ .then(|| {
+ craft_ui::layout::split_rect(
+ ui.available_rect_before_wrap(),
+ craft_ui::layout::SplitAxis::Horizontal,
+ craft_ui::layout::SplitSize::Ratio(0.5),
+ 2.0,
+ 0.0,
+ )
+ })
+ .flatten();
+ if let Some(layout) = split_layout {
+ // Two panes with a divider; each has its own view (zoom, scroll) and render cache.
+ ui.painter().rect_filled(layout.divider, 0.0, t.border);
+ // Resolve the clicked pane before either canvas handles this frame's keys.
+ if let Some(p) = ui.input(|i| i.pointer.any_pressed().then(|| i.pointer.interact_pos()).flatten()) {
+ if layout.first.contains(p) {
+ self.focus_pane = 0;
+ } else if layout.second.contains(p) {
+ self.focus_pane = 1;
+ }
+ }
+ for (k, half) in [layout.first, layout.second].into_iter().enumerate() {
+ self.switch_pane(k as u8);
+ // A new pane starts at the other pane's view.
+ if k == 1 && self.view().is_none() {
+ self.switch_pane(0);
+ let v = self.view().copied();
+ self.switch_pane(1);
+ if let (Some(mut v), Some(m)) = (v, self.view_mut()) {
+ v.fitted = false;
+ *m = v;
+ }
+ }
+ ui.scope_builder(egui::UiBuilder::new().max_rect(half), |ui| canvas::show(self, ui));
+ }
+ self.switch_pane(self.focus_pane);
+ } else {
+ self.switch_pane(0);
+ // With a second window, the main one takes the focus back when clicked.
+ if !self.second_window || (ui.input(|i| i.pointer.any_pressed()) && ui.ui_contains_pointer()) {
+ self.focus_pane = 0;
+ }
+ canvas::show(self, ui);
+ }
+ }
+
/// Lay out the whole window.
pub fn ui(&mut self, ui: &mut egui::Ui) {
+ #[cfg(test)]
+ {
+ self.input_ticks += 1;
+ }
let ctx = ui.ctx().clone();
self.canvas_ime = false;
+ self.ime_canvas = None;
+ self.ime_interrupt = false;
+ // Fonts/theme must be installed from the real UI pass, before the font gate below: doing
+ // this only from a hidden logic tick would make the first shown pass wait forever.
+ if ctx.current_pass_index() == 0 {
+ self.ui_setup(&ctx);
+ }
if !self.fonts_ready {
+ // The first pass installs fonts and returns before any widget sees this frame's input.
+ // Put an injected step back rather than acknowledge it as consumed.
+ self.requeue_injected_batch();
ctx.request_repaint();
return;
}
diff --cc crates/ui-egui/src/panel_docking.rs
index 52dd988ff,b022f2647..6c48614e2
--- a/crates/ui-egui/src/panel_docking.rs
+++ b/crates/ui-egui/src/panel_docking.rs
@@@ -11,44 -5,34 +11,44 @@@ use serde_json::{Value, json}
use crate::DesignApp;
-#[derive(Clone, Default)]
-struct LegacyDrag {
- layout: Option<Layout<String>>,
- open_panel: Option<String>,
- floating: Vec<(String, [f32; 2])>,
- generation: u64,
+/// The id of the dock area that draws the panels.
+fn area_id() -> egui::Id {
- egui::Id::new("designcraft-panel-docking")
++ egui::Id::unique("designcraft-panel-docking")
}
-pub(crate) fn cancel_gesture(app: &mut DesignApp, ctx: &egui::Context) {
- cancel_legacy_drag(app, ctx);
- craft_ui::docking::cancel_drag::<String>(ctx, egui::Id::unique("designcraft-panel-docking"));
+/// The dock area a headless app floats into, before it ever drew a frame.
+const HEADLESS_AREA: egui::Rect = egui::Rect::from_min_max(egui::Pos2::ZERO, egui::pos2(1400.0, 900.0));
+
+/// The egui id of a docking control, for tests that press it or read its response.
+#[cfg(test)]
+pub(crate) fn hit_id(hit: &craft_ui::docking::Hit<String>) -> egui::Id {
+ craft_ui::docking::DockArea::<String>::hit_id(area_id(), hit)
}
-fn cancel_legacy_drag(app: &mut DesignApp, ctx: &egui::Context) -> bool {
- let key = egui::Id::unique("designcraft-panel-docking").with("legacy-origin");
- let previous = ctx.data_mut(|data| data.remove_temp::<LegacyDrag>(key));
- if let Some(previous) = previous {
- craft_ui::docking::cancel_drag::<String>(ctx, egui::Id::unique("designcraft-panel-docking"));
- if previous.generation != app.ui.docking_generation {
- return false;
- }
- app.ui.open_panel = previous.open_panel;
- app.ui.floating = previous.floating;
- app.ui.docking = previous.layout;
- true
- } else {
- false
+/// The egui id of a panel's tab.
+#[cfg(test)]
+pub(crate) fn tab_id(panel: &str) -> egui::Id {
+ hit_id(&craft_ui::docking::Hit::Tab(panel.to_owned()))
+}
+
+/// The viewports of the floating windows that may have OS windows of their own. Where egui
+/// embeds viewports every floating window stays in the main window.
+pub(crate) fn native_viewports(app: &DesignApp, ctx: &egui::Context) -> Vec<egui::ViewportId> {
+ if ctx.embed_viewports() {
+ return Vec::new();
}
+ layout_of(app).floating.iter().map(|window| craft_ui::docking::DockArea::<String>::window_viewport(area_id(), window.id)).collect()
+}
+
+/// The egui layer of the floating window whose first panel is `panel`.
+#[cfg(test)]
+pub(crate) fn floating_layer(panel: &str) -> egui::LayerId {
+ let window = Floating::single(vec![panel.to_owned()], 0, [0.0, 0.0, 1.0, 1.0]);
+ craft_ui::docking::DockArea::<String>::floating_layer(area_id(), &window).unwrap_or_else(egui::LayerId::background)
+}
+
+pub(crate) fn cancel_gesture(ctx: &egui::Context) {
+ craft_ui::docking::cancel_drag::<String>(ctx, area_id());
}
fn normalize(raw: &str) -> Option<&'static str> {
@@@ -1047,31 -463,61 +1047,31 @@@ pub(crate) fn show(app: &mut DesignApp
blocked.push(ui.ctx().content_rect());
} else if crate::story_editor::visible(app) {
// The editor is rendered after the dock; block its unmeasured first frame conservatively.
- let rect = ui.ctx().memory(|m| m.area_rect(egui::Id::new("story_editor"))).unwrap_or_else(|| ui.ctx().content_rect());
+ let rect = ui.ctx().memory(|m| m.area_rect(egui::Id::unique("story_editor"))).unwrap_or_else(|| ui.ctx().content_rect());
blocked.push(rect);
}
- let t = crate::theme::Tokens::get(ui.ctx());
- let language = app.ui.language.clone();
- let mut draw = |ui: &mut egui::Ui| {
- let mut style = craft_ui::docking::DockStyle::from_ui(ui);
- style.tab_height = 27.0;
- style.background = t.panel;
- style.tab_background = t.tab_strip;
- style.active_background = t.panel;
- style.text = t.text_strong;
- style.inactive_text = t.text_dim;
- style.border = egui::Stroke::new(1.0, t.border);
- style.accent = t.accent;
- style.float_label = crate::i18n::tr(&language, "Float Panel").to_owned();
- style.close_label = crate::i18n::tr(&language, "Close Panel").to_owned();
- style.move_label = crate::i18n::tr(&language, "Group with").to_owned();
- style.panels_label = crate::i18n::tr(&language, "Panels").to_owned();
- style.resize_label = crate::i18n::tr(&language, "Resize panels").to_owned();
- style.resize_window_label = crate::i18n::tr(&language, "Resize panel window").to_owned();
- let mut area = craft_ui::docking::DockArea::new(egui::Id::unique("designcraft-panel-docking")).blocked_rects(&blocked);
- if let Some(panel) = &raise {
- area = area.raise_panel(panel.clone());
- }
- area.show_customized(
- ui,
- &layout,
- &style,
- |id| {
- crate::i18n::tr(
- &language,
- crate::dock::DOCK_TABS.iter().chain(crate::dock::ICON_PANELS).find(|p| p.0 == id).map(|p| p.1).unwrap_or(id),
- )
- .to_owned()
- },
- // Close comes from the panel's own tab commands, so the surface doesn't add another.
- |_| craft_ui::docking::Permissions { closable: false, ..Default::default() },
- |_| craft_ui::docking::PanelLimits { min: egui::vec2(220.0, 80.0), ..Default::default() },
- &mut PanelContent(app),
- )
- };
- let output = if layout.root.is_some() {
- egui::Panel::right("shared-panel-dock")
- .default_size(310.0)
- .size_range(220.0..=720.0)
- .resizable(true)
- .frame(egui::Frame::NONE.fill(t.panel))
- .show(ui, &mut draw)
- .inner
- } else {
- draw(ui)
- };
+ let style = dock_style(ui, &app.ui.language);
+ let mut dock = craft_ui::docking::DockArea::new(area)
+ .float_bounds(float_bounds(app, ui.ctx()))
+ .blocked_rects(&blocked)
+ .input_blocked(modal)
+ .auto_collapse_iconic(app.ui.dock_auto_collapse);
+ if let Some(panel) = raise {
+ dock = dock.raise_panel(panel);
+ }
+ let mut output = dock.show_content(ui, &layout, &style, &mut PanelContent { app: &mut *app });
+ for event in std::mem::take(&mut output.events) {
+ match event {
+ craft_ui::docking::DockEvent::ToggleAutoCollapse => app.ui.dock_auto_collapse = !app.ui.dock_auto_collapse,
+ craft_ui::docking::DockEvent::FlyoutChanged { panel } => app.ui.docking_flyout = panel,
+ _ => {}
+ }
+ }
if let Some(panel) = output.focused {
- app.ui.docking_opened = Some(panel);
+ if panel != CANVAS {
+ app.ui.docking_opened = Some(panel.clone());
+ }
+ app.ui.docking_focused = Some(panel);
}
if let Some(error) = output.error {
app.ui.status = error.to_string();
diff --cc docs/pdf-backend.md
index 525c9ff82,26d73aa77..eb32303a9
--- a/docs/pdf-backend.md
+++ b/docs/pdf-backend.md
@@@ -1,8 -1,8 +1,8 @@@
# Shared PDF backend
-DesignCraft pins `craft-pdf`, patched Krilla 0.8.2 and the five Hayro reader crates (with
-`hayro-cmap`) to craft-libs revision `9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef`. Existing `craft-ui` and `craft-print` revisions
-remain unchanged. The reader migration is reviewed on top of the separate writer change.
+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 `5bbe9f6254de3bb9f9707ae0740ab0db8170afd5`. `craft-ui`,
++`hayro-cmap` and `hayro-postscript`) to craft-libs revision `a0916808f7d78bed8c7b90cdf937176015454a7f`. `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 --cc xtask/src/pdf_deps.rs
index bd854394d,7e9677d52..e7caa5d53
--- a/xtask/src/pdf_deps.rs
+++ b/xtask/src/pdf_deps.rs
@@@ -4,7 -4,7 +4,7 @@@ use std::process::Command
use serde_json::Value;
- const REV: &str = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5";
-const REV: &str = "9f75d3dc19b4b514c4f3d4847ed1ec1b0e86b4ef";
++const REV: &str = "a0916808f7d78bed8c7b90cdf937176015454a7f";
const PACKAGES: &[(&str, &str)] = &[
("craft-pdf", "0.1.0"),
("krilla", "0.8.2"),