diff --git a/Cargo.lock b/Cargo.lock index e90204bd..5499d91b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,6 +132,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + [[package]] name = "alloc-no-stdlib" version = "3.0.0" @@ -193,6 +202,22 @@ dependencies = [ "libc", ] +[[package]] +name = "annotate-snippets" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4" +dependencies = [ + "anstyle", + "unicode-width", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + [[package]] name = "anyhow" version = "1.0.104" @@ -224,7 +249,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.52.0", + "windows-sys 0.60.2", "wl-clipboard-rs", "x11rb", ] @@ -457,6 +482,25 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "annotate-snippets", + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools 0.13.0", + "proc-macro2", + "quote", + "regex", + "rustc-hash 2.1.3", + "shlex 1.3.0", + "syn 2.0.119", +] + [[package]] name = "bit-set" version = "0.10.0" @@ -493,6 +537,12 @@ dependencies = [ "serde_core", ] +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "block-buffer" version = "0.10.4" @@ -581,6 +631,16 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "calendrical_calculations" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abbd6eeda6885048d357edc66748eea6e0268e3dd11f326fff5bd248d779c26" +dependencies = [ + "core_maths", + "displaydoc", +] + [[package]] name = "calloop" version = "0.13.0" @@ -646,7 +706,26 @@ dependencies = [ "find-msvc-tools", "jobserver", "libc", - "shlex", + "shlex 2.0.1", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom 7.1.3", +] + +[[package]] +name = "cfg-expr" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd44d82755fb9210fb10d9daf8dd7e522da0efe1d5f263cffc5db07725663ff" +dependencies = [ + "smallvec", + "target-lexicon", ] [[package]] @@ -670,6 +749,17 @@ dependencies = [ "libc", ] +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "rand_core", +] + [[package]] name = "chrono" version = "0.4.45" @@ -677,11 +767,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-link", ] +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clipboard-win" version = "5.4.3" @@ -764,6 +867,12 @@ dependencies = [ "rustversion", ] +[[package]] +name = "cookie-factory" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2" + [[package]] name = "core-foundation" version = "0.9.4" @@ -814,12 +923,34 @@ dependencies = [ "libc", ] +[[package]] +name = "core-graphics2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b65858d95344d2711161cd92196732f67d6c5fea238cf12f994584828731a5c" +dependencies = [ + "bitflags 2.13.2", + "block", + "cfg-if", + "core-foundation 0.10.1", + "libc", +] + [[package]] name = "core_detect" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -829,23 +960,68 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "craft-appkit" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "block2 0.6.2", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", +] + [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "rustix 1.1.6", ] +[[package]] +name = "craft-behavior" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "accesskit", + "bitflags 2.13.2", + "craft-host", + "craft-keymap", + "craft-theme", + "craft-tracked", + "craft-ui-macros", + "emath", + "kurbo", + "serde", + "smallvec", +] + +[[package]] +name = "craft-cloud-ui" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "egui", +] + [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=380a2f79f6a195c090a5372e819cbcda2b703c09#380a2f79f6a195c090a5372e819cbcda2b703c09" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "rayon", ] @@ -853,27 +1029,73 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "block2 0.6.2", + "craft-atomic", + "craft-host", + "craft-i18n", + "craft-platform", + "futures-lite", + "log", "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "raw-window-handle", "rfd", + "zbus", +] + +[[package]] +name = "craft-docpath" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "serde", +] + +[[package]] +name = "craft-font-catalog" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "harfrust 0.13.3", + "kurbo", + "skrifa 0.47.0", + "thiserror 2.0.21", + "unicode-bidi", + "unicode-segmentation", + "windows-registry", ] [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" + +[[package]] +name = "craft-host" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "bitflags 2.13.2", + "craft-i18n", + "egui", + "serde", + "toml", + "web-time", +] [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ + "chrono", "fixed_decimal", + "icu_calendar", + "icu_collator", + "icu_datetime", "icu_decimal", "icu_locale_core", "icu_locale_fallback", @@ -883,6 +1105,7 @@ dependencies = [ "icu_provider", "icu_provider_adapters", "icu_provider_blob", + "icu_time", "log", "objc2-foundation 0.3.2", "sys-locale", @@ -894,7 +1117,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "craft-dds", "craft-jpeg", @@ -921,7 +1144,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "thiserror 2.0.21", ] @@ -929,8 +1152,13 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ + "craft-host", + "craft-i18n", + "craft-tracked", + "craft-ui-macros", + "craft-xml", "egui", "serde", "serde_json", @@ -939,18 +1167,18 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc)", + "craft-xml", "thiserror 2.0.21", ] [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89#7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89)", + "craft-zip", "serde", "serde_json", "thiserror 2.0.21", @@ -959,20 +1187,25 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", "craft-keymap", "craft-quit", + "craft-theme", + "craft-ui", + "craft-window", "egui", - "muda", - "objc2 0.6.5", - "objc2-app-kit 0.3.2", + "serde", + "serde_json", ] [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "serde_json", ] @@ -980,7 +1213,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "brotli-decompressor", "chrono", @@ -992,27 +1225,56 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=380a2f79f6a195c090a5372e819cbcda2b703c09#380a2f79f6a195c090a5372e819cbcda2b703c09" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "chrono", "craft-codepage", "encoding_rs", ] +[[package]] +name = "craft-pdf" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "serde", +] + [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ + "async-channel", + "async-io", + "async-process", + "core-graphics2", + "craft-atomic", + "craft-docpath", + "craft-host", + "craft-i18n", + "craft-theme", + "futures-lite", "js-sys", + "log", + "objc2-app-kit 0.3.2", + "rfd", + "serde", + "serde_json", "wasm-bindgen", + "wasm-bindgen-futures", "web-sys", + "web-time", + "windows", + "x11rb", + "xcap", + "zbus", ] [[package]] name = "craft-png" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c42c34bfa127b095fb0a8d5ccaba0c168c254062#c42c34bfa127b095fb0a8d5ccaba0c168c254062" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "png", "thiserror 2.0.21", @@ -1021,36 +1283,57 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "dispatch2", "egui", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "wasm-bindgen", + "web-sys", ] [[package]] name = "craft-sbs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=380a2f79f6a195c090a5372e819cbcda2b703c09#380a2f79f6a195c090a5372e819cbcda2b703c09" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "base64 0.23.1", "craft-mime", - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=380a2f79f6a195c090a5372e819cbcda2b703c09)", + "craft-xml", "flate2", "roxmltree", "thiserror 2.0.21", ] +[[package]] +name = "craft-settings" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "craft-atomic", + "craft-host", + "dirs", + "log", + "serde", + "serde_json", + "toml", + "toml_edit", + "web-sys", + "web-time", +] + [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "craft-image-codecs", - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc)", + "craft-xml", "data-url", "flate2", + "gif", + "image-webp", "kurbo", "quick-xml 0.41.0", "resvg", @@ -1064,7 +1347,7 @@ dependencies = [ [[package]] name = "craft-texture" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a913a42abc9fed0cfc588114788e400229f5108#5a913a42abc9fed0cfc588114788e400229f5108" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "bytemuck", "dds", @@ -1072,46 +1355,205 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-theme" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "bitflags 2.13.2", + "craft-tracked", + "craft-ui-macros", + "ecolor", + "log", + "serde", + "serde_json", + "smallvec", +] + [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "serde", "thiserror 2.0.21", + "tiff", ] +[[package]] +name = "craft-tracked" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" + [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ - "craft-fonts-build", + "craft-cloud-ui", + "craft-ui-canvas", + "craft-ui-contract", + "craft-ui-panels", + "craft-ui-patterns", + "craft-ui-shell", + "craft-ui-widgets", +] + +[[package]] +name = "craft-ui-canvas" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "craft-behavior", "craft-i18n", + "craft-keymap", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", "egui", - "epaint", - "js-sys", - "log", - "objc2 0.6.5", - "objc2-app-kit 0.3.2", - "objc2-foundation 0.3.2", "serde", - "skrifa", - "wasm-bindgen", + "serde_json", +] + +[[package]] +name = "craft-ui-contract" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "accesskit", + "craft-behavior", + "craft-codepage", + "craft-font-catalog", + "craft-fonts-build", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-platform", + "craft-quit", + "craft-settings", + "craft-svg", + "craft-theme", + "craft-tracked", + "craft-ui-macros", + "craft-window", + "egui", + "epaint_default_fonts", + "flate2", + "inventory", + "log", + "scoped-tls", + "serde", + "serde_json", + "siphasher", + "skrifa 0.44.0", + "smallvec", + "toml", + "typeid", "wasm-bindgen-futures", - "web-sys", + "web-time", +] + +[[package]] +name = "craft-ui-macros" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "craft-ui-panels" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-quit", + "craft-theme", + "craft-ui-macros", + "craft-ui-widgets", + "egui", + "serde", + "serde_json", +] + +[[package]] +name = "craft-ui-patterns" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-pdf", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", + "egui", + "serde", + "serde_json", + "toml", + "toml_edit", + "zeroize", +] + +[[package]] +name = "craft-ui-shell" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-platform", + "craft-svg", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", + "craft-window", + "egui", + "raw-window-handle", + "serde", + "web-time", +] + +[[package]] +name = "craft-ui-widgets" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-svg", + "craft-theme", + "craft-ui-contract", + "craft-ui-macros", + "egui", + "log", + "serde", + "smallvec", ] [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "chrono", + "craft-host", + "craft-theme", + "craft-ui", "dunce", "egui", "flate2", - "getrandom 0.3.4", "image", "log", "plist", @@ -1129,31 +1571,42 @@ dependencies = [ "zip 9.5.0", ] +[[package]] +name = "craft-win32" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" +dependencies = [ + "winsafe", +] + [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ + "craft-appkit", + "craft-atomic", + "craft-behavior", + "craft-host", + "craft-settings", + "craft-win32", "egui", + "muda", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "raw-window-handle", + "serde", + "serde_json", "wayland-client", + "winsafe", + "x11rb", ] [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=380a2f79f6a195c090a5372e819cbcda2b703c09#380a2f79f6a195c090a5372e819cbcda2b703c09" -dependencies = [ - "quick-xml 0.41.0", - "serde", - "thiserror 2.0.21", -] - -[[package]] -name = "craft-xml" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1163,17 +1616,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=512a1b8e8b59a7b325e7f69f6131aa8628470288#512a1b8e8b59a7b325e7f69f6131aa8628470288" -dependencies = [ - "flate2", - "thiserror 2.0.21", - "zip 9.5.0", -] - -[[package]] -name = "craft-zip" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89#7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" +source = "git+https://github.com/storytold/craft-libs?rev=d7010805175ba1190d521b2565852bdda39e632c#d7010805175ba1190d521b2565852bdda39e632c" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1338,6 +1781,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.60.2", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1397,6 +1861,61 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" +[[package]] +name = "drm" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "drm-ffi", + "drm-fourcc", + "libc", + "rustix 0.38.44", +] + +[[package]] +name = "drm" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a41816e58f47f49acfd956651055ddcf137c4882c2098c30c448817af21183a" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "bytemuck_derive", + "drm-ffi", + "drm-fourcc", + "libc", + "rustix 1.1.6", +] + +[[package]] +name = "drm-ffi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51a91c9b32ac4e8105dec255e849e0d66e27d7c34d184364fb93e469db08f690" +dependencies = [ + "drm-sys", + "rustix 1.1.6", +] + +[[package]] +name = "drm-fourcc" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" + +[[package]] +name = "drm-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8e1361066d91f5ffccff060a3c3be9c3ecde15be2959c1937595f7a82a9f8" +dependencies = [ + "libc", + "linux-raw-sys 0.9.4", +] + [[package]] name = "dunce" version = "1.0.5" @@ -1412,7 +1931,7 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "emath", @@ -1422,7 +1941,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1459,14 +1978,14 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "accesskit", "ahash", "bitflags 2.13.2", "emath", "epaint", - "itertools", + "itertools 0.15.0", "log", "nohash-hasher", "profiling", @@ -1487,7 +2006,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1506,7 +2025,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "accesskit_winit", "arboard", @@ -1529,7 +2048,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "egui", @@ -1542,7 +2061,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "dify", "eframe", @@ -1568,12 +2087,24 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "serde", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "encoding_rs" version = "0.8.44" @@ -1629,7 +2160,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1637,14 +2168,14 @@ dependencies = [ "emath", "epaint_default_fonts", "font-types", - "harfrust", + "harfrust 0.12.0", "log", "nohash-hasher", "parking_lot", "profiling", "self_cell", "serde", - "skrifa", + "skrifa 0.44.0", "smallvec", "unicode-bidi", "unicode-general-category", @@ -1656,7 +2187,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" [[package]] name = "equivalent" @@ -1671,7 +2202,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -1863,6 +2394,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "form_urlencoded" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs-set-times" version = "0.20.3" @@ -1975,6 +2515,30 @@ dependencies = [ "slab", ] +[[package]] +name = "gbm" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce852e998d3ca5e4a97014fb31c940dc5ef344ec7d364984525fd11e8a547e6a" +dependencies = [ + "bitflags 2.13.2", + "drm 0.14.1", + "drm-fourcc", + "gbm-sys", + "libc", + "wayland-backend", + "wayland-server", +] + +[[package]] +name = "gbm-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13a5f2acc785d8fb6bf6b7ab6bfb0ef5dad4f4d97e8e70bb8e470722312f76f" +dependencies = [ + "libc", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2037,6 +2601,7 @@ dependencies = [ "js-sys", "libc", "r-efi 6.0.0", + "rand_core", "wasm-bindgen", ] @@ -2050,6 +2615,15 @@ dependencies = [ "weezl", ] +[[package]] +name = "gl" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94edab108827d67608095e269cf862e60d920f144a5026d3dbcfd8b877fb404" +dependencies = [ + "gl_generator", +] + [[package]] name = "gl_generator" version = "0.14.0" @@ -2094,11 +2668,17 @@ dependencies = [ "hashbrown 0.17.1", "log", "peniko", - "skrifa", + "skrifa 0.44.0", "smallvec", "vello_common", ] +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + [[package]] name = "glow" version = "0.17.0" @@ -2220,7 +2800,20 @@ checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" dependencies = [ "bitflags 2.13.2", "bytemuck", - "read-fonts", + "read-fonts 0.41.0", + "smallvec", +] + +[[package]] +name = "harfrust" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "948d0741125ba89cd3e1c23e5642415b6ade7e1d29d67ba25fb925b533e989d6" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "once_cell", + "read-fonts 0.43.3", "smallvec", ] @@ -2262,6 +2855,12 @@ dependencies = [ "fearless_simd", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.5.3" @@ -2314,6 +2913,39 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_calendar" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58655df2f728e46e4eee80bddebefacf52ec3e77cdb925014b47c5a5905eb55c" +dependencies = [ + "calendrical_calculations", + "displaydoc", + "icu_locale_core", + "icu_provider", + "serde", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_collator" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08984ed58ac439ebf3e13d2cf26b0c46a60afcd21721c1d14087c0b240344dda" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_normalizer", + "icu_properties", + "icu_provider", + "serde", + "smallvec", + "utf16_iter", + "utf8_iter", + "zerovec", +] + [[package]] name = "icu_collections" version = "2.3.0" @@ -2322,12 +2954,37 @@ checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" dependencies = [ "displaydoc", "potential_utf", + "serde", "utf8_iter", "yoke", "zerofrom", "zerovec", ] +[[package]] +name = "icu_datetime" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c44df99c4c5297b05653d1a1629f13bdc9fd4044acfbbaf30b15194a1eed4cd6" +dependencies = [ + "displaydoc", + "fixed_decimal", + "icu_calendar", + "icu_decimal", + "icu_locale_core", + "icu_pattern", + "icu_plurals", + "icu_provider", + "icu_time", + "potential_utf", + "serde", + "smallvec", + "tinystr", + "writeable", + "zerotrie", + "zerovec", +] + [[package]] name = "icu_decimal" version = "2.3.0" @@ -2389,6 +3046,7 @@ dependencies = [ "icu_normalizer_data", "icu_properties", "icu_provider", + "serde", "smallvec", "utf16_iter", "utf8_iter", @@ -2439,6 +3097,7 @@ dependencies = [ "icu_locale_core", "icu_properties_data", "icu_provider", + "serde", "zerotrie", "zerovec", ] @@ -2491,12 +3150,49 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_time" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af37e1c3b9f3ab564b619fdf4b22de169f6381eb0f7048e3ca454290c438126b" +dependencies = [ + "calendrical_calculations", + "displaydoc", + "icu_calendar", + "icu_locale_core", + "icu_provider", + "serde", + "zerotrie", + "zerovec", +] + [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + [[package]] name = "image" version = "0.25.10" @@ -2546,6 +3242,15 @@ dependencies = [ "serde_core", ] +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + [[package]] name = "io-extras" version = "0.19.0" @@ -2593,6 +3298,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.15.0" @@ -2678,9 +3392,9 @@ dependencies = [ [[package]] name = "jpeg-encoder" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b454d911ac55068f53495488d8ccd0646eaa540c033a28ee15b07838afafb01f" +checksum = "a0370574b86f7eca156b9f298392b5e69a23f8c86f3f865add60bbc2e79467a6" [[package]] name = "js-sys" @@ -2789,6 +3503,54 @@ dependencies = [ "redox_syscall 0.9.5", ] +[[package]] +name = "libspa" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882f7427e7989dcc9d388b7f05c4630390a1d7696f9ffa469cd4a7a48f0b4c40" +dependencies = [ + "bitflags 2.13.2", + "cc", + "cookie-factory", + "libc", + "libspa-sys", + "nom 8.0.0", + "rustix 1.1.6", + "system-deps", +] + +[[package]] +name = "libspa-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b6e17bdaf63ed0d5e4144022624032b41fd9733112e8c74ac26fc9bf1291924" +dependencies = [ + "bindgen", + "cc", + "system-deps", +] + +[[package]] +name = "libwayshot-xcap" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea8a46e4d016ef464e386e4970f5415fe0939c2d63abe0c2f539c05ef88c5fe5" +dependencies = [ + "drm 0.15.0", + "gbm", + "gl", + "image", + "khronos-egl", + "memmap2", + "rustix 1.1.6", + "thiserror 2.0.21", + "tracing", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + [[package]] name = "linebender_resource_handle" version = "0.1.1" @@ -2814,6 +3576,12 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -2958,8 +3726,8 @@ dependencies = [ "craft-sbs", "craft-svg", "craft-texture", - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc)", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=512a1b8e8b59a7b325e7f69f6131aa8628470288)", + "craft-xml", + "craft-zip", "dds", "flate2", "image", @@ -3011,11 +3779,14 @@ version = "0.4.1" dependencies = [ "base64 0.22.1", "craft-atomic", + "craft-behavior", "craft-dialogs", + "craft-host", + "craft-i18n", "craft-keymap", "craft-platform", "craft-png", - "craft-quit", + "craft-theme", "craft-ui", "craft-update", "craft-window", @@ -3092,6 +3863,12 @@ dependencies = [ "glam 0.15.2", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -3243,6 +4020,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nom" version = "8.0.0" @@ -3335,8 +4122,8 @@ dependencies = [ "block2 0.5.1", "libc", "objc2 0.5.3", - "objc2-core-data", - "objc2-core-image", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", "objc2-foundation 0.2.2", "objc2-quartz-core 0.2.2", ] @@ -3349,9 +4136,48 @@ checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", + "libc", "objc2 0.6.5", + "objc2-cloud-kit 0.3.2", + "objc2-core-data 0.3.2", "objc2-core-foundation", "objc2-core-graphics", + "objc2-core-image 0.3.2", + "objc2-core-text", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-av-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478ae33fcac9df0a18db8302387c666b8ef08a3e2d62b510ca4fc278a384b6c0" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "dispatch2", + "objc2 0.6.5", + "objc2-avf-audio", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-image 0.3.2", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-image-io", + "objc2-media-toolbox", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-avf-audio" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" +dependencies = [ + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -3368,6 +4194,17 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-cloud-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-contacts" version = "0.2.2" @@ -3379,6 +4216,28 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-core-audio" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1eebcea8b0dbff5f7c8504f3107c68fc061a3eb44932051c8cf8a68d969c3b2" +dependencies = [ + "dispatch2", + "objc2 0.6.5", + "objc2-core-audio-types", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-core-audio-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", +] + [[package]] name = "objc2-core-data" version = "0.2.2" @@ -3391,6 +4250,17 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-core-data" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-core-foundation" version = "0.3.2" @@ -3398,7 +4268,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", + "libc", "objc2 0.6.5", ] @@ -3409,10 +4281,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", + "libc", "objc2 0.6.5", "objc2-core-foundation", "objc2-io-surface", + "objc2-metal 0.3.2", ] [[package]] @@ -3427,6 +4302,16 @@ dependencies = [ "objc2-metal 0.2.2", ] +[[package]] +name = "objc2-core-image" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" +dependencies = [ + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-core-location" version = "0.2.2" @@ -3439,6 +4324,49 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-core-media" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec576860167a15dd9fce7fbee7512beb4e31f532159d3482d1f9c6caedf31d" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-audio", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-core-video", +] + +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", +] + +[[package]] +name = "objc2-core-video" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-io-surface", + "objc2-metal 0.3.2", +] + [[package]] name = "objc2-encode" version = "4.1.0" @@ -3466,10 +4394,22 @@ checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", + "libc", "objc2 0.6.5", "objc2-core-foundation", ] +[[package]] +name = "objc2-image-io" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b0446e98cf4a784cc7a0177715ff317eeaa8463841c616cfc78aa4f953c4ea" +dependencies = [ + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", +] + [[package]] name = "objc2-io-surface" version = "0.3.2" @@ -3493,6 +4433,18 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-media-toolbox" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd9fdde720df3da7046bb9097811000c1e7ab5cd579fa89d96b27d56781fb30" +dependencies = [ + "objc2 0.6.5", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-core-media", +] + [[package]] name = "objc2-metal" version = "0.2.2" @@ -3563,9 +4515,9 @@ dependencies = [ "bitflags 2.13.2", "block2 0.5.1", "objc2 0.5.3", - "objc2-cloud-kit", - "objc2-core-data", - "objc2-core-image", + "objc2-cloud-kit 0.2.2", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", "objc2-core-location", "objc2-foundation 0.2.2", "objc2-link-presentation", @@ -3633,6 +4585,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "orbclient" version = "0.3.55" @@ -3669,7 +4627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -3829,6 +4787,31 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pipewire" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde71084c4e25959d68f1ea54daa75e5ecdb338e5caf0b5510143b79baa32d5c" +dependencies = [ + "bitflags 2.13.2", + "libc", + "libspa", + "libspa-sys", + "pipewire-sys", + "rustix 1.1.6", +] + +[[package]] +name = "pipewire-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce653f53e63e5b93853218092ee9a8906a5d082c92f3f1db26316955dd63ce0" +dependencies = [ + "bindgen", + "libspa-sys", + "system-deps", +] + [[package]] name = "pkg-config" version = "0.3.34" @@ -3924,6 +4907,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" dependencies = [ "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", "serde", ] @@ -4057,6 +5042,23 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +[[package]] +name = "rand" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + [[package]] name = "range-alloc" version = "0.1.5" @@ -4121,6 +5123,28 @@ dependencies = [ "once_cell", ] +[[package]] +name = "read-fonts" +version = "0.43.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "005c8acf251756c478b0bf402885bfd88a1476020c4c7e6060edc1aa68da38ea" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + +[[package]] +name = "read-fonts" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5a0cf4bb6cbce4c29756270d189a5e400ac05e91192161d83a0bcb6e68492e8" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + [[package]] name = "reborrow" version = "0.5.5" @@ -4154,6 +5178,16 @@ dependencies = [ "bitflags 2.13.2", ] +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror 2.0.21", +] + [[package]] name = "ref-cast" version = "1.0.27" @@ -4174,6 +5208,35 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "regex" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + [[package]] name = "renderdoc-sys" version = "1.1.0" @@ -4360,7 +5423,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -4427,7 +5490,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -4635,10 +5698,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures", + "cpufeatures 0.2.17", "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "shlex" version = "2.0.1" @@ -4699,7 +5768,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" dependencies = [ "bytemuck", - "read-fonts", + "read-fonts 0.41.0", +] + +[[package]] +name = "skrifa" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "526e654b303ff4ad73a5a40b25de2b3ce3d039c5e3b6da5f89ae6e57004cb40f" +dependencies = [ + "bytemuck", + "read-fonts 0.44.0", ] [[package]] @@ -4867,6 +5946,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "system-deps" +version = "7.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml", + "version-compare", +] + [[package]] name = "tar" version = "0.4.46" @@ -4877,6 +5969,12 @@ dependencies = [ "libc", ] +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + [[package]] name = "tempfile" version = "3.27.0" @@ -4884,10 +5982,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix 1.1.6", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -5108,8 +6206,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" dependencies = [ "indexmap", + "serde_core", + "serde_spanned", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] @@ -5166,7 +6267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" dependencies = [ "memchr", - "nom", + "nom 8.0.0", "petgraph", ] @@ -5291,6 +6392,18 @@ dependencies = [ "log", ] +[[package]] +name = "url" +version = "2.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + [[package]] name = "usvg" version = "0.48.1" @@ -5300,7 +6413,7 @@ dependencies = [ "base64 0.23.1", "data-url", "fontdb", - "harfrust", + "harfrust 0.12.0", "imagesize", "kurbo", "log", @@ -5308,7 +6421,7 @@ dependencies = [ "roxmltree", "simplecss", "siphasher", - "skrifa", + "skrifa 0.44.0", "strict-num", "svgtypes", "tiny-skia-path", @@ -5418,6 +6531,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "version-compare" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" + [[package]] name = "version_check" version = "0.9.5" @@ -5601,6 +6720,19 @@ dependencies = [ "quote", ] +[[package]] +name = "wayland-server" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde9c29be0f723a573977de51ee455bf3dfa03652730a74f9dd3b337e374d75" +dependencies = [ + "bitflags 2.13.2", + "downcast-rs", + "rustix 1.1.6", + "wayland-backend", + "wayland-scanner", +] + [[package]] name = "wayland-sys" version = "0.31.11" @@ -5608,7 +6740,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" dependencies = [ "dlib", + "libc", "log", + "memoffset", "once_cell", "pkg-config", ] @@ -5831,13 +6965,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + [[package]] name = "winapi-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -6292,6 +7432,48 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" +[[package]] +name = "xcap" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da270fd7c8581d43d731cb690bcc791fc0a7b3bc96e131a4b6552d0379640a9e" +dependencies = [ + "dispatch2", + "image", + "libwayshot-xcap", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-av-foundation", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-core-media", + "objc2-core-video", + "objc2-foundation 0.3.2", + "percent-encoding", + "pipewire", + "rand", + "scopeguard", + "serde", + "thiserror 2.0.21", + "url", + "widestring", + "windows", + "xcb", + "zbus", +] + +[[package]] +name = "xcb" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6c2ad15e0e922856ee89afe862b8992334bbe7953adad56cd1199358cb30566" +dependencies = [ + "bitflags 2.13.2", + "libc", + "quick-xml 0.41.0", +] + [[package]] name = "xcursor" version = "0.3.11" diff --git a/Cargo.toml b/Cargo.toml index 39486918..ee18d334 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,19 +39,19 @@ license = "MIT OR Apache-2.0" [workspace.dependencies] # Standard Base64 output; strict SBS decoding remains app-local -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", version = "0.1.0" } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", version = "0.1.0" } # Read 3D meshes through craft-mesh; keep mesh processing app-local -craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", default-features = false, features = ["obj", "gltf"] } +craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", default-features = false, features = ["obj", "gltf"] } # Shared XML escaping and bounded XML parsing; SBS model and serialization policy stay app-local -craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Shared SBS package/schema parsing, sniffing, embedded codec, and envelope writing (storytold/craft-libs#2496) -craft-sbs = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "380a2f79f6a195c090a5372e819cbcda2b703c09" } +craft-sbs = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Shared bounded ZIP archive reader and deterministic writer (storytold/craft-libs#2411) -craft-zip = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "512a1b8e8b59a7b325e7f69f6131aa8628470288" } +craft-zip = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Bound SVG parsing and drawing through craft-svg -craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["tree-render"] } +craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", features = ["tree-render"] } # Shared raster image codecs -craft-image-codecs = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-image-codecs = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # internal materialcraft-core = { path = "crates/core" } materialcraft-geom = { path = "crates/geom" } @@ -91,43 +91,47 @@ getrandom = "0.3" # Shared Craft egui components from storytold/craft-libs # MIT OR Apache-2.0 egui_kittest = "0.37" -craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # MCMAT v3 uses its merged archive revision and the matching ZIP crate -craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" } -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["serde"] } +craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Keyboard bindings (chords, dispatch and display text): storytold/craft-libs, MIT OR Apache-2.0 -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["egui"] } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", features = ["egui"] } # Native dialogs that do not block the event loop: storytold/craft-libs, MIT OR Apache-2.0 -craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } -craft-platform = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-platform = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # The platform quit and the macOS Quit menu item: storytold/craft-libs, MIT OR Apache-2.0 -craft-quit = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["egui"] } -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-quit = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", features = ["ui"] } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Who draws the window frame, and an app-drawn strip as the title bar: storytold/craft-libs, MIT OR Apache-2.0 -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["egui"] } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", features = ["ui"] } # Release checks and self-updates for the desktop app: storytold/craft-libs, MIT OR Apache-2.0 -craft-update = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc", features = ["egui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", features = ["ui"] } # Atomic persistence, at the suite's current revision -craft-atomic = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } -craft-png = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c42c34bfa127b095fb0a8d5ccaba0c168c254062" } +craft-atomic = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } +craft-png = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Parse the optional shared font catalog at build time; the font repository is not a dependency -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "453b0da782ccef39be9a6dac8d27c80b553ef1cc" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c" } # Float image planes and texture sampling for node cooking: storytold/craft-libs, MIT OR Apache-2.0 -craft-texture = { git = "https://github.com/storytold/craft-libs", rev = "5a913a42abc9fed0cfc588114788e400229f5108", features = ["parallel"] } +craft-texture = { git = "https://github.com/storytold/craft-libs", rev = "d7010805175ba1190d521b2565852bdda39e632c", features = ["parallel"] } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] -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" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +emath = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } # egui-phosphor has no release for egui 0.37 (vendor/egui-phosphor/VENDORED.md). egui-phosphor = { path = "vendor/egui-phosphor" } diff --git a/apps/materialcraft-web/src/web.rs b/apps/materialcraft-web/src/web.rs index 850b8d84..73430837 100644 --- a/apps/materialcraft-web/src/web.rs +++ b/apps/materialcraft-web/src/web.rs @@ -60,6 +60,7 @@ async fn run(canvas: web_sys::HtmlCanvasElement) -> Result<(), String> { canvas, options, Box::new(|cc| { + materialcraft_ui_egui::framework::install_headless(&cc.egui_ctx); let mut app = MaterialCraftApp::new(cc, session); // One thread cooks in the browser, so keep previews small diff --git a/apps/materialcraft/Cargo.toml b/apps/materialcraft/Cargo.toml index d8150fee..8a9610af 100644 --- a/apps/materialcraft/Cargo.toml +++ b/apps/materialcraft/Cargo.toml @@ -26,7 +26,7 @@ rfd = { workspace = true } craft-atomic = { workspace = true } # The window frame's choice applies before the window exists. -craft-window = { workspace = true, features = ["egui"] } +craft-window = { workspace = true, features = ["ui"] } # The Windows update helper is a copy of this program started with `--finish-update`. [target.'cfg(windows)'.dependencies] diff --git a/apps/materialcraft/src/main.rs b/apps/materialcraft/src/main.rs index e1ae4b3e..099c6712 100644 --- a/apps/materialcraft/src/main.rs +++ b/apps/materialcraft/src/main.rs @@ -239,10 +239,10 @@ fn main() { prev(info); })); let session = initial_session(&args); - let window_frame = craft_window::Choice::probe(craft_window::Prefix::new("MATERIALCRAFT")).into_frame(); - let mut viewport = craft_window::decorate( + let window_frame = materialcraft_ui_egui::framework::decide_frame(); + let mut viewport = craft_window::policy::apply( egui::ViewportBuilder::default().with_title(os_window::name_for(os_window::identity())).with_inner_size(DEFAULT_SIZE).with_min_inner_size(MIN_SIZE), - &window_frame, + &window_frame.frame, ); // Stable keeps eframe's implicit app id, so its saved layout stays where it is; a Nightly // carries its own id so docks, compositor rules and the taskbar list it separately. @@ -282,6 +282,7 @@ fn main() { os_window::name_for(os_window::identity()), options, Box::new(move |cc| { + materialcraft_ui_egui::framework::install(&cc.egui_ctx, window_frame)?; let mut app = MaterialCraftApp::new(cc, session); app.build_version = BUILT_VERSION.to_owned(); app.build_commit = BUILD_SHA.to_owned(); @@ -291,7 +292,6 @@ fn main() { app.at_exit = Some(Box::new(move || { nightly_session::finish_once(&hook_session, hook_notice.load(std::sync::atomic::Ordering::Relaxed)); })); - app.window_layout = window_frame.layout().cloned(); // Called from the creator: winit installs its default menu before this runs. On error winit's menu stays, whose Quit does not ask #[cfg(target_os = "macos")] if let Err(error) = craft_menu::mac::install_app_menu(&cc.egui_ctx, os_window::name_for(os_window::identity())) { diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 73080dfc..90257bf0 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -14,6 +14,11 @@ materialcraft-render = { workspace = true } eframe = { workspace = true, features = ["default_fonts", "wgpu", "persistence"] } egui = { workspace = true } craft-ui = { workspace = true } +craft-behavior = { workspace = true } +craft-host = { workspace = true } +craft-theme = { workspace = true } +craft-i18n = { workspace = true } +craft-window = { workspace = true, features = ["ui"] } craft-keymap = { workspace = true, features = ["egui"] } egui-phosphor = { version = "0.14", features = ["regular"] } serde = { workspace = true } @@ -30,10 +35,6 @@ sha2 = { workspace = true } sys-locale = "0.3" craft-update = { workspace = true } craft-dialogs = { workspace = true } -craft-quit = { workspace = true, features = ["egui"] } -craft-window = { workspace = true, features = ["egui"] } -# Floating panels open as OS windows. -craft-ui = { workspace = true, features = ["native-windows"] } # Browser file I/O (web_files.rs): async pickers and Blob downloads. [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index f2ca03a9..0e2fe4e1 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -1,22 +1,26 @@ //! The dock host: every panel (explorer, library, graph, 3D view, 2D view, properties, console, -//! history) is a tab that can be docked, tabbed, resized, floated and closed. craft-ui's shared -//! docking (`craft_ui::docking`) draws the frames, tab strips, floating windows and drop previews -//! and owns the gestures; this module names the panels, builds the default arrangement, applies -//! the dock's changes and hosts the panel bodies. +//! history) is a tab that can be docked, tabbed, resized, floated and closed. craft-ui's +//! `DockArea` draws the frames, tab strips, floating windows and drop previews and owns the +//! gestures; this module names the panels, builds the default arrangement, applies the dock's +//! changes and hosts the panel bodies. //! //! The graph is the central canvas: it stays docked, never takes tabs and is the only panel that -//! cannot close or float. The layout persists with `UiState` as a craft-ui `Workspace`; a layout -//! that does not load or validate becomes the default. +//! cannot close or float. The layout persists with `UiState` as a craft-behavior `Workspace`; a +//! layout that does not load or validate becomes the default. -use craft_ui::docking::{Action, DockArea, DockContent, DockStyle, Layout, Location, Node, PanelLimits, PanelState, Permissions, Placement}; -use craft_ui::layout::{SplitAxis, SplitSize}; -use egui::{Id, Margin, RichText, Ui, vec2}; +use std::sync::Arc; + +use craft_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions, SplitSize}; +use craft_behavior::flow::Axis; +use craft_ui::contract::{Bind, BodyCx, PlainData, SizeLimits, Tracked}; +use craft_ui::docking::{DockConfig, DockPanels, GroupAt, PanelSpec, PanelSpecs}; +use craft_ui::patterns::dock::DockArea; +use egui::{Margin, Rect, Ui, vec2}; use serde::{Deserialize, Serialize}; use serde_json::Value; use crate::MaterialCraftApp; use crate::i18n::tr; -use crate::theme::Tokens; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Panel { @@ -63,68 +67,62 @@ impl Panel { } } - /// Where the panel floats when it has never been laid out: `[x, y, width, height]`, cascaded. - fn float_rect(self) -> Option<[f32; 4]> { + /// Where the panel floats when it has never been laid out, cascaded. + fn float_rect(self) -> Option { let slot = match self { Panel::Console => 0.0, Panel::History => 1.0, _ => return None, }; - Some([900.0, 120.0 + 50.0 * slot, 420.0, 320.0]) + Some(Rect::from_min_size(egui::pos2(900.0, 120.0 + 50.0 * slot), vec2(420.0, 320.0))) } } -/// The saved panel arrangement: craft-ui's workspace over MaterialCraft's panels. -pub type Workspace = craft_ui::docking::Workspace; +/// The saved panel arrangement: craft-behavior's workspace over MaterialCraft's panels. +pub type Workspace = craft_behavior::dock::Workspace; /// The graph never moves, floats, closes or takes tabs; panels dock beside it. pub fn permissions(panel: &Panel) -> Permissions { - if *panel == Panel::Graph { Permissions { accepts_splits: true, ..Permissions::PROTECTED } } else { Permissions::default() } + if *panel == Panel::Graph { Permissions::PROTECTED.accepts_splits(true) } else { Permissions::default() } } fn tabs(panels: &[Panel]) -> Node { - Node::Tabs { panels: panels.to_vec(), active: 0 } + Node::tabs(panels.to_vec(), 0) } -fn split(axis: SplitAxis, ratio: f32, first: Node, second: Node) -> Node { - Node::Split { axis, size: SplitSize::Ratio(ratio), first: Box::new(first), second: Box::new(second) } +fn split(axis: Axis, ratio: f32, first: Node, second: Node) -> Node { + Node::split(axis, SplitSize::Ratio(ratio), first, second) } /// The default: explorer over library on the left; the graph over the 3D and 2D views in the /// middle; properties on the right. Console and history are closed and open floating. pub fn default_workspace() -> Workspace { use Panel::*; - let left = split(SplitAxis::Vertical, 0.36, tabs(&[Explorer]), tabs(&[Library])); - let views = split(SplitAxis::Horizontal, 0.5, tabs(&[View3d]), tabs(&[View2d])); - let center = split(SplitAxis::Vertical, 0.52, tabs(&[Graph]), views); - let root = split(SplitAxis::Horizontal, 0.15, left, split(SplitAxis::Horizontal, 0.8, center, tabs(&[Properties]))); - let mut workspace = Workspace::new(Layout { root: Some(root), floating: Vec::new() }); - for panel in Panel::ALL { - if let Some(rect) = panel.float_rect() { - let location = Location { - floating: Some(rect), - anchor: None, - placement: Placement::Tab { before: None }, - size: None, - stack: None, - sibling: Vec::new(), - group: None, - }; - workspace.hidden.push((panel, location)); - } - } - workspace + let left = split(Axis::Y, 0.36, tabs(&[Explorer]), tabs(&[Library])); + let views = split(Axis::X, 0.5, tabs(&[View3d]), tabs(&[View2d])); + let center = split(Axis::Y, 0.52, tabs(&[Graph]), views); + let root = split(Axis::X, 0.15, left, split(Axis::X, 0.8, center, tabs(&[Properties]))); + let hidden = Panel::ALL + .into_iter() + .filter_map(|panel| { + let rect = panel.float_rect()?; + let mut location = Location::new(None, DockPlacement::tab(None)); + location.floating = Some(rect); + Some((panel, location)) + }) + .collect(); + Workspace::from_parts(Layout::new(Some(root), Vec::new()), hidden, Vec::new()) } -/// craft-ui's checks plus the graph's: a saved or hand-edited file cannot hide, float, group -/// or collapse it. +/// craft-behavior's checks plus the graph's: a saved or hand-edited file cannot hide, float, +/// group or collapse it. pub fn validate(workspace: &Workspace) -> Result<(), String> { workspace.validate().map_err(|error| error.to_string())?; - let layout = &workspace.layout; + let layout = workspace.layout(); if layout.floating.iter().any(|window| window.contains(&Panel::Graph)) { return Err("The graph cannot float".into()); } - if workspace.hidden.iter().any(|(panel, _)| *panel == Panel::Graph) { + if workspace.hidden().iter().any(|(panel, _)| *panel == Panel::Graph) { return Err("The graph cannot be hidden".into()); } let mut found = false; @@ -141,7 +139,7 @@ pub fn validate(workspace: &Workspace) -> Result<(), String> { } found = true; } - Node::Stack { entries } if entries.iter().any(|entry| entry.panel == Panel::Graph) => { + Node::Stack { entries, .. } if entries.iter().any(|entry| entry.panel == Panel::Graph) => { return Err("The graph cannot be collapsed".into()); } Node::Dock { columns, .. } if columns.iter().flat_map(|column| &column.groups).any(|group| group.panels.contains(&Panel::Graph)) => { @@ -156,7 +154,7 @@ pub fn validate(workspace: &Workspace) -> Result<(), String> { // --------------------------------------------------------------------------------------------- // The live dock -/// The dock layout (part of `UiState`; serialized as a craft-ui `Workspace`). +/// The dock layout (part of `UiState`; serialized as a craft-behavior `Workspace`). #[derive(Clone, Debug)] pub struct Dock { workspace: Workspace, @@ -207,12 +205,18 @@ impl Dock { } pub fn is_open(&self, p: Panel) -> bool { - self.workspace.layout.contains(&p) + self.workspace.layout().contains(&p) } /// Open and the front tab of its group. pub fn is_visible(&self, p: Panel) -> bool { - self.workspace.layout.panel_state(&p) == PanelState::Front + self.workspace.layout().panel_state(&p) == PanelState::Front + } + + /// Puts the default layout back. It replaces the workspace instead of editing it, which ends a drag in progress. + pub fn reset(&mut self) { + self.workspace.replace(default_workspace()); + self.raise = None; } /// Hide a visible panel, otherwise bring it up. @@ -221,7 +225,7 @@ impl Dock { } pub fn close(&mut self, p: Panel) { - if let Err(error) = self.workspace.set_visible(p, false, None, permissions) { + if let Err(error) = self.workspace.set_visible(p, false, None, false, permissions) { log::warn!("panel {p:?} was not closed: {error}"); } } @@ -230,7 +234,7 @@ impl Dock { /// front. pub fn focus(&mut self, p: Panel) { let mut next = self.workspace.clone(); - match next.set_visible(p, true, None, permissions) { + match next.set_visible(p, true, None, false, permissions) { Ok(()) if validate(&next).is_ok() => { self.workspace = next; self.raise = Some(p); @@ -244,7 +248,7 @@ impl Dock { /// it was. fn apply(&mut self, action: Action) { let mut next = self.workspace.clone(); - match next.apply(action, permissions) { + match next.apply(action, false, permissions) { Ok(_) if validate(&next).is_ok() => self.workspace = next, Ok(_) => log::warn!("a panel move would break the graph's rules"), Err(error) => log::warn!("a panel move was not applied: {error}"), @@ -252,73 +256,117 @@ impl Dock { } } +/// What the dock area keeps between passes: the workspace it shows and the panels' specs. +#[derive(Default)] +pub(crate) struct LiveDock { + shown: Option>, + specs: Tracked, +} + +impl LiveDock { + /// The `Arc` the dock shows for `workspace`: the last one while the arrangement is the same, + /// so an idle pass keeps the workspace's revision and the dock reads no spec. + fn shown(&mut self, workspace: &Workspace) -> Arc { + if let Some(shown) = self.shown.as_ref().filter(|shown| ***shown == *workspace) { + return Arc::clone(shown); + } + let shown = Arc::new(workspace.clone()); + self.shown = Some(Arc::clone(&shown)); + shown + } +} + +/// What the dock reads of the panels: their tab names, in [`Panel::ALL`] order. +#[derive(Clone, Debug, Default, PartialEq, PlainData)] +struct DockSpecs { + labels: Vec, +} + +impl PanelSpecs for DockSpecs { + fn spec(&self, panel: &Panel) -> PanelSpec { + let label = Panel::ALL.iter().position(|p| p == panel).and_then(|index| self.labels.get(index)).cloned().unwrap_or_default(); + // Every panel body is MaterialCraft's own egui code: the dock runs it with the window's style. + let spec = PanelSpec::new(label).limits(limits(panel)).float_size(vec2(420.0, 320.0)).host_body(); + if *panel == Panel::Graph { spec.canvas() } else { spec } + } + + fn permissions(&self, panel: &Panel) -> Permissions { + permissions(panel) + } +} + +/// Smallest body sizes a divider drag leaves. +fn limits(panel: &Panel) -> SizeLimits { + SizeLimits::at_least(if *panel == Panel::Graph { vec2(240.0, 160.0) } else { vec2(120.0, 60.0) }) +} + +/// The tab name of `panel`: what it shows (the selection, the scene, the image) in the interface +/// language. +fn label(app: &MaterialCraftApp, panel: Panel) -> String { + match panel { + Panel::Properties => crate::properties::title(app), + Panel::Graph => app.session.graph().map(|g| format!("{} - {}", g.name, tr("Graph"))).unwrap_or_else(|_| tr("Graph").into()), + Panel::View3d => format!("{} - {}", crate::view3d::scene_label(app), tr("3D View")), + Panel::View2d => crate::view2d::title(app), + p => tr(p.name()).to_string(), + } +} + +/// Reads the tab names, moving the specs' revision only when one changed. +fn refresh_specs(app: &mut MaterialCraftApp) { + let labels: Vec = Panel::ALL.iter().map(|panel| label(app, *panel)).collect(); + if app.docks.specs.labels != labels { + app.docks.specs.labels = labels; + } +} + // --------------------------------------------------------------------------------------------- // Drawing -fn area_id() -> Id { - Id::unique("materialcraft-docking") -} - -/// The dock look: every panel group is a card on the window's frame colour, its tab strip -/// without hard lines, the shown tab a pill, uppercase captions. -fn style(ui: &Ui, t: &Tokens) -> DockStyle { - let mut s = DockStyle::from_ui(ui); - s.gap = 6.0; - // Smallest panel extent a divider drag leaves. - s.min_pane = 60.0; - s.background = t.panel; - s.tab_background = t.panel; - s.active_background = t.button; - s.text = t.text_strong; - s.inactive_text = t.text_dim; - s.border = egui::Stroke::NONE; - s.accent = t.accent; - s.floating_background = t.panel; - s.floating_stroke = egui::Stroke::new(1.0, t.button_border); - s.font = egui::FontId::proportional(10.5); - s.min_tab_width = 54.0; - s.tab_height = 30.0; - // Panels arrange in a split tree around the graph; floating title bars only move windows. - s.new_dock_zones = false; - s.title_bar_docks = false; - s -} - /// Draw the dock (graph and panels) into `ui`. pub fn show(app: &mut MaterialCraftApp, ui: &mut Ui) { let ctx = ui.ctx().clone(); - let tk = Tokens::get(&ctx); - let style = style(ui, &tk); - let layout = app.ui.dock.workspace.layout.clone(); - let mut area = DockArea::new(area_id()).input_blocked(crate::shell::modality::Modality::capture(app, &ctx).is_blocked()); - if let Some(panel) = app.ui.dock.raise.take() { - area = area.raise_panel(panel); - } - let output = area.show_content(ui, &layout, &style, &mut Panels { app }); + refresh_specs(app); + let shown = app.docks.shown(&app.ui.dock.workspace); + // The specs leave the app while its panels borrow it, and come back with their revision. + let specs = std::mem::take(&mut app.docks.specs); + let raise = app.ui.dock.raise.take(); + // Panels arrange in a split tree around the graph; floating title bars only move windows. + let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false); + let output = { + let mut panels = Panels { app: &mut *app }; + let mut area = DockArea::new("Panels", Bind::given(Arc::clone(&shown)), &specs, &mut panels, config); + if let Some(panel) = raise { + area = area.raise(panel); + } + area.show(ui) + }; + app.docks.specs = specs; if let Some(error) = &output.error { - log::warn!("docking: {error}"); + log::warn!("docking: {:?}", error.error); } // A body that changed the layout (a panel opened from its own menu) wins over this frame's // gestures, which were made against the old one. - if app.ui.dock.workspace.layout != layout { - craft_ui::docking::cancel_drag::(&ctx, area_id()); + if app.ui.dock.workspace != *shown { + craft_ui::runtime::drag::cancel(&ctx, craft_behavior::CancelReason::HostChanged); return; } - for action in output.actions { + for action in output.actions.into_iter().chain(output.requested) { app.ui.dock.apply(action); } } -/// The panels' contents, names and limits for the dock area. +/// The panels' contents for the dock area. struct Panels<'a> { app: &'a mut MaterialCraftApp, } -impl DockContent for Panels<'_> { - fn body(&mut self, ui: &mut Ui, panel: &Panel) { +impl DockPanels for Panels<'_> { + fn body(&mut self, panel: &Panel, ui: &mut Ui, _: &mut BodyCx<'_>) { let app = &mut *self.app; match panel { - Panel::Graph => crate::graph::show(app, ui), + // The graph is its group's `group_view`. + Panel::Graph => {} Panel::View3d => crate::view3d::show(app, ui), Panel::View2d => crate::view2d::show(app, ui), _ => { @@ -334,31 +382,14 @@ impl DockContent for Panels<'_> { } } - fn logical_label(&self, panel: &Panel) -> String { - match panel { - Panel::Properties => crate::properties::title(self.app), - Panel::Graph => self.app.session.graph().map(|g| format!("{} - {}", g.name, tr("Graph"))).unwrap_or_else(|_| tr("Graph").into()), - Panel::View3d => format!("{} - {}", crate::view3d::scene_label(self.app), tr("3D View")), - Panel::View2d => crate::view2d::title(self.app), - p => tr(p.name()).to_string(), + /// The graph editor, edge to edge in its group. + fn group_view(&mut self, panels: &[Panel], _: usize, ui: &mut Ui, at: GroupAt, _: &mut BodyCx<'_>) -> Option { + let GroupAt::Show(rect) = at else { return None }; + if !panels.contains(&Panel::Graph) { + return None; } - } - - fn label(&mut self, _ui: &Ui, _panel: &Panel, logical: &str, font: &egui::FontId, color: egui::Color32) -> egui::WidgetText { - RichText::new(logical.to_uppercase()).font(font.clone()).strong().color(color).into() - } - - fn permissions(&self, panel: &Panel) -> Permissions { - permissions(panel) - } - - fn limits(&self, panel: &Panel) -> PanelLimits { - let min = if *panel == Panel::Graph { vec2(240.0, 160.0) } else { vec2(120.0, 60.0) }; - PanelLimits { min, ..PanelLimits::default() } - } - - fn floating_size(&self, _panel: &Panel) -> Option { - Some(vec2(420.0, 320.0)) + crate::graph::show(self.app, ui); + Some(rect.height()) } } @@ -371,7 +402,7 @@ mod tests { let w = default_workspace(); assert!(validate(&w).is_ok()); for panel in Panel::ALL { - assert!(w.layout.contains(&panel) || w.hidden.iter().any(|(p, _)| *p == panel), "{panel:?} is neither shown nor hidden"); + assert!(w.layout().contains(&panel) || w.hidden().iter().any(|(p, _)| *p == panel), "{panel:?} is neither shown nor hidden"); } } @@ -379,18 +410,30 @@ mod tests { fn floating_panels_stop_while_a_dialog_is_open() { let mut app = crate::MaterialCraftApp::headless(materialcraft_engine::sample_session(), crate::UiState::default()); let ctx = egui::Context::default(); - let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(1200.0, 800.0))); - let frame = |app: &mut crate::MaterialCraftApp| { - ctx.run_ui(egui::RawInput { screen_rect, ..Default::default() }, |ui| show(app, ui)).textures_delta.clear(); - ctx.data(|data| data.get_temp::(area_id().with("input-blocked"))) - }; + let modal = |app: &mut crate::MaterialCraftApp| app.frame_input(&ctx, Default::default(), 1.0).app_modal; - assert_eq!(frame(&mut app), Some(false)); + assert_eq!(modal(&mut app), None); app.ui.windows.unsaved = Some(crate::unsaved::Guarded::Quit); - assert_eq!(frame(&mut app), Some(true), "the panels stop on the frame the prompt opens"); + assert_eq!(modal(&mut app), Some(egui::ViewportId::ROOT), "the panels stop on the frame the prompt opens"); app.ui.windows.unsaved = None; app.ui.windows.shortcuts = true; - assert_eq!(frame(&mut app), Some(false), "the Shortcuts list does not block"); + assert_eq!(modal(&mut app), None, "the Shortcuts list does not block"); + } + + #[test] + fn a_focused_panel_is_raised_for_one_frame() { + let mut app = crate::MaterialCraftApp::headless(materialcraft_engine::sample_session(), crate::UiState::default()); + let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); + app.ui.dock.focus(Panel::Properties); + assert_eq!(app.ui.dock.raise, Some(Panel::Properties)); + + // The first frame only installs the fonts + for _ in 0..2 { + ctx.run_ui(egui::RawInput::default(), |ui| app.draw(ui)).textures_delta.clear(); + } + + assert_eq!(app.ui.dock.raise, None); } #[test] @@ -401,6 +444,18 @@ mod tests { assert_eq!(back, dock); } + #[test] + fn only_a_reset_replaces_the_workspace() { + let mut dock = Dock::default(); + let start = dock.workspace().generation(); + dock.focus(Panel::Console); + dock.close(Panel::Library); + assert_eq!(dock.workspace().generation(), start); + dock.reset(); + assert_ne!(dock.workspace().generation(), start); + assert_eq!(dock, Dock::default()); + } + #[test] fn the_graph_stays_put_and_panels_come_back() { let mut dock = Dock::default(); diff --git a/crates/ui-egui/src/explorer/actions.rs b/crates/ui-egui/src/explorer/actions.rs index f743227e..72eecb0b 100644 --- a/crates/ui-egui/src/explorer/actions.rs +++ b/crates/ui-egui/src/explorer/actions.rs @@ -158,7 +158,7 @@ pub(super) fn rename_dialog(app: &mut MaterialCraftApp, ctx: &egui::Context) { .show(ctx, |ui| { let response = ui.text_edit_singleline(&mut name); crate::widgets::name(&response, egui::Role::TextInput, "Name"); - if !ctx.memory(|memory| memory.has_focus(response.id)) && !ctx.egui_wants_keyboard_input() { + if !ctx.memory(|memory| memory.has_focus(response.id)) && !crate::framework::widget_has_keyboard(ctx) { response.request_focus(); } accept |= response.lost_focus() && ui.input(|input| input.key_pressed(egui::Key::Enter)); @@ -167,7 +167,7 @@ pub(super) fn rename_dialog(app: &mut MaterialCraftApp, ctx: &egui::Context) { cancel |= ui.button(tr("Cancel")).clicked(); }); }); - cancel |= ctx.input(|input| input.key_pressed(egui::Key::Escape)); + cancel |= crate::framework::escape_pressed(ctx); app.ui.explorer.rename = if open && !cancel { Some((target.clone(), name.clone())) } else { None }; if accept && activate(app, target.document()) { let mut parameters = target.parameters(); diff --git a/crates/ui-egui/src/fonts.rs b/crates/ui-egui/src/fonts.rs index 4be466bc..a1e9d757 100644 --- a/crates/ui-egui/src/fonts.rs +++ b/crates/ui-egui/src/fonts.rs @@ -58,7 +58,7 @@ impl UiFonts { defs.font_data.insert(name.clone(), data); defs.families.entry(FontFamily::Proportional).or_default().push(name.clone()); defs.families.entry(FontFamily::Monospace).or_default().push(name); - ctx.set_fonts(defs); + crate::theme::load_fonts(ctx, defs); self.installed = true; } diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs new file mode 100644 index 00000000..a7f69aeb --- /dev/null +++ b/crates/ui-egui/src/framework.rs @@ -0,0 +1,213 @@ +//! The craft-ui runtime, hosted from MaterialCraft's own eframe `App` (craft-libs docs/craft-framework.md, section +//! 2.2). The desktop app calls [`install`] once, [`MaterialCraftApp::before_input`] in `raw_input_hook`, +//! [`MaterialCraftApp::close_path`] last in `logic`, and [`before_ui`] first in `ui`; the browser build and tests +//! install with [`install_headless`]. The framework dialogs run on [`MaterialCraftApp::framework_dialogs`] after +//! MaterialCraft's own UI. +//! +//! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of MaterialCraft's own egui +//! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] and taken with +//! [`take_window_cancel`]; the graph editor's canvas is declared to the runtime with [`host_canvas`], which keeps the edit +//! chords and the clipboard events in egui's input for MaterialCraft's shortcuts, and Tab while it opens the node search. +//! The focused canvas leaves the keyboard to the shortcuts ([`widget_has_keyboard`]). + +use std::sync::{Arc, OnceLock}; + +use craft_host::target::ShellInfo; +use craft_host::{AppInfo, Host}; +use craft_keymap::{Chord, Key, Overrides}; +use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; +use craft_ui::runtime::commands::{CommandInput, CommandSet as _, NavCommand}; +use craft_ui::runtime::env::{RootEnv, Scale}; +use craft_ui::runtime::focus::{self, EditSet, FocusTarget, KeyUse}; +use craft_ui::runtime::frame::{FrameInput, FrameOutput}; +use craft_ui::runtime::keys::{Intent, with_window_intents}; +use craft_ui::runtime::overlay::{self, OpenFilter}; +use craft_ui::shell::embed::{self, CloseDecision}; +use craft_window::policy::Decision; +use craft_window::system::WindowSystem; + +use crate::MaterialCraftApp; +use crate::shell::modality::Modality; +use egui::ViewportId; + +/// Each pass of the root window, first in `App::ui`: hands the runtime the native window it answers the hit test of +/// (Windows) and fits the window to its monitor once. +#[cfg(not(target_arch = "wasm32"))] +pub use craft_ui::shell::embed::before_ui; + +/// The environment-variable prefix of the frame override: `MATERIALCRAFT_TITLEBAR`. +#[cfg(not(target_arch = "wasm32"))] +const FRAME_PREFIX: craft_window::Prefix = craft_window::Prefix::new("MATERIALCRAFT"); + +/// The scripts of the interface languages, for the font stack. +static SCRIPTS: I18nScripts = I18nScripts; + +/// The runtime's first font stack: egui's bundled faces and no installed system fonts. MaterialCraft's own definitions +/// ([`crate::theme::install`]) replace it before anything is drawn. +fn ui_fonts() -> UiFonts<'static> { + UiFonts::new(&SCRIPTS).system_fonts(SystemFonts::Off) +} + +fn install_with(ctx: &egui::Context, shell: ShellInfo, windows: Arc, frame: Option) -> Result<(), String> { + let mut spec = craft_ui::InstallSpec::new(shell, windows).app_id(crate::os_window::app_id()); + if let Some(frame) = frame { + spec = spec.frame(frame); + } + embed::install(ctx, spec, &ui_fonts()).map(drop).map_err(|error| format!("the UI runtime could not be installed: {error}")) +} + +/// Who draws the main window's frame. The app's bar is the title bar only where the desktop leaves the frame to the +/// app (GNOME on Wayland) or `MATERIALCRAFT_TITLEBAR=app` asks for it; everywhere else the system draws it. Call it +/// once, before the window exists: the desktop app builds its window with [`craft_window::policy::apply`] and hands +/// the decision to [`install`]. +#[cfg(not(target_arch = "wasm32"))] +pub fn decide_frame() -> Decision { + use craft_window::policy::{TitleBarPref, decide_for}; + let pref = if craft_window::Choice::probe(FRAME_PREFIX).frame().decorations() { TitleBarPref::System } else { TitleBarPref::Integrated }; + decide_for(FRAME_PREFIX, craft_host::target::Backend::from_env(), pref) +} + +/// Installs the runtime on the desktop window's context, once, before the first pass, with the window's `frame`. +#[cfg(not(target_arch = "wasm32"))] +pub fn install(ctx: &egui::Context, frame: Decision) -> Result<(), String> { + let shell = ShellInfo::default().backend(craft_host::target::Backend::from_env()); + install_with(ctx, shell, Arc::new(craft_window::system::SystemWindows), Some(frame)) +} + +/// Installs the runtime on a context with no native window of its own: the browser build's canvas and test windows. +pub fn install_headless(ctx: &egui::Context) { + if let Err(error) = install_with(ctx, ShellInfo::default(), Arc::new(craft_window::system::NoWindows), None) { + log::warn!("{error}"); + } +} + +/// Who MaterialCraft is to the framework's dialogs (the update dialogs show its name and icon). +pub(crate) fn host() -> Arc { + Arc::new( + Host::builder(AppInfo { id: "materialcraft", name: "MaterialCraft", version: materialcraft_engine::VERSION }) + .icon_png(include_bytes!("../../../assets/app-icon/hicolor/128x128/apps/ai.storyteller.materialcraft.png")) + .build(), + ) +} + +/// Preferences > Shortcuts assigns any chord to a node, so the runtime's F6 and Shift+F6 pane moves are unbound. +/// Overrides are keyed by command id, which the command set gives. +fn command_overrides() -> Arc { + static OVERRIDES: OnceLock> = OnceLock::new(); + OVERRIDES + .get_or_init(|| { + let mut overrides = Overrides::new(); + for id in [NavCommand::NextPane.id(), NavCommand::PreviousPane.id()] { + overrides.insert(id, Vec::new()); + } + Arc::new(overrides) + }) + .clone() +} + +impl MaterialCraftApp { + /// The framework's part of `App::raw_input_hook`, once per frame before the first pass: takes what the runtime + /// gathered since the last frame and gives the coming passes the root values (theme mode, interface scale and + /// direction). + pub fn before_input(&mut self, ctx: &egui::Context) { + // MaterialCraft applies the interface scale itself (`step`), so the runtime keeps the zoom it applied last. + let scale = ctx.zoom_factor(); + embed::before_input(ctx, |output| self.frame_input(ctx, output, scale)); + } + + /// The root values of this frame. MaterialCraft registers no commands with the runtime (it unbinds the framework's + /// pane moves, [`command_overrides`]) and lets it toggle no chrome, so the output carries nothing it acts on. While one of MaterialCraft's own egui modals shows in the + /// root window, the runtime blocks the panels floated into windows of their own. + pub(crate) fn frame_input(&mut self, ctx: &egui::Context, _output: FrameOutput, scale: f32) -> FrameInput { + use crate::theme::Brightness; + let mode = match self.ui.prefs.brightness { + Brightness::Light | Brightness::MediumLight => craft_theme::Mode::Light, + Brightness::Dark | Brightness::MediumDark => craft_theme::Mode::Dark, + }; + let direction = if crate::i18n::is_rtl() { craft_i18n::Direction::Rtl } else { craft_i18n::Direction::Ltr }; + let root = RootEnv::new().mode(mode).scale(Scale::new(scale)).direction(direction); + let app_modal = Modality::capture(self, ctx).is_blocked().then_some(ViewportId::ROOT); + FrameInput::new(root).commands(CommandInput::new().overrides(command_overrides())).host(Arc::clone(&self.framework_host)).app_modal(app_modal) + } + + /// The framework's part of `App::logic`, after MaterialCraft's own: the root window's close path. Unsaved work + /// holds the window open while Save / Discard / Cancel asks ([`crate::unsaved::close_requested`]); a confirmed + /// quit closes it. + pub fn close_path(&mut self, ctx: &egui::Context) { + embed::logic(ctx, || if crate::unsaved::close_requested(self) { CloseDecision::Hold } else { CloseDecision::Close }); + } +} + +/// The graph editor's canvas widget, the window's document canvas. The material, function and FX-Map editors share it, +/// so it keeps the focus when one replaces another. +pub fn canvas_id() -> egui::Id { + egui::Id::unique("materialcraft-graph-canvas") +} + +/// Declares the graph editor's canvas, drawn in this pass, as the window's document canvas. With nothing or the canvas +/// focused, the edit chords and the clipboard events stay in egui's input for MaterialCraft's shortcuts. With +/// `opens_search` the focused canvas claims a bare Tab, which opens its node search; Shift+Tab always moves on from +/// it, and Tab does otherwise. +pub(crate) fn host_canvas(ctx: &egui::Context, opens_search: bool) { + const KEYS: KeyUse = KeyUse::CANVAS.with_edits(EditSet::ALL); + const TAB: [Chord; 1] = [Chord::plain(Key::Tab)]; + const SEARCH_KEYS: KeyUse = KEYS.with_claims(&TAB); + // The claim would hold with nothing focused too, where a bare Tab moves the focus into the window + let claims_tab = opens_search && ctx.memory(|memory| memory.has_focus(canvas_id())); + focus::host_canvas(ctx, canvas_id(), if claims_tab { SEARCH_KEYS } else { KEYS }); +} + +/// Gives the canvas the keyboard focus, with the arrows and Escape its own. +pub(crate) fn focus_canvas(ctx: &egui::Context) { + focus::request(ctx, FocusTarget::Id(canvas_id())); +} + +/// The widget that has the keyboard, the canvas left out: the focused canvas leaves the keyboard to MaterialCraft's +/// shortcuts, as with nothing focused. +pub(crate) fn focused_widget(ctx: &egui::Context) -> Option { + ctx.memory(|memory| memory.focused()).filter(|focused| *focused != canvas_id()) +} + +/// Whether a widget other than the canvas has the keyboard. +pub(crate) fn widget_has_keyboard(ctx: &egui::Context) -> bool { + focused_widget(ctx).is_some() +} + +/// Whether a dialog, MaterialCraft's, egui's or the framework's, the home screen, or an egui menu or popup is up. +pub(crate) fn overlay_open(app: &MaterialCraftApp, ctx: &egui::Context) -> bool { + app.ui.windows.home || Modality::capture(app, ctx).is_blocked() || egui::Popup::is_any_open(ctx) || overlay::any_open(ctx, OpenFilter::Modal) +} + +/// Whether Escape was pressed in this pass: from egui while one of MaterialCraft's own widgets or popups has the +/// keyboard, otherwise the window's cancel, which the runtime routes to no component. Leaves it for later readers. +pub(crate) fn escape_pressed(ctx: &egui::Context) -> bool { + ctx.input(|i| i.key_pressed(egui::Key::Escape)) || window_cancel(ctx, false) +} + +/// Takes the window's cancel (an Escape while nothing has framework focus) when it is there: no later reader sees it. +pub(crate) fn take_window_cancel(ctx: &egui::Context) -> bool { + window_cancel(ctx, true) +} + +/// Releases the keyboard from a framework widget (a dock tab row, a panel's drag band) when nothing took the Escape +/// pressed on it, as egui does for MaterialCraft's own widgets. Called last in the UI: what is drawn before it takes its +/// Escape first. A framework modal keeps the focus in it, and a text field its own. +pub(crate) fn release_keyboard(ctx: &egui::Context) { + if let Some(focused) = focused_widget(ctx) + && !ctx.text_edit_focused() + && !overlay::any_open(ctx, OpenFilter::Modal) + && take_window_cancel(ctx) + { + ctx.memory_mut(|memory| memory.surrender_focus(focused)); + } +} + +/// Whether the window's cancel is there and untaken; `take` takes it. +fn window_cancel(ctx: &egui::Context, take: bool) -> bool { + let mut pending = false; + with_window_intents(ctx, false, |intents| { + pending = if take { intents.take(Intent::Cancel) } else { intents.untaken(&Intent::Cancel) }; + take && pending + }); + pending +} diff --git a/crates/ui-egui/src/function/canvas.rs b/crates/ui-egui/src/function/canvas.rs index c64739d3..37d0dd45 100644 --- a/crates/ui-egui/src/function/canvas.rs +++ b/crates/ui-egui/src/function/canvas.rs @@ -39,6 +39,8 @@ pub(super) fn canvas(app: &mut MaterialCraftApp, editor: &mut FunctionEditor, ui super::input::handle(app, editor, ui, &frame.response, &frame.ports, &frame.geometry, on_annotation); let camera = GraphCamera { origin: frame.response.rect.min, pan: editor.pan, zoom: editor.zoom }; super::search::show(app, editor, ui, &camera); + let over_canvas = crate::graph::canvas_focus::under_pointer(ui, &frame.response, frame.response.hovered(), super::search::area()); + crate::graph::canvas_focus::settle(app, ui, over_canvas && editor.search.is_none()); frame.geometry.publish(&mut app.graph, frame.response.rect); if editor.drag.is_none() { let camera = GraphCamera { origin: frame.response.rect.min, pan: editor.pan, zoom: editor.zoom }; diff --git a/crates/ui-egui/src/function/input.rs b/crates/ui-egui/src/function/input.rs index 56fc4361..65675879 100644 --- a/crates/ui-egui/src/function/input.rs +++ b/crates/ui-egui/src/function/input.rs @@ -137,7 +137,8 @@ pub(super) fn handle( } } - if response.clicked() && !on_wire && !ui.input(|input| input.modifiers.alt) { + // A click of the pointer: Enter and Space on the focused canvas make it `clicked` too + if response.clicked_by(egui::PointerButton::Primary) && !on_wire && !ui.input(|input| input.modifiers.alt) { crate::graph::node_selection::select(&mut editor.selection, None, ui.input(|input| input.modifiers)); crate::graph::node_selection::select(&mut editor.selected_wires, None, ui.input(|input| input.modifiers)); } @@ -189,7 +190,7 @@ pub(super) fn handle( // Space or Tab over the canvas, or a double-click on empty canvas, searches for a node to add // Tab moves focus between widgets, so it waits only for text fields and focus held before this frame - let space = !ui.ctx().egui_wants_keyboard_input() && ui.input(|input| input.key_pressed(egui::Key::Space)); + let space = !crate::framework::widget_has_keyboard(ui.ctx()) && ui.input(|input| input.key_pressed(egui::Key::Space)); let tab = app.ui.prefs.tab_opens_node_search && !app.graph.keyboard_was_focused && !ui.ctx().text_edit_focused() @@ -205,7 +206,7 @@ pub(super) fn handle( editor.menu_at = camera.to_graph(pointer_position); editor.search = Some(FunctionSearch::at(editor.menu_at, None)); } - response.context_menu(|ui| { + crate::graph::canvas_focus::context_menu(response, |ui| { super::context_menu::show(app, editor, ui, None); }); } diff --git a/crates/ui-egui/src/function/render.rs b/crates/ui-egui/src/function/render.rs index d30c3e77..636360ef 100644 --- a/crates/ui-egui/src/function/render.rs +++ b/crates/ui-egui/src/function/render.rs @@ -7,7 +7,8 @@ use egui::{Align2, Color32, Rect, Sense, Stroke, Ui, Vec2, pos2, vec2}; use std::collections::{BTreeMap, BTreeSet}; pub(super) fn paint(app: &mut MaterialCraftApp, editor: &mut FunctionEditor, ui: &mut Ui) -> Option { - let (canvas_bounds, response) = ui.allocate_exact_size(ui.available_size().max(vec2(200.0, 200.0)), Sense::click_and_drag()); + let size = ui.available_size().max(vec2(200.0, 200.0)); + let (canvas_bounds, response) = crate::graph::canvas_focus::allocate(app, ui, size); app.graph.view = canvas_bounds; let graph = editor.current(app)?; let snap = app.ui.prefs.snap_to_grid; diff --git a/crates/ui-egui/src/function/search.rs b/crates/ui-egui/src/function/search.rs index fc24d6ea..035de780 100644 --- a/crates/ui-egui/src/function/search.rs +++ b/crates/ui-egui/src/function/search.rs @@ -85,12 +85,17 @@ pub(crate) fn pick(app: &mut MaterialCraftApp, editor: &mut FunctionEditor, sear editor.inspected_node = Some(id); } +/// The search popup's area +pub(super) fn area() -> egui::Id { + egui::Id::unique("function-node-search") +} + pub(super) fn show(app: &mut MaterialCraftApp, editor: &mut FunctionEditor, ui: &mut Ui, camera: &GraphCamera) { let blocked = crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked(); let Some(mut search) = editor.search.take() else { return }; let tokens = Tokens::get(ui.ctx()); - let area = egui::Id::unique("function-node-search"); + let area = area(); let mut close = false; let mut chosen = None; egui::Area::new(area).fixed_pos(camera.to_screen(search.at)).order(egui::Order::Foreground).show(ui.ctx(), |ui| { @@ -115,10 +120,11 @@ pub(super) fn show(app: &mut MaterialCraftApp, editor: &mut FunctionEditor, ui: } }); let list = candidates(app, editor, &search.text); - let (up, down, enter, escape) = ui.input(|input| { + let (up, down, enter) = ui.input(|input| { let pressed = |key| !blocked && input.key_pressed(key); - (pressed(egui::Key::ArrowUp), pressed(egui::Key::ArrowDown), pressed(egui::Key::Enter), pressed(egui::Key::Escape)) + (pressed(egui::Key::ArrowUp), pressed(egui::Key::ArrowDown), pressed(egui::Key::Enter)) }); + let escape = !blocked && crate::framework::escape_pressed(ui.ctx()); if down { search.selected_index = (search.selected_index + 1).min(list.len().saturating_sub(1)); } @@ -154,7 +160,10 @@ pub(super) fn show(app: &mut MaterialCraftApp, editor: &mut FunctionEditor, ui: && ui.ctx().pointer_interact_pos().is_some_and(|pointer| !ui.ctx().layer_id_at(pointer).is_some_and(|layer| layer.id == area)); if let Some(candidate) = chosen.filter(|_| !blocked) { pick(app, editor, &search, &candidate); - } else if !close && !clicked_outside { + crate::framework::focus_canvas(ui.ctx()); + } else if close { + crate::framework::focus_canvas(ui.ctx()); + } else if !clicked_outside { editor.search = Some(search); } } diff --git a/crates/ui-egui/src/graph/canvas.rs b/crates/ui-egui/src/graph/canvas.rs index 86543d58..3f069458 100644 --- a/crates/ui-egui/src/graph/canvas.rs +++ b/crates/ui-egui/src/graph/canvas.rs @@ -51,7 +51,8 @@ pub fn show(app: &mut MaterialCraftApp, ui: &mut Ui) { fn canvas(app: &mut MaterialCraftApp, ui: &mut Ui) { let theme = Tokens::get(ui.ctx()); let context = ui.ctx().clone(); - let (rect, response) = ui.allocate_exact_size(ui.available_size(), Sense::click_and_drag()); + let size = ui.available_size(); + let (rect, response) = super::canvas_focus::allocate(app, ui, size); crate::widgets::name(&response, egui::Role::Canvas, "Node graph"); app.graph.view = rect; if app.ui.frame_all || app.graph.framed_graph != Some(app.session.graph) { @@ -350,6 +351,8 @@ fn canvas(app: &mut MaterialCraftApp, ui: &mut Ui) { } super::search::show(app, ui, &camera); + let over_canvas = super::canvas_focus::under_pointer(ui, &response, ui.rect_contains_pointer(rect), super::search::area()); + super::canvas_focus::settle(app, ui, over_canvas && app.graph.search.is_none()); let (failed, placeholders) = app.session.cook_failures(); let mut at = rect.right_bottom() - vec2(8.0, 8.0); if !failed.is_empty() { diff --git a/crates/ui-egui/src/graph/canvas_focus.rs b/crates/ui-egui/src/graph/canvas_focus.rs new file mode 100644 index 00000000..90adeb52 --- /dev/null +++ b/crates/ui-egui/src/graph/canvas_focus.rs @@ -0,0 +1,86 @@ +//! The graph editor's canvas widget and its keyboard focus + +use crate::MaterialCraftApp; +use crate::framework::{canvas_id, focus_canvas, focused_widget, host_canvas, overlay_open}; +use crate::shell::modality::Modality; +use egui::{Id, PointerButton, Popup, Rect, Response, Sense, SetOpenCommand, Ui, Vec2}; + +/// The passes a graph that opens asks for the focus in: the widget that opened it keeps egui's focus for up to two +/// passes, the one it was last drawn in and the one after it went away. +const FOCUS_PASSES: u8 = 3; + +/// Allocate and draw the canvas widget: every editor (material, function, FX-Map) draws the one that has the focus +pub(crate) fn allocate(app: &MaterialCraftApp, ui: &mut Ui, size: Vec2) -> (Rect, Response) { + let (_, rect) = ui.allocate_space(size); + let response = ui.interact(rect, canvas_id(), Sense::click_and_drag()); + // Declared before the widgets on the canvas, for its place in Tab order + host_canvas(ui.ctx(), false); + focus_on_press(app, ui, &response); + (rect, response) +} + +/// A press anywhere on the canvas gives it the keyboard focus. Real presses only: with the canvas focused, egui makes +/// Enter and Space clicks of it. +fn focus_on_press(app: &MaterialCraftApp, ui: &Ui, canvas: &Response) { + let ctx = ui.ctx(); + if !ui.input(|input| input.pointer.any_pressed()) || !ui.rect_contains_pointer(canvas.rect) || Modality::capture(app, ctx).is_blocked() { + return; + } + + // A press in the value being edited on a node stays there + let in_editor = ctx.text_edit_focused() && focused_widget(ctx).and_then(|id| ctx.read_response(id)).is_some_and(|field| field.is_pointer_button_down_on()); + if !in_editor { + focus_canvas(ctx); + } +} + +/// The canvas's context menu. Real clicks only, as for [`focus_on_press`]: Enter picks in the Add node menu and must not +/// close it. +pub(crate) fn context_menu(canvas: &Response, contents: impl FnOnce(&mut Ui)) { + let open = if canvas.secondary_clicked() { + Some(SetOpenCommand::Bool(true)) + } else if canvas.clicked_by(PointerButton::Primary) { + Some(SetOpenCommand::Bool(false)) + } else { + None + }; + Popup::context_menu(canvas).open_memory(open).show(contents); +} + +/// Whether the pointer is over the canvas: `hovered`, or over the node search `search`, which still covers the canvas in +/// the passes after it closes +pub(crate) fn under_pointer(ui: &Ui, canvas: &Response, hovered: bool, search: Id) -> bool { + let ctx = ui.ctx(); + hovered + || ctx.pointer_interact_pos().is_some_and(|pointer| canvas.rect.contains(pointer) && ctx.layer_id_at(pointer).is_some_and(|layer| layer.id == search)) +} + +/// Settle the focus and Tab once the canvas has handled its input. A graph that opens or becomes active asks for the +/// focus, and so does the canvas while nothing is focused and Tab opens its node search (`opens_search`). It waits for a +/// dialog, menu or popup to close, and leaves the focus with a text field and, after [`FOCUS_PASSES`], with a widget +/// of another window. +pub(crate) fn settle(app: &mut MaterialCraftApp, ui: &Ui, opens_search: bool) { + let ctx = ui.ctx(); + let opens_search = opens_search && app.ui.prefs.tab_opens_node_search && !Modality::capture(app, ctx).is_blocked(); + let shown = Some((app.session.document_id, app.session.graph, app.graph.annotation_target.clone())); + if app.graph.shown != shown { + app.graph.shown = shown; + app.graph.focus_passes = FOCUS_PASSES; + } + + let focused = ctx.memory(|memory| memory.focused()); + let unfocused = opens_search && focused.is_none() && !ui.input(|input| input.pointer.any_down()); + if (app.graph.focus_passes > 0 || unfocused) && !overlay_open(app, ctx) { + let same_window = focused.is_none_or(|id| ctx.read_response(id).is_some_and(|widget| widget.layer_id == ui.layer_id())); + if ctx.text_edit_focused() { + app.graph.focus_passes = 0; + } else if same_window { + app.graph.focus_passes = 0; + focus_canvas(ctx); + } else { + app.graph.focus_passes = app.graph.focus_passes.saturating_sub(1); + ctx.request_repaint(); + } + } + host_canvas(ctx, opens_search); +} diff --git a/crates/ui-egui/src/graph/canvas_tests.rs b/crates/ui-egui/src/graph/canvas_tests.rs index de23bc95..f09c0201 100644 --- a/crates/ui-egui/src/graph/canvas_tests.rs +++ b/crates/ui-egui/src/graph/canvas_tests.rs @@ -97,6 +97,7 @@ fn clicked_wires_swap_with_x_and_delete_together() { app.run("graph.connect", json!({"from": a, "to": blend, "toPort": "foreground"})); app.run("graph.connect", json!({"from": b, "to": blend, "toPort": "background"})); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut frame = |app: &mut MaterialCraftApp, mut events: Vec, modifiers: egui::Modifiers| { events.insert(0, egui::Event::ModifiersChanged(modifiers)); let input = egui::RawInput { events, ..Default::default() }; diff --git a/crates/ui-egui/src/graph/frames.rs b/crates/ui-egui/src/graph/frames.rs index b9bf8ebc..a79edcb1 100644 --- a/crates/ui-egui/src/graph/frames.rs +++ b/crates/ui-egui/src/graph/frames.rs @@ -13,8 +13,9 @@ pub(super) struct Frames { impl Frames { /// `session` after a few frames, so the canvas is laid out pub(super) fn new(session: materialcraft_engine::Session) -> Frames { - let mut f = - Frames { ctx: egui::Context::default(), app: MaterialCraftApp::headless(session, crate::UiState::default()), time: 0.0, canvas_text: Vec::new() }; + let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); + let mut f = Frames { ctx, app: MaterialCraftApp::headless(session, crate::UiState::default()), time: 0.0, canvas_text: Vec::new() }; for _ in 0..3 { f.run(Vec::new(), egui::Modifiers::NONE); } diff --git a/crates/ui-egui/src/graph/function_search_tests.rs b/crates/ui-egui/src/graph/function_search_tests.rs index 4648308d..77d30415 100644 --- a/crates/ui-egui/src/graph/function_search_tests.rs +++ b/crates/ui-egui/src/graph/function_search_tests.rs @@ -103,6 +103,21 @@ fn space_tab_and_double_click_open_the_search_and_enter_adds() { assert!(nodes.iter().any(|(_, op, _)| op == "add")); } +#[test] +fn space_on_the_focused_canvas_keeps_the_selection() { + let (mut frames, constant) = function_canvas(); + let at = empty(&frames); + frames.click(at, Modifiers::NONE); + let selection = vec![materialcraft_engine::core::NodeId(u64::from(constant))]; + frames.app.session.selection = selection.clone(); + frames.run(Vec::new(), Modifiers::NONE); + assert_eq!(frames.ctx.memory(|memory| memory.focused()), Some(crate::framework::canvas_id())); + + frames.run(vec![press(Key::Space)], Modifiers::NONE); + assert!(search(&frames).is_some()); + assert_eq!(frames.app.session.selection, selection, "egui's click for Space selects nothing"); +} + #[test] fn wires_dropped_on_empty_canvas_search_and_connect_the_new_node() { let (mut frames, constant) = function_canvas(); diff --git a/crates/ui-egui/src/graph/gesture.rs b/crates/ui-egui/src/graph/gesture.rs index 94d18680..bdd7e5b5 100644 --- a/crates/ui-egui/src/graph/gesture.rs +++ b/crates/ui-egui/src/graph/gesture.rs @@ -9,5 +9,5 @@ pub(crate) fn finished(ui: &Ui, owner: PointerButton) -> bool { } pub(crate) fn cancelled(ui: &Ui) -> bool { - ui.input(|input| !input.focused || input.key_pressed(egui::Key::Escape)) + !ui.input(|input| input.focused) || crate::framework::escape_pressed(ui.ctx()) } diff --git a/crates/ui-egui/src/graph/graph_camera.rs b/crates/ui-egui/src/graph/graph_camera.rs index 36caaa62..220b13a0 100644 --- a/crates/ui-egui/src/graph/graph_camera.rs +++ b/crates/ui-egui/src/graph/graph_camera.rs @@ -58,7 +58,7 @@ impl GraphCamera { pub(crate) fn frame_key(ui: &Ui, view: Rect) -> bool { ui.rect_contains_pointer(view) - && !ui.ctx().egui_wants_keyboard_input() + && !crate::framework::widget_has_keyboard(ui.ctx()) && ui.input(|input| input.key_pressed(egui::Key::F) && input.modifiers.is_none()) } } diff --git a/crates/ui-egui/src/graph/graph_view.rs b/crates/ui-egui/src/graph/graph_view.rs index e390694b..28061ea2 100644 --- a/crates/ui-egui/src/graph/graph_view.rs +++ b/crates/ui-egui/src/graph/graph_view.rs @@ -5,6 +5,10 @@ use materialcraft_engine::core::NodeId; pub struct GraphView { pub(crate) inspected_node: Option, pub(crate) keyboard_was_focused: bool, + /// The document, graph and nested editor shown last frame + pub(super) shown: Option<(u64, usize, materialcraft_engine::AnnotationTarget)>, + /// The passes left in which the canvas asks for the keyboard focus, after what is shown changed + pub(super) focus_passes: u8, pub(super) thumbnails_cleared: bool, pub(super) drag: Option, pub(super) search: Option, @@ -56,6 +60,8 @@ impl Default for GraphView { GraphView { inspected_node: None, keyboard_was_focused: false, + shown: None, + focus_passes: 0, thumbnails_cleared: false, drag: None, search: None, diff --git a/crates/ui-egui/src/graph/input.rs b/crates/ui-egui/src/graph/input.rs index 6c077ae8..d4e420ab 100644 --- a/crates/ui-egui/src/graph/input.rs +++ b/crates/ui-egui/src/graph/input.rs @@ -239,7 +239,7 @@ pub(super) fn handle( } let at = app.graph.menu_at; - canvas.context_menu(|ui| match app.graph.menu_wire.clone() { + super::canvas_focus::context_menu(canvas, |ui| match app.graph.menu_wire.clone() { Some(wire) => wire_menu(app, ui, wire, at), None => super::context_menu::show(app, ui, at, None), }); @@ -277,7 +277,7 @@ pub(super) fn handle( && app.graph.search.is_none() && !crate::shell::modality::Modality::capture(app, &context).is_blocked() { - let typing = context.egui_wants_keyboard_input(); + let typing = crate::framework::widget_has_keyboard(&context); let platform = craft_keymap::egui::platform(&context); if !typing && let Some(entry) = context.input(|input| crate::node_shortcuts::pressed(&app.ui.prefs.node_shortcuts, input, platform)) { let under_pointer = camera.to_graph(position); diff --git a/crates/ui-egui/src/graph/mod.rs b/crates/ui-egui/src/graph/mod.rs index be1bed30..210631d8 100644 --- a/crates/ui-egui/src/graph/mod.rs +++ b/crates/ui-egui/src/graph/mod.rs @@ -3,6 +3,7 @@ pub(crate) mod add_node_menu; pub(crate) mod annotation_canvas; pub(crate) mod annotation_input; pub(crate) mod canvas; +pub(crate) mod canvas_focus; mod context_menu; pub(crate) mod frame_hit; #[cfg(test)] diff --git a/crates/ui-egui/src/graph/search.rs b/crates/ui-egui/src/graph/search.rs index 055092a8..518bd402 100644 --- a/crates/ui-egui/src/graph/search.rs +++ b/crates/ui-egui/src/graph/search.rs @@ -5,6 +5,11 @@ use egui_phosphor::regular as icon; use materialcraft_engine::core::NodeId; use serde_json::json; +/// The search popup's area +pub(super) fn area() -> egui::Id { + egui::Id::unique("node-search") +} + pub(super) fn open_search(app: &mut MaterialCraftApp, ctx: &egui::Context, at: Pos2, connect: Option<(NodeId, String)>) { if crate::shell::modality::Modality::capture(app, ctx).is_blocked() { return; @@ -45,7 +50,7 @@ pub(super) fn show(app: &mut MaterialCraftApp, ui: &mut Ui, cam: &GraphCamera) { let screen = cam.to_screen(s.at); let mut close = false; let mut pick: Option<&'static str> = None; - egui::Area::new(egui::Id::unique("node-search")).fixed_pos(screen).order(egui::Order::Foreground).show(ui.ctx(), |ui| { + egui::Area::new(area()).fixed_pos(screen).order(egui::Order::Foreground).show(ui.ctx(), |ui| { egui::Frame::popup(ui.style()).show(ui, |ui| { ui.set_width(260.0); if blocked { @@ -71,10 +76,11 @@ pub(super) fn show(app: &mut MaterialCraftApp, ui: &mut Ui, cam: &GraphCamera) { if s.connect_to.is_some() { list.retain(|definition| !definition.outputs.is_empty()); } - let (up, down, enter, esc) = ui.input(|i| { + let (up, down, enter) = ui.input(|i| { let pressed = |key| !blocked && i.key_pressed(key); - (pressed(egui::Key::ArrowUp), pressed(egui::Key::ArrowDown), pressed(egui::Key::Enter), pressed(egui::Key::Escape)) + (pressed(egui::Key::ArrowUp), pressed(egui::Key::ArrowDown), pressed(egui::Key::Enter)) }); + let esc = !blocked && crate::framework::escape_pressed(ui.ctx()); if down { s.sel = (s.sel + 1).min(list.len().saturating_sub(1)); } @@ -109,7 +115,7 @@ pub(super) fn show(app: &mut MaterialCraftApp, ui: &mut Ui, cam: &GraphCamera) { }); let clicked_out = !blocked && ui.input(|i| i.pointer.any_pressed()) - && ui.ctx().pointer_interact_pos().is_some_and(|p| !ui.ctx().layer_id_at(p).is_some_and(|l| l.id == egui::Id::unique("node-search"))); + && ui.ctx().pointer_interact_pos().is_some_and(|p| !ui.ctx().layer_id_at(p).is_some_and(|l| l.id == area())); if let Some(def) = pick.filter(|_| !crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked()) { let s = app.graph.search.take(); if let Some(s) = s { @@ -124,7 +130,11 @@ pub(super) fn show(app: &mut MaterialCraftApp, ui: &mut Ui, cam: &GraphCamera) { app.run("graph.connect", json!({"from": id.0, "fromPort": output, "to": to.0, "toPort": port})); } } + crate::framework::focus_canvas(ui.ctx()); } else if close || clicked_out { app.graph.search = None; + if close { + crate::framework::focus_canvas(ui.ctx()); + } } } diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 39d1e5f4..4cbd1153 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -41,7 +41,7 @@ pub fn current() -> &'static Language { /// Returns true if `code` is a right-to-left language (e.g. Arabic `"ar"`). pub fn is_rtl_code(code: &str) -> bool { - craft_ui::direction::resolve(code, craft_ui::direction::Setting::Language) == craft_ui::direction::Direction::Rtl + craft_i18n::direction(code) == craft_i18n::Direction::Rtl } /// Returns true if the current UI language is right-to-left. diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index a966e5e9..12a7d296 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -9,6 +9,7 @@ pub mod docking; pub mod explorer; pub mod export; pub mod fonts; +pub mod framework; pub mod function; pub mod graph; mod graph_drag_payload; @@ -28,6 +29,7 @@ mod preview_resolution; #[path = "property/mod.rs"] pub mod properties; mod shell; +mod shortcut_dispatch; pub mod state; pub mod theme; pub mod thumbs; diff --git a/crates/ui-egui/src/material_craft_app.rs b/crates/ui-egui/src/material_craft_app.rs index f148a796..93ddcf7d 100644 --- a/crates/ui-egui/src/material_craft_app.rs +++ b/crates/ui-egui/src/material_craft_app.rs @@ -58,18 +58,23 @@ pub struct MaterialCraftApp { pub(crate) material_export_job: Option>>, /// The held action waiting for the Save dialog the unsaved-changes prompt opened pub(crate) awaiting_save: Option, - /// The window buttons to draw when the app draws the window frame; `None` while the desktop draws it (desktop only) - #[cfg(not(target_arch = "wasm32"))] - pub window_layout: Option, /// Keyboard shortcuts and their dispatch pub(crate) keymap: craft_keymap::Keymap, - pub(crate) dispatcher: craft_keymap::egui::Dispatcher, + pub(crate) dispatcher: crate::shortcut_dispatch::Dispatcher, + /// The dock area's workspace and panel specs between passes + pub(crate) docks: docking::LiveDock, + /// The framework dialogs (the update dialogs), run once per pass after MaterialCraft's own UI + pub framework_dialogs: craft_ui::dialog::DialogHost, + /// Who MaterialCraft is to the framework's dialogs + pub(crate) framework_host: std::sync::Arc, /// What Copy or Cut put on the clipboard this frame, for the system clipboard pub(crate) system_clipboard: Option, /// Fallback fonts for Arabic pub fonts: fonts::UiFonts, /// The icon font is installed (it takes effect on the frame after `set_fonts`) fonts_ready: bool, + /// The frame that only installed the fonts: egui runs it again once they are loaded. + fonts_frame: Option, ui_gesture_active: bool, /// The version this build names itself with: the Launcher's feed identity for a Nightly. pub build_version: String, @@ -143,15 +148,15 @@ impl MaterialCraftApp { #[cfg(not(target_arch = "wasm32"))] material_export_job: None, awaiting_save: None, - #[cfg(not(target_arch = "wasm32"))] - window_layout: None, keymap: menus::keymap(craft_keymap::Platform::current()), - - // Accept clipboard events without duplicating web key commands - dispatcher: craft_keymap::egui::Dispatcher::new().with_repeat(true).with_clipboard_events(true), + dispatcher: crate::shortcut_dispatch::Dispatcher::default(), + docks: docking::LiveDock::default(), + framework_dialogs: craft_ui::dialog::DialogHost::new(), + framework_host: crate::framework::host(), system_clipboard: None, fonts: fonts::UiFonts::default(), fonts_ready: false, + fonts_frame: None, ui_gesture_active: false, build_version: materialcraft_engine::VERSION.to_owned(), build_commit: String::new(), @@ -468,18 +473,19 @@ impl eframe::App for MaterialCraftApp { } } - fn raw_input_hook(&mut self, _ctx: &egui::Context, raw: &mut egui::RawInput) { + fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) { control::feed_input(self, raw); + self.before_input(ctx); } fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { - #[cfg(not(target_arch = "wasm32"))] - self.step_then(ctx, craft_quit::on_close_request); - #[cfg(target_arch = "wasm32")] self.step(ctx); + self.close_path(ctx); } fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) { + #[cfg(not(target_arch = "wasm32"))] + crate::framework::before_ui(ui.ctx(), &*frame); self.draw(ui); #[cfg(not(target_arch = "wasm32"))] self.dialogs.show_pending(Some(&*frame)); @@ -489,13 +495,6 @@ impl eframe::App for MaterialCraftApp { } impl MaterialCraftApp { - /// [`Self::step`], then the platform's close handling, which sees a close `step` canceled - #[cfg(not(target_arch = "wasm32"))] - fn step_then(&mut self, ctx: &egui::Context, close: impl FnOnce(&egui::Context) -> bool) { - self.step(ctx); - close(ctx); - } - /// Per-frame logic before drawing: styles, the control channel, cooking, shortcuts pub fn step(&mut self, ctx: &egui::Context) { if !self.fonts_ready { @@ -503,6 +502,10 @@ impl MaterialCraftApp { ctx.request_repaint(); return; } + if self.reruns_fonts_frame(ctx) { + ctx.request_repaint(); + return; + } i18n::set_language(&self.ui.prefs.language); self.fonts.update(ctx, &self.ui.prefs.language, self.ui.windows.preferences); @@ -527,7 +530,7 @@ impl MaterialCraftApp { self.session.finish_edit(); } - crate::unsaved::handle_close(self, ctx); + crate::unsaved::finish_quit(self, ctx); control::poll(self, ctx); web_files::poll(self); #[cfg(not(target_arch = "wasm32"))] @@ -562,19 +565,29 @@ impl MaterialCraftApp { } } + /// Whether this pass is egui's rerun of the frame that only installed the fonts + fn reruns_fonts_frame(&mut self, ctx: &egui::Context) -> bool { + self.fonts_frame = self.fonts_frame.filter(|frame| *frame == ctx.cumulative_frame_nr()); + self.fonts_frame.is_some() + } + /// Draw the whole window into `ui` pub fn draw(&mut self, ui: &mut egui::Ui) { crate::annotation::activate(self, crate::annotation::target(self)); + let ctx = ui.ctx().clone(); if !self.fonts_ready { self.fonts_ready = true; + self.fonts_frame = Some(ctx.cumulative_frame_nr()); + return; + } + if self.reruns_fonts_frame(&ctx) { return; } - let ctx = ui.ctx().clone(); let t0 = now_ms(); // Tab can focus a menu or toolbar button while drawing; preserve keyboard ownership - self.graph.keyboard_was_focused = ctx.egui_wants_keyboard_input(); + self.graph.keyboard_was_focused = crate::framework::widget_has_keyboard(&ctx); menus::menu_bar(self, ui); if self.ui.prefs.show_toolbar { toolbar::main_toolbar(self, ui); @@ -583,12 +596,14 @@ impl MaterialCraftApp { self.ui.explorer.hovered = false; egui::CentralPanel::default().frame(egui::Frame::NONE.fill(theme::Tokens::get(&ctx).chrome)).show(ui, |ui| docking::show(self, ui)); windows::show(self, &ctx); + self.framework_dialogs.run(ui); + crate::framework::release_keyboard(&ctx); #[cfg(not(target_arch = "wasm32"))] - if self.window_layout.is_some() { + if crate::window_controls::app_draws_frame(&ctx) { crate::window_controls::resize_zones(ui); } - let gesture_active = ctx.input(|input| input.pointer.any_down()) || ctx.egui_wants_keyboard_input(); + let gesture_active = ctx.input(|input| input.pointer.any_down()) || crate::framework::widget_has_keyboard(&ctx); if !gesture_active && (self.ui_gesture_active || ctx.input(|input| input.pointer.any_released())) { self.session.finish_edit(); } diff --git a/crates/ui-egui/src/material_craft_app.test.rs b/crates/ui-egui/src/material_craft_app.test.rs index df5940a0..1634b5f4 100644 --- a/crates/ui-egui/src/material_craft_app.test.rs +++ b/crates/ui-egui/src/material_craft_app.test.rs @@ -57,6 +57,7 @@ mod lib_tests { app.ui.explorer.hovered = true; app.ui.dock.close(crate::docking::Panel::Explorer); let context = egui::Context::default(); + crate::framework::install_headless(&context); context.run_ui(egui::RawInput::default(), |ui| app.draw(ui)).textures_delta.clear(); @@ -79,14 +80,14 @@ mod close_order_tests { fn close_frame(app: &mut MaterialCraftApp) -> bool { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut input = egui::RawInput::default(); input.viewports.entry(egui::ViewportId::ROOT).or_default().events.push(egui::ViewportEvent::Close); let mut canceled = false; ctx.run_ui(input, |ui| { - app.step_then(ui.ctx(), |ctx| { - canceled = ctx.viewport(|viewport| viewport.commands.contains(&egui::ViewportCommand::CancelClose)); - false - }); + app.step(ui.ctx()); + app.close_path(ui.ctx()); + canceled = ui.ctx().viewport(|viewport| viewport.commands.contains(&egui::ViewportCommand::CancelClose)); }) .textures_delta .clear(); @@ -103,7 +104,8 @@ mod close_order_tests { let mut clean = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); clean.fonts_ready = true; clean.session.modified = false; - assert!(!close_frame(&mut clean), "nothing to hold: the hook sees a close to take over"); + // Only the app's decision: a close that goes ahead ends in the platform's quit, which macOS answers by canceling it. + assert!(!crate::unsaved::close_requested(&mut clean), "nothing to hold: the hook sees a close to take over"); } } diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 915ceee6..2fa9f8a9 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -1,6 +1,6 @@ //! Menu actions and shortcuts share stable command ids -use craft_keymap::{Active, Bindable, Binding, Chord, Keymap, Platform, Scope, Scopes}; +use craft_keymap::{Binding, Chord, CommandDef, Keymap, Platform, Scope, Scopes}; use egui::class::HasClasses as _; use serde_json::Value; @@ -251,7 +251,7 @@ pub fn invoke(app: &mut MaterialCraftApp, ctx: &egui::Context, id: &str) { "ui.quit" => ctx.send_viewport_cmd(egui::ViewportCommand::Close), "ui.preferences" => app.ui.windows.preferences = true, "ui.view.graph" => {} - "ui.resetLayout" => app.ui.dock = crate::docking::Dock::default(), + "ui.resetLayout" => app.ui.dock.reset(), "ui.closeAll" => crate::unsaved::guard(app, crate::unsaved::Guarded::Menu { id: id.to_string() }), "file.newPackage" => { app.run("file.newPackage", serde_json::json!({})); @@ -318,7 +318,7 @@ pub(crate) fn shortcut_table() -> Vec<(&'static str, &'static str)> { pub(crate) fn keymap(platform: Platform) -> Keymap { let catalog = shortcut_table() .into_iter() - .filter_map(|(id, text)| Some(Bindable::new(id, id, Scope::app()).with_default(Binding::new(parse_shortcut(text)?)))) + .filter_map(|(id, text)| Some(CommandDef::new(id, id, Scope::app()).with_default(Binding::new(parse_shortcut(text)?)))) .collect(); Keymap::new(catalog, Scopes::new(), platform) } @@ -328,61 +328,61 @@ pub fn shortcut_of(id: &str) -> Option<&'static str> { CATALOG.iter().find(|i| i.id == id).and_then(|i| i.shortcut).or_else(|| materialcraft_engine::find(id).and_then(|c| c.shortcut)) } -/// Draw menu bars with aligned labels and a separate gutter for checkmarks. +/// Draw menu bars with aligned labels and a separate gutter for checkmarks. Where the app draws the window's frame, the +/// menu bar is the window's title bar: the framework's title bar holds it, with the move area and the caption buttons +/// of the desktop's layout. pub fn menu_bar(app: &mut MaterialCraftApp, ui: &mut egui::Ui) { let tokens = Tokens::get(ui.ctx()); - egui::Panel::top("menu_bar").exact_size(24.0).frame(egui::Frame::NONE.fill(tokens.chrome).inner_margin(egui::Margin::symmetric(6, 0))).show(ui, |ui| { - #[cfg(not(target_arch = "wasm32"))] - let window_layout = app.window_layout.clone(); - #[cfg(not(target_arch = "wasm32"))] - if window_layout.is_some() { - craft_window::title_bar::empty_area(ui, ui.max_rect()); - } - - egui::MenuBar::new().ui(ui, |ui| { - let context = ui.ctx().clone(); - #[cfg(not(target_arch = "wasm32"))] - if let Some(layout) = &window_layout { - crate::window_controls::buttons(ui, &context, &layout.left); - } - for top in TOP { - ui.menu_button(tr(top), |ui| { - ui.set_min_width(220.0); - let mut current_submenu: Option<&str> = None; - let items: Vec = CATALOG.iter().filter(|item| item.menu == top).copied().collect(); - for item in &items { - if let Some(submenu) = item.sub { - if current_submenu == Some(submenu) { - continue; - } - - current_submenu = Some(submenu); - ui.menu_button(menu_label(tr(submenu)), |ui| { - for entry in items.iter().filter(|entry| entry.sub == Some(submenu)) { - menu_item(app, &context, ui, entry); - } - }); - continue; - } - - if item.label == "-" { - ui.separator(); - continue; - } - - menu_item(app, &context, ui, item); - } - }); - } - #[cfg(not(target_arch = "wasm32"))] - if let Some(layout) = window_layout.as_ref().filter(|layout| !layout.right.is_empty()) { - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - let mut right = layout.right.clone(); - right.reverse(); - crate::window_controls::buttons(ui, &context, &right); - }); + #[cfg(not(target_arch = "wasm32"))] + if crate::window_controls::app_bar_is_title_bar(ui.ctx()) { + use craft_ui::contract::ShowContainer as _; + egui::Panel::top("menu_bar").frame(egui::Frame::NONE.fill(tokens.chrome)).show(ui, |ui| { + let bar = craft_ui::shell::TitleBar::new().show(ui, |ui, _| menus(app, ui)).output; + if bar.close_requested { + ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close); } }); + return; + } + egui::Panel::top("menu_bar") + .exact_size(24.0) + .frame(egui::Frame::NONE.fill(tokens.chrome).inner_margin(egui::Margin::symmetric(6, 0))) + .show(ui, |ui| menus(app, ui)); +} + +/// The top-level menus, in a menu bar +fn menus(app: &mut MaterialCraftApp, ui: &mut egui::Ui) { + egui::MenuBar::new().ui(ui, |ui| { + let context = ui.ctx().clone(); + for top in TOP { + ui.menu_button(tr(top), |ui| { + ui.set_min_width(220.0); + let mut current_submenu: Option<&str> = None; + let items: Vec = CATALOG.iter().filter(|item| item.menu == top).copied().collect(); + for item in &items { + if let Some(submenu) = item.sub { + if current_submenu == Some(submenu) { + continue; + } + + current_submenu = Some(submenu); + ui.menu_button(menu_label(tr(submenu)), |ui| { + for entry in items.iter().filter(|entry| entry.sub == Some(submenu)) { + menu_item(app, &context, ui, entry); + } + }); + continue; + } + + if item.label == "-" { + ui.separator(); + continue; + } + + menu_item(app, &context, ui, item); + } + }); + } }); } @@ -454,12 +454,21 @@ fn menu_item(app: &mut MaterialCraftApp, context: &egui::Context, ui: &mut egui: } } -/// Dispatch shortcuts unless a widget, popup or dialog owns the keyboard +/// Dispatch shortcuts unless a widget other than the canvas, a popup or a dialog owns the keyboard pub fn shortcuts(app: &mut MaterialCraftApp, ctx: &egui::Context) { - if ctx.egui_wants_keyboard_input() || egui::Popup::is_any_open(ctx) { + if crate::framework::widget_has_keyboard(ctx) || egui::Popup::is_any_open(ctx) { return; } + // A plain Escape no widget of MaterialCraft's took is the window's cancel: it runs the Escape shortcuts + if crate::framework::take_window_cancel(ctx) { + let held = craft_ui::runtime::keys::escape_mods(ctx).unwrap_or_default(); + let modifiers = egui::Modifiers { shift: held.shift, alt: held.alt, ..Default::default() }; + ctx.input_mut(|i| { + i.events.insert(0, egui::Event::Key { key: egui::Key::Escape, physical_key: Some(egui::Key::Escape), pressed: true, repeat: false, modifiers }); + }); + } + // The desktop sends Copy, Cut and Paste events in place of their key presses if !ctx .input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Key { pressed: true, .. } | egui::Event::Copy | egui::Event::Cut | egui::Event::Paste(_)))) @@ -491,10 +500,16 @@ pub fn shortcuts(app: &mut MaterialCraftApp, ctx: &egui::Context) { let gesture_in_progress = ctx.input(|i| i.pointer.any_down()); let node_search_open = app.graph.search_is_open() || app.function_editor.as_ref().is_some_and(|editor| editor.search.is_some()); let hits = ctx.input_mut(|i| { - app.dispatcher.dispatch_filtered(i, &app.keymap, &Active::NONE, |hit| { + app.dispatcher.dispatch_filtered(i, &app.keymap, |hit| { let id = hit.command.id.as_str(); let keeps_escape = id == "ui.cook.cancel" && (!app.cooker.busy() || gesture_in_progress || node_search_open || label_selected); - modality.allows(id) && !(label_selected && matches!(id, "edit.copy" | "edit.cut")) && !unavailable_clipboard_commands.contains(&id) && !keeps_escape + // The runtime's Quit runs Ctrl+Q, in the panels' own windows and from text fields too + let runtime_quits = id == "ui.quit"; + modality.allows(id) + && !runtime_quits + && !(label_selected && matches!(id, "edit.copy" | "edit.cut")) + && !unavailable_clipboard_commands.contains(&id) + && !keeps_escape }) }); for hit in hits { @@ -551,7 +566,7 @@ mod tests { owners.entry(chord.to_string()).or_insert((id, chord)); } for (id, chord) in owners.into_values() { - assert_eq!(map.lookup(&chord, false, &Active::NONE), craft_keymap::Lookup::Run(id.into()), "{chord}"); + assert_eq!(map.lookup(&chord, false, &craft_keymap::Active::NONE), craft_keymap::Lookup::Run(id.into()), "{chord}"); } } } @@ -782,7 +797,9 @@ mod tests { let mut app = app(); app.ui.recent.push("recent.sbs".into()); - let mut harness = egui_kittest::Harness::builder().build_ui_state(|ui, app: &mut MaterialCraftApp| menu_bar(app, ui), app); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_ui_state(|ui, app: &mut MaterialCraftApp| menu_bar(app, ui), app); harness.run_steps(2); harness.get_by_label("File").click(); harness.run_steps(3); @@ -802,7 +819,9 @@ mod tests { let mut app = app(); app.dialogs.ask(craft_dialogs::FileDialog::open(), crate::native_dialogs::Then::OpenPackage); - let mut harness = egui_kittest::Harness::builder().build_ui_state(|ui, app: &mut MaterialCraftApp| menu_bar(app, ui), app); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_ui_state(|ui, app: &mut MaterialCraftApp| menu_bar(app, ui), app); harness.run_steps(2); harness.get_by_label("File").click(); harness.run_steps(3); @@ -898,7 +917,7 @@ mod tests { #[test] fn a_web_copy_press_runs_edit_copy() { let mut app = app(); - app.dispatcher = craft_keymap::egui::Dispatcher::new().with_repeat(true).with_clipboard_events(true); + app.dispatcher = crate::shortcut_dispatch::Dispatcher::default(); app.run("edit.selectAll", serde_json::json!({})); let ctx = egui::Context::default(); copy_event_kept(&mut app, &ctx, press_c(vec![egui::Event::Copy])); @@ -908,7 +927,7 @@ mod tests { #[test] fn selected_label_text_keeps_its_copy_on_the_web() { let mut app = app(); - app.dispatcher = craft_keymap::egui::Dispatcher::new().with_repeat(true).with_clipboard_events(true); + app.dispatcher = crate::shortcut_dispatch::Dispatcher::default(); app.run("edit.selectAll", serde_json::json!({})); let ctx = egui::Context::default(); select_label_text(&ctx); diff --git a/crates/ui-egui/src/native_dialogs.rs b/crates/ui-egui/src/native_dialogs.rs index 83d80743..6b12ee5b 100644 --- a/crates/ui-egui/src/native_dialogs.rs +++ b/crates/ui-egui/src/native_dialogs.rs @@ -63,13 +63,13 @@ impl GraphRef { /// A queue for an app that has no window to wake yet (offscreen snapshots and tests) pub(crate) fn unattached() -> Dialogs { - craft_dialogs::Dialogs::new(std::sync::Arc::new(|| {})) + craft_dialogs::Dialogs::new(craft_dialogs::Wake::none()) } /// A queue whose answers wake the window pub(crate) fn attached(ctx: &egui::Context) -> Dialogs { let ctx = ctx.clone(); - craft_dialogs::Dialogs::new(std::sync::Arc::new(move || ctx.request_repaint())) + craft_dialogs::Dialogs::new(craft_dialogs::Wake::new(move || ctx.request_repaint())) } /// Queue a dialog unless one is already open or waiting, in which case the open one comes forward @@ -141,6 +141,7 @@ pub(crate) fn poll(app: &mut MaterialCraftApp) { Some(path) => chosen(app, then, &path), None => cancelled(app, then), }, + Answer::Saved { path, .. } => chosen(app, then, &path), Answer::Cancelled | Answer::Message(_) => cancelled(app, then), Answer::Unavailable(why) => { app.toast(format!("{}: {why}", tr("The file dialog could not be shown")), true); diff --git a/crates/ui-egui/src/native_dialogs.test.rs b/crates/ui-egui/src/native_dialogs.test.rs index 50d18a31..092dee2c 100644 --- a/crates/ui-egui/src/native_dialogs.test.rs +++ b/crates/ui-egui/src/native_dialogs.test.rs @@ -248,7 +248,7 @@ fn the_prompts_save_with_a_path_saves_and_runs_the_action_at_once() { #[test] fn the_app_shows_a_requested_dialog_and_applies_its_answer() { - let mut harness = egui_kittest::Harness::builder().build_eframe(|_| app()); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|_| app()); harness.step(); harness.step(); let path = temp("frames.sbs"); @@ -452,29 +452,31 @@ fn a_held_close_waits_for_the_save_dialog() { answer_prompt_with_save(&mut app); app.session.modified = false; let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut input = egui::RawInput::default(); input.viewports.entry(egui::ViewportId::ROOT).or_default().events.push(egui::ViewportEvent::Close); - let mut output = ctx.run_ui(input, |ui| crate::unsaved::handle_close(&mut app, ui.ctx())); + let mut output = ctx.run_ui(input, |ui| app.close_path(ui.ctx())); output.textures_delta.clear(); let commands = output.viewport_output.remove(&egui::ViewportId::ROOT).map(|root| root.commands).unwrap_or_default(); assert!(commands.contains(&egui::ViewportCommand::CancelClose)); } +/// The runtime brings a held window forward, a minimized one included, so the prompt can show. #[test] fn a_held_close_restores_a_minimized_window() { - for (minimized, restored) in [(Some(true), true), (Some(false), false), (None, false)] { - let mut app = modified_app_asking_to_quit(); - app.ui.windows.unsaved = None; - let ctx = egui::Context::default(); - let mut input = egui::RawInput::default(); - let root = input.viewports.entry(egui::ViewportId::ROOT).or_default(); - root.minimized = minimized; - root.events.push(egui::ViewportEvent::Close); - let mut output = ctx.run_ui(input, |ui| crate::unsaved::handle_close(&mut app, ui.ctx())); - output.textures_delta.clear(); - let commands = output.viewport_output.remove(&egui::ViewportId::ROOT).map(|root| root.commands).unwrap_or_default(); - assert_eq!(commands.contains(&egui::ViewportCommand::Minimized(false)), restored, "{minimized:?}"); - } + let mut app = modified_app_asking_to_quit(); + app.ui.windows.unsaved = None; + let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); + let mut input = egui::RawInput::default(); + let root = input.viewports.entry(egui::ViewportId::ROOT).or_default(); + root.minimized = Some(true); + root.events.push(egui::ViewportEvent::Close); + let mut output = ctx.run_ui(input, |ui| app.close_path(ui.ctx())); + output.textures_delta.clear(); + let commands = output.viewport_output.remove(&egui::ViewportId::ROOT).map(|root| root.commands).unwrap_or_default(); + assert!(commands.contains(&egui::ViewportCommand::Minimized(false)), "{commands:?}"); + assert!(app.ui.windows.unsaved.is_some(), "the prompt asks"); } #[test] diff --git a/crates/ui-egui/src/pattern/canvas.rs b/crates/ui-egui/src/pattern/canvas.rs index e08af383..f1d3168c 100644 --- a/crates/ui-egui/src/pattern/canvas.rs +++ b/crates/ui-egui/src/pattern/canvas.rs @@ -50,13 +50,15 @@ pub(crate) fn show(app: &mut MaterialCraftApp, ui: &mut Ui) { let points = if slot.is_some() { geometry::wire(source.pos, pointer) } else { geometry::wire(pointer, source.pos) }; ui.painter_at(response.rect).add(egui::epaint::CubicBezierShape::from_points_stroke(points, false, Color32::TRANSPARENT, Stroke::new(2.0, PORT_COLOR))); } - response.context_menu(|ui| super::context_menu::show(app, &mut editor, ui)); + crate::graph::canvas_focus::context_menu(&response, |ui| super::context_menu::show(app, &mut editor, ui)); + crate::graph::canvas_focus::settle(app, ui, false); editor.inspected_node = crate::graph::node_selection::inspected(&editor.selection, editor.inspected_node); app.pattern_editor = Some(editor); } fn paint(app: &mut MaterialCraftApp, editor: &mut PatternEditor, ui: &mut Ui) -> Option { - let (bounds, response) = ui.allocate_exact_size(ui.available_size().max(vec2(100.0, 100.0)), Sense::click_and_drag()); + let size = ui.available_size().max(vec2(100.0, 100.0)); + let (bounds, response) = crate::graph::canvas_focus::allocate(app, ui, size); app.graph.view = bounds; let graph = editor.current(app)?; let selected: std::collections::BTreeSet<_> = editor.selection.iter().copied().collect(); diff --git a/crates/ui-egui/src/pattern/input.rs b/crates/ui-egui/src/pattern/input.rs index e78598b8..c06e93e5 100644 --- a/crates/ui-egui/src/pattern/input.rs +++ b/crates/ui-egui/src/pattern/input.rs @@ -118,7 +118,7 @@ pub(super) fn handle(app: &mut MaterialCraftApp, editor: &mut PatternEditor, ui: } } if response.hovered() - && !ui.ctx().egui_wants_keyboard_input() + && !crate::framework::widget_has_keyboard(ui.ctx()) && ui.input(|input| input.key_pressed(egui::Key::Space)) && !crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked() { diff --git a/crates/ui-egui/src/preference/shortcuts_page.rs b/crates/ui-egui/src/preference/shortcuts_page.rs index 5cb393a9..c6954541 100644 --- a/crates/ui-egui/src/preference/shortcuts_page.rs +++ b/crates/ui-egui/src/preference/shortcuts_page.rs @@ -108,6 +108,11 @@ fn field(app: &mut MaterialCraftApp, ui: &mut Ui, entry: &str, label: &str) { fn capture(app: &mut MaterialCraftApp, ui: &mut Ui) { let Some(entry) = app.ui.preferences.capturing.clone() else { return }; + // A plain Escape cancels the wait; with no field of MaterialCraft's focused it is the window's cancel + if crate::framework::take_window_cancel(ui.ctx()) { + app.ui.preferences.capturing = None; + return; + } let platform = craft_keymap::egui::platform(ui.ctx()); let chord = ui.input(|input| input.events.iter().find_map(|event| crate::node_shortcuts::event_chord(event, platform))); let Some(chord) = chord else { return }; diff --git a/crates/ui-egui/src/preview_disk_cache.rs b/crates/ui-egui/src/preview_disk_cache.rs index e00da1d8..81431e65 100644 --- a/crates/ui-egui/src/preview_disk_cache.rs +++ b/crates/ui-egui/src/preview_disk_cache.rs @@ -240,10 +240,13 @@ fn digest_name(stem: &str) -> bool { stem.len() == 64 && stem.bytes().all(|byte| byte.is_ascii_hexdigit()) } +/// craft-atomic's staging file of a cache file: `.{file}.{pid}-{n}.craft_tmp`, where `file` is the cache file's name or +/// its first part (older craft-atomic cut it to 64 characters). fn staging_name(name: &str) -> bool { - let Some((stem, suffix)) = name.strip_prefix('.').and_then(|name| name.strip_suffix(".craft_tmp")).and_then(|name| name.split_once('.')) else { + let Some((file, suffix)) = name.strip_prefix('.').and_then(|name| name.strip_suffix(".craft_tmp")).and_then(|name| name.rsplit_once('.')) else { return false; }; + let stem = file.split_once('.').map_or(file, |(stem, _)| stem); digest_name(stem) && suffix.split_once('-').is_some_and(|(pid, counter)| pid.parse::().is_ok_and(|pid| pid > 0) && counter.parse::().is_ok()) } diff --git a/crates/ui-egui/src/shell/modality.test.rs b/crates/ui-egui/src/shell/modality.test.rs index f9245397..2f312c4f 100644 --- a/crates/ui-egui/src/shell/modality.test.rs +++ b/crates/ui-egui/src/shell/modality.test.rs @@ -145,6 +145,7 @@ fn a_file_dropped_behind_a_prompt_does_not_reach_the_package() { let mut app = app(); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); frame(&mut app, &ctx, Vec::new()); frame(&mut app, &ctx, Vec::new()); let png = encode(&Image::filled(2, 2, Kind::Gray, [0.5; 4]), "png", Depth::U8, false).unwrap(); diff --git a/crates/ui-egui/src/shortcut_dispatch.rs b/crates/ui-egui/src/shortcut_dispatch.rs new file mode 100644 index 00000000..0706e4bc --- /dev/null +++ b/crates/ui-egui/src/shortcut_dispatch.rs @@ -0,0 +1,250 @@ +//! The frame's key presses and clipboard events as the shortcuts they run: egui's events fed to +//! `craft_keymap::Matcher`, one press at a time in press order. +//! +//! - A press that runs a command is removed from egui's input, with the text it typed; one that +//! runs nothing, or whose hit the caller declines, stays. +//! - Held keys run their command again on each repeat (a held arrow nudges); repeats never count +//! toward a double press. +//! - egui's Copy, Cut and Paste events count as their plain chords (Cmd+C, Cmd+X, Cmd+V; +//! Shift+Delete and Shift+Insert), so the desktop's clipboard events run the edit commands. The +//! web build sends a clipboard press and the clipboard event it causes: the press decides, and +//! its event goes with it when it runs a command and stays otherwise. +//! - The keyboard layout is learned from what plain presses type, and taken from egui when the +//! integration reports whether it is Latin. + +use craft_keymap::{Active, Hit, Key, KeyInput, Keymap, Layout, Matcher, Mods, Platform, Press}; +use egui::{Event, InputState, Key as EguiKey}; + +/// eframe's web build sends a press's Text event first when no text field has focus. +const TEXT_FIRST: bool = cfg!(target_arch = "wasm32"); + +/// What matching carries between frames: the previous press (double presses) and the layout. +#[derive(Default)] +pub(crate) struct Dispatcher { + matcher: Matcher, + layout: Layout, + /// Whether right Alt is held. egui-winit reports AltGr with neither Ctrl nor Alt, so its + /// presses would otherwise teach the layout as plain ones. + right_alt: bool, +} + +impl Dispatcher { + /// The commands this frame's key presses and clipboard events run, in press order, with + /// `accept` deciding each hit before its event is removed. A declined hit is left out and its + /// event, with any text it typed, stays in egui's input in its place. + pub(crate) fn dispatch_filtered(&mut self, input: &mut InputState, keymap: &Keymap, mut accept: impl FnMut(&Hit) -> bool) -> Vec { + let platform = keymap.platform(); + let now = input.time; + let frame_mods = Mods::from_egui(&input.modifiers, platform); + let events = std::mem::take(&mut input.events); + let text_of = text_of_press(&events, TEXT_FIRST); + if let Some(latin) = input.keyboard_layout_is_latin() { + self.layout.set_latin(Some(latin)); + } + self.learn(&events, &text_of, platform); + let causes = clipboard_event_follows(&events, &self.layout, platform, input); + let mut caused_taken: Vec> = vec![None; events.len()]; + let mut drop = vec![false; events.len()]; + let mut hits = Vec::new(); + let mut kept = Vec::with_capacity(events.len()); + for (i, event) in events.into_iter().enumerate() { + match &event { + Event::Key { pressed: true, repeat, .. } => { + let key = key_input(&event, platform, input); + if self.layout.resolve(&key).is_some() { + let press = Press { input: &key, repeat: *repeat, now, active: &Active::NONE, outer: &[] }; + let hit = self.matcher.press(&self.layout, keymap, &press).filter(&mut accept); + if let Some((j, _)) = causes[i] { + caused_taken[j] = Some(hit.is_some()); + } + if let Some(hit) = hit { + hits.push(hit); + if let Some(j) = text_of[i].filter(|_| !(key.mods.cmd || key.mods.ctrl)) { + drop[j] = true; + } + continue; + } + } + } + // Desktop clipboard events, and web ones whose press ran nothing. + Event::Copy | Event::Cut | Event::Paste(_) => match caused_taken[i] { + Some(true) => continue, + Some(false) => {} + None => { + let (key, held) = clipboard_chord(&event, frame_mods); + let press = Press { input: &KeyInput::new(held).with_typed(key), repeat: false, now, active: &Active::NONE, outer: &[] }; + if let Some(hit) = self.matcher.press(&self.layout, keymap, &press).filter(&mut accept) { + hits.push(hit); + continue; + } + } + }, + _ => {} + } + kept.push((i, event)); + } + input.events = kept.into_iter().filter(|(i, _)| !drop[*i]).map(|(_, e)| e).collect(); + hits + } + + /// Teaches the layout what this frame's presses typed. + fn learn(&mut self, events: &[Event], text_of: &[Option], platform: Platform) { + for (event, text) in events.iter().zip(text_of) { + match event { + Event::Key { physical_key: Some(EguiKey::AltRight), pressed, .. } => self.right_alt = *pressed, + Event::WindowFocused(false) => self.right_alt = false, + _ => {} + } + if self.right_alt { + continue; + } + let Some(Event::Text(text)) = text.and_then(|j| events.get(j)) else { continue }; + if let Some(KeyInput { mods, physical: Some(physical), .. }) = KeyInput::from_egui(event, platform) { + self.layout.observe(physical, mods, text); + } + } + } +} + +/// A press as [`KeyInput::from_egui`] reads it, with the Latin layout's character `input` reports +/// for its key. +fn key_input(event: &Event, platform: Platform, input: &InputState) -> KeyInput { + let mut key = KeyInput::from_egui(event, platform).unwrap_or(KeyInput::new(Mods::NONE)); + if let Event::Key { physical_key: Some(physical), .. } = event { + key.latin = input.latin_layout_char(*physical); + } + key +} + +/// A clipboard event's kind. +#[derive(Clone, Copy)] +enum Clip { + Copy, + Cut, + Paste, +} + +fn event_clip(event: &Event) -> Option { + match event { + Event::Copy => Some(Clip::Copy), + Event::Cut => Some(Clip::Cut), + Event::Paste(_) => Some(Clip::Paste), + _ => None, + } +} + +/// The clipboard event a backend sends for a press, if any. +fn clipboard_kind(key: Key, held: Mods) -> Option { + match key { + Key::C if held.cmd => Some(Clip::Copy), + Key::X if held.cmd => Some(Clip::Cut), + Key::V if held.cmd => Some(Clip::Paste), + Key::Delete if held.shift => Some(Clip::Cut), + Key::Insert if held.shift => Some(Clip::Paste), + Key::Insert if held.cmd || held.ctrl => Some(Clip::Copy), + _ => None, + } +} + +/// For each clipboard key press whose clipboard event comes later in the frame, as the web build +/// sends them: the index of that event, and the text of a Paste event. +fn clipboard_event_follows(events: &[Event], layout: &Layout, platform: Platform, input: &InputState) -> Vec)>> { + let mut out = vec![None; events.len()]; + let mut ahead: [Option; 3] = [None; 3]; + for (i, event) in events.iter().enumerate().rev() { + if let Some(seen) = event_clip(event).and_then(|c| ahead.get_mut(c as usize)) { + *seen = Some(i); + } else if let Event::Key { pressed: true, .. } = event { + let chord = layout.resolve(&key_input(event, platform, input)); + let clip = chord.and_then(|c| clipboard_kind(c.key, c.mods)); + if let Some(j) = clip.and_then(|c| ahead.get_mut(c as usize)).and_then(Option::take) { + let text = if let Some(Event::Paste(text)) = events.get(j) { Some(text.clone()) } else { None }; + out[i] = Some((j, text)); + } + } + } + out +} + +/// For each key press, the index of the Text event it typed. egui-winit, and eframe's web text +/// agent while a text field has focus, send the Text after the press, before the next one. +/// With `text_first`, eframe's web build with no text field focused, the Text comes right before +/// its press, and only for a press without Ctrl or Cmd. +fn text_of_press(events: &[Event], text_first: bool) -> Vec> { + let is_text = |e: Option<&Event>| matches!(e, Some(Event::Text(t)) if !t.is_empty()); + let mut out = vec![None; events.len()]; + if text_first { + for (i, event) in events.iter().enumerate().skip(1) { + if let Event::Key { pressed: true, modifiers, .. } = event + && !(modifiers.ctrl || modifiers.command || modifiers.mac_cmd) + && is_text(events.get(i - 1)) + { + out[i] = Some(i - 1); + } + } + return out; + } + let mut text_ahead = None; + for (i, event) in events.iter().enumerate().rev() { + match event { + Event::Key { pressed: true, .. } => out[i] = text_ahead.take(), + _ if is_text(Some(event)) => text_ahead = Some(i), + _ => {} + } + } + out +} + +/// The press a clipboard event stands for, with the modifiers held. Off macOS egui-winit also +/// sends Cut for Shift+Delete and Paste for Shift+Insert. +fn clipboard_chord(event: &Event, held: Mods) -> (Key, Mods) { + let with_cmd = Mods { cmd: true, ..held }; + let shift_only = held.shift && !held.cmd; + match event { + Event::Cut if shift_only => (Key::Delete, held), + Event::Cut => (Key::X, with_cmd), + Event::Paste(_) if shift_only => (Key::Insert, held), + Event::Paste(_) => (Key::V, with_cmd), + _ => (Key::C, with_cmd), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use craft_keymap::{Binding, CommandDef, Scope, Scopes}; + + fn keymap() -> Keymap { + let def = |id: &'static str, binding: &str| CommandDef::new(id, id, Scope::app()).with_default(Binding::parse(binding).unwrap()); + Keymap::new(vec![def("tool.marquee", "M"), def("edit.copy", "Ctrl+C")], Scopes::new(), Platform::Windows) + } + + fn press(key: EguiKey, modifiers: egui::Modifiers) -> Event { + Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers } + } + + /// A press that runs a command leaves egui's input with the text it typed; the others stay, in order. + #[test] + fn a_bound_press_and_its_text_leave_the_input() { + let mut input = InputState::default(); + input.events = + vec![press(EguiKey::M, egui::Modifiers::NONE), Event::Text("m".into()), press(EguiKey::Q, egui::Modifiers::NONE), Event::Text("q".into())]; + let hits = Dispatcher::default().dispatch_filtered(&mut input, &keymap(), |_| true); + assert_eq!(hits.iter().map(|hit| hit.command.id.as_str()).collect::>(), ["tool.marquee"]); + assert_eq!(input.events, [press(EguiKey::Q, egui::Modifiers::NONE), Event::Text("q".into())]); + } + + /// The desktop's Copy event runs the copy command; declined, it stays for egui. + #[test] + fn a_clipboard_event_runs_its_chord_unless_declined() { + let mut input = InputState::default(); + input.events = vec![Event::Copy]; + let hits = Dispatcher::default().dispatch_filtered(&mut input, &keymap(), |_| true); + assert_eq!(hits.iter().map(|hit| hit.command.id.as_str()).collect::>(), ["edit.copy"]); + assert!(input.events.is_empty()); + + input.events = vec![Event::Copy]; + assert!(Dispatcher::default().dispatch_filtered(&mut input, &keymap(), |_| false).is_empty()); + assert_eq!(input.events, [Event::Copy]); + } +} diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index d2ab9114..468d2653 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -292,9 +292,19 @@ pub fn font_definitions() -> egui::FontDefinitions { fonts } +/// Gives the context `fonts` through the framework runtime, which keeps its layout memory in step with them. The +/// framework's chrome (the dock, the update dialogs) also draws in the signature and semibold families; both take the +/// proportional faces, as MaterialCraft has no bold face. A family left out draws missing-glyph boxes. +pub fn load_fonts(ctx: &egui::Context, mut fonts: egui::FontDefinitions) { + let proportional = fonts.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); + fonts.families.insert(craft_ui::fonts::FontRef::signature().family(), proportional.clone()); + fonts.families.insert(FontFamily::Name(craft_ui::fonts::SEMIBOLD.into()), proportional); + craft_ui::fonts::load(ctx, fonts); +} + /// Install the fonts (once, at startup; the app applies the style from its settings). pub fn install(ctx: &egui::Context) { - ctx.set_fonts(font_definitions()); + load_fonts(ctx, font_definitions()); } /// Apply brightness `b` and `accent`: store the tokens for [`Tokens::get`] and style egui with @@ -334,8 +344,18 @@ pub fn apply(ctx: &egui::Context, b: Brightness, accent: Accent) { v.selection.stroke = Stroke::new(1.0, t.accent); v.hyperlink_color = t.accent; let w = &mut v.widgets; - craft_ui::theme::WidgetPalette { noninteractive: t.panel, inactive: t.button, hovered: t.row_hover, active: t.tool_active, open: t.row_hover } - .apply_to(w, t.cr(), Stroke::new(1.0, t.text)); + for (widget, fill) in [ + (&mut w.noninteractive, t.panel), + (&mut w.inactive, t.button), + (&mut w.hovered, t.row_hover), + (&mut w.active, t.tool_active), + (&mut w.open, t.row_hover), + ] { + widget.bg_fill = fill; + widget.weak_bg_fill = fill; + widget.corner_radius = t.cr(); + widget.fg_stroke = Stroke::new(1.0, t.text); + } // Hovered and pressed lettering, and `RichText::strong` (captions), in the strong colour. w.hovered.fg_stroke.color = t.text_strong; w.active.fg_stroke.color = t.text_strong; diff --git a/crates/ui-egui/src/unsaved.rs b/crates/ui-egui/src/unsaved.rs index c743e842..dd3812a9 100644 --- a/crates/ui-egui/src/unsaved.rs +++ b/crates/ui-egui/src/unsaved.rs @@ -118,22 +118,25 @@ fn perform(app: &mut MaterialCraftApp, action: Guarded) { } } -/// Per frame: hold back a window close while there is unsaved work, and finish a confirmed quit -pub fn handle_close(app: &mut MaterialCraftApp, ctx: &Context) { - if ctx.input(|i| i.viewport().close_requested()) && !app.quit_confirmed { - // Focused text is still a draft when the OS asks to close the window - crate::properties::GraphPropertyDraft::commit(app); - // While the Save dialog of a held action is open, the close waits for its answer - if app.awaiting_save.is_some() || holds_close(needs_confirmation(&app.session), app.quit_confirmed) { - ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); - // The prompt is drawn only while the window is visible - if ctx.input(|i| i.viewport().minimized) == Some(true) { - ctx.send_viewport_cmd(egui::ViewportCommand::Minimized(false)); - ctx.send_viewport_cmd(egui::ViewportCommand::Focus); - } - guard(app, Guarded::Quit); - } +/// The root window was asked to close: whether unsaved work holds it open. Holding asks Save / Discard / Cancel for +/// the modified packages, and the runtime keeps the window open and brings it forward while the question is up. +/// Runs in the framework's close path ([`MaterialCraftApp::close_path`]). +pub fn close_requested(app: &mut MaterialCraftApp) -> bool { + if app.quit_confirmed { + return false; } + // Focused text is still a draft when the OS asks to close the window + crate::properties::GraphPropertyDraft::commit(app); + // While the Save dialog of a held action is open, the close waits for its answer + let holds = app.awaiting_save.is_some() || holds_close(needs_confirmation(&app.session), app.quit_confirmed); + if holds { + guard(app, Guarded::Quit); + } + holds +} + +/// Per frame: close the window once a quit is confirmed +pub fn finish_quit(app: &MaterialCraftApp, ctx: &Context) { if app.quit_confirmed { ctx.send_viewport_cmd(egui::ViewportCommand::Close); } @@ -174,7 +177,7 @@ pub fn show(app: &mut MaterialCraftApp, ctx: &Context) { } }); }); - if choice.is_none() && ctx.input(|i| i.key_pressed(egui::Key::Escape)) { + if choice.is_none() && crate::framework::escape_pressed(ctx) { choice = Some(Choice::Cancel); } let Some(choice) = choice else { return }; diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index bb1ba492..a8fe0e3a 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -1,8 +1,10 @@ //! Software updates on the desktop: the background check at startup, Help > Check for updates and -//! the prompts that report them. A Nightly has no updater: the Launcher installs it. +//! the prompts that report them, as craft-update's dialogs on the app's +//! [`DialogHost`](craft_ui::dialog::DialogHost). A Nightly has no updater: the Launcher installs it. +use craft_ui::dialog::DialogResult; +use craft_update::stack_dialogs::{CheckChoice, UpdateCheckDialog}; use craft_update::updater::{Action, Status, Updater}; -use craft_update::{CheckResultDialog, CheckResultResponse}; use crate::MaterialCraftApp; @@ -70,9 +72,9 @@ pub(crate) fn tick(app: &mut MaterialCraftApp, ctx: &egui::Context) { rt.repaint = Some(ctx.clone()); let Some(updater) = rt.updater.as_mut() else { return }; if std::mem::take(&mut rt.check_requested) { - updater.check_now(ctx); + updater.check_now(); } else if rt.startup_check { - updater.check_at_start(ctx); + updater.check_at_start(); } updater.tick(ctx); } @@ -84,25 +86,46 @@ fn result_window_shows(status: &Status, prompt_open: bool) -> bool { !prompt_open && !matches!(status, Status::Idle) } +/// One pass of the update flow, before the dialog host runs: answers the result dialog closed in +/// the last pass, drives the startup prompt, and keeps the result dialog open and current while the +/// updater has something to report pub(crate) fn show(app: &mut MaterialCraftApp, ctx: &egui::Context) { let Some(updater) = app.updates_rt.updater.as_mut() else { return }; // An installation, and the close for a ready update, wait until nothing is unsaved let clean = !crate::unsaved::needs_confirmation(&app.session); - match updater.show_if(ctx, clean) { + // Answered before the dialog is kept open below, so a dismissed outcome does not open again at once + match app.framework_dialogs.take::() { + Some(DialogResult::Ok(CheckChoice::CheckNow | CheckChoice::CheckAgain)) => app.updates_rt.check_requested = true, + // The next `run` asks the window to close once nothing is unsaved + Some(DialogResult::Ok(CheckChoice::RestartToUpdate)) => updater.restart_to_update(), + Some(DialogResult::Ok(CheckChoice::Update)) => { + updater.request_install(clean); + } + Some(DialogResult::Ok(CheckChoice::Download)) => ctx.open_url(egui::OpenUrl::new_tab(crate::UPDATE_APP.releases_url())), + // Closing the dialog dismisses the outcome it showed + Some(_) => updater.dismiss_status(), + None => {} + } + match updater.run(&mut app.framework_dialogs, clean) { Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)), Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close), - Action::None => {} + _ => {} } // A found update opens the startup prompt and leaves the status idle, which ends the result dialog - if result_window_shows(updater.status(), updater.prompt_open()) { - match CheckResultDialog::new(&crate::UPDATE_APP, materialcraft_engine::VERSION).with_translator(translate).show(ctx, updater.status()) { - CheckResultResponse::None => {} - // Closing the dialog dismisses the outcome it showed - CheckResultResponse::Close => updater.dismiss_status(), - CheckResultResponse::CheckAgain => app.updates_rt.check_requested = true, - // The next `show_if` asks the window to close once nothing is unsaved - CheckResultResponse::RestartToUpdate => updater.restart_to_update(), - } + let shows = result_window_shows(updater.status(), updater.prompt_open()); + let (status, installing, message) = (updater.status().clone(), updater.is_installing(), updater.status_message()); + let dialogs = &mut app.framework_dialogs; + if shows && !dialogs.is_open::() { + dialogs.open(UpdateCheckDialog::new(materialcraft_engine::VERSION)); + } else if !shows && dialogs.is_open::() { + dialogs.cancel::(ctx); + // Hidden for the prompt, not dismissed: the outcome shows again after it + let _ = dialogs.take::(); + } + if let Some(dialog) = dialogs.get_mut::() { + dialog.set_status(status); + dialog.set_installing(installing); + dialog.set_message(message); } } diff --git a/crates/ui-egui/src/updates_ui.test.rs b/crates/ui-egui/src/updates_ui.test.rs index 4ee2ac0d..39db0153 100644 --- a/crates/ui-egui/src/updates_ui.test.rs +++ b/crates/ui-egui/src/updates_ui.test.rs @@ -112,6 +112,7 @@ fn frame(app: &mut MaterialCraftApp, ctx: &egui::Context) { fn the_menu_command_starts_a_check_on_the_next_frame() { let (mut app, checks, _) = app_with_source(); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); frame(&mut app, &ctx); menus::invoke(&mut app, &ctx, COMMAND); assert!(app.updates_rt.check_requested); @@ -168,11 +169,17 @@ fn an_offered_release_opens_the_prompt_over_the_window() { assert!(blocks_input(&app)); - let mut harness = egui_kittest::Harness::builder().build_ui_state(|ui, app: &mut MaterialCraftApp| crate::windows::show(app, ui.ctx()), app); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_ui_state( + |ui, app: &mut MaterialCraftApp| { + crate::windows::show(app, ui.ctx()); + app.framework_dialogs.run(ui); + }, + app, + ); harness.run_steps(3); - let _ = harness.get_by_label("LATER"); + let _ = harness.get_by_label("Later"); assert!(harness.state().updates_rt.updater.as_ref().unwrap().prompt_open()); } @@ -192,7 +199,13 @@ fn a_requested_check_shows_its_progress() { check(&mut app); tick(&mut app, &egui::Context::default()); - let mut harness = egui_kittest::Harness::builder().build_ui_state(|ui, app: &mut MaterialCraftApp| crate::windows::show(app, ui.ctx()), app); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_ui_state( + |ui, app: &mut MaterialCraftApp| { + crate::windows::show(app, ui.ctx()); + app.framework_dialogs.run(ui); + }, + app, + ); harness.run_steps(3); let _ = harness.get_by_label("Checking for updates…"); drop(release); diff --git a/crates/ui-egui/src/view2d/viewport.rs b/crates/ui-egui/src/view2d/viewport.rs index 3c4079a2..c188ab78 100644 --- a/crates/ui-egui/src/view2d/viewport.rs +++ b/crates/ui-egui/src/view2d/viewport.rs @@ -199,7 +199,7 @@ fn stretch_for(physical: [f32; 3], pixels: [u32; 2]) -> f32 { /// Space toggles tiling, F fits the image and C, R, G, B and A pick the channels, while the pointer is over the image fn keys(app: &mut MaterialCraftApp, ui: &Ui, response: &Response) { - if !response.hovered() || ui.ctx().egui_wants_keyboard_input() || crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked() { + if !response.hovered() || crate::framework::widget_has_keyboard(ui.ctx()) || crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked() { return; } diff --git a/crates/ui-egui/src/view3d/navigation.rs b/crates/ui-egui/src/view3d/navigation.rs index ad0b0bc1..c7ac5261 100644 --- a/crates/ui-egui/src/view3d/navigation.rs +++ b/crates/ui-egui/src/view3d/navigation.rs @@ -130,7 +130,7 @@ pub(super) fn reset_selected(app: &mut MaterialCraftApp) { /// The keys of the view, while the pointer is over it and nothing else has the keyboard fn keys(app: &mut MaterialCraftApp, ui: &Ui, response: &Response) { - if !response.hovered() || ui.ctx().egui_wants_keyboard_input() || crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked() { + if !response.hovered() || crate::framework::widget_has_keyboard(ui.ctx()) || crate::shell::modality::Modality::capture(app, ui.ctx()).is_blocked() { return; } @@ -156,7 +156,7 @@ fn keys(app: &mut MaterialCraftApp, ui: &Ui, response: &Response) { if pressed(Modifiers::NONE, Key::L) { app.view3d.tool = Tool::Light; } - if pressed(Modifiers::NONE, Key::Escape) { + if ui.input(|input| input.modifiers.is_none()) && crate::framework::escape_pressed(ui.ctx()) { app.view3d.selected = false; } } diff --git a/crates/ui-egui/src/web_files/package_save.rs b/crates/ui-egui/src/web_files/package_save.rs index 72afe680..ae6eddb8 100644 --- a/crates/ui-egui/src/web_files/package_save.rs +++ b/crates/ui-egui/src/web_files/package_save.rs @@ -65,7 +65,7 @@ impl PackageSave { }); }); app.ui.windows.package_save = Some(request); - let dismissed = !open || cancel || ctx.input(|input| input.key_pressed(egui::Key::Escape)); + let dismissed = !open || cancel || crate::framework::escape_pressed(ctx); if accept || dismissed { Self::finish(app, accept && !dismissed, download); } diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index f57d83d7..a435544e 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -1,7 +1,6 @@ //! Compact widgets matching the app's look: labelled slim sliders, icon buttons, section //! headers, channel toggle chips and color swatches. -use craft_ui::buttons::{ButtonVisuals, IconButton, IconButtonStyle}; use egui::{Color32, CornerRadius, Response, RichText, Sense, Stroke, Ui, vec2}; use crate::theme::Tokens; @@ -179,24 +178,33 @@ pub fn elided(painter: &egui::Painter, text: impl Into, size: f32, color } /// A square icon button (Phosphor glyph) in a rounded tool well: `selected` sits in the accent -/// tinted well (the shared Craft icon button, `craft_ui::buttons`). +/// tinted well, a hovered one in the row-hover well and a pressed one in the tool well; keyboard +/// focus draws an inset accent outline. `tooltip` is its accessible name and tooltip. A +/// non-finite, non-positive or oversized (over 4096 points) size gives an inert zero-size response. pub fn icon_button(ui: &mut Ui, icon: &str, tooltip: &str, selected: bool, size: f32) -> Response { let tk = Tokens::get(ui.ctx()); - let well = |fill, icon| ButtonVisuals { fill, stroke: Stroke::NONE, icon }; - let style = IconButtonStyle { - normal: well(Color32::TRANSPARENT, tk.text), - hovered: well(tk.row_hover, tk.text_strong), - pressed: Some(well(tk.tool_active, tk.text_strong)), - selected: well(tk.tool_active, tk.text_strong), - corner_radius: CornerRadius::same(6), - focus_stroke: Stroke::new(1.0, tk.accent), + let valid = size.is_finite() && size > 0.0 && size <= 4096.0; + let (rect, response) = ui.allocate_exact_size(if valid { vec2(size, size) } else { egui::Vec2::ZERO }, if valid { Sense::click() } else { Sense::hover() }); + response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, valid && ui.is_enabled(), selected, tooltip)); + if !valid { + return response; + } + let (fill, color) = if selected || response.is_pointer_button_down_on() { + (tk.tool_active, tk.text_strong) + } else if response.hovered() { + (tk.row_hover, tk.text_strong) + } else { + (Color32::TRANSPARENT, tk.text) }; - IconButton::new(tooltip, vec2(size, size), &style) - .selected(selected) - .show(ui, |ui, rect, color| { - ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, icon, egui::FontId::proportional(size * 0.62), color); - }) - .on_hover_text(tooltip) + let radius = CornerRadius::same(6); + if fill != Color32::TRANSPARENT { + ui.painter().rect_filled(rect, radius, fill); + } + ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, icon, egui::FontId::proportional(size * 0.62), color); + if response.has_focus() && rect.width() > 4.0 && rect.height() > 4.0 { + ui.painter().rect_stroke(rect.shrink(2.0), radius, Stroke::new(1.0, tk.accent), egui::StrokeKind::Inside); + } + response.on_hover_text(tooltip) } /// A flat button filled with the accent, white lettering (a dialog's main action). diff --git a/crates/ui-egui/src/window_controls.rs b/crates/ui-egui/src/window_controls.rs index cb0bd4ae..f69141a9 100644 --- a/crates/ui-egui/src/window_controls.rs +++ b/crates/ui-egui/src/window_controls.rs @@ -1,34 +1,20 @@ -//! The menu bar as the title bar, where the desktop leaves the window frame to the app (GNOME on Wayland) +//! The window's own frame where the desktop leaves it to the app (GNOME on Wayland): which frame the runtime has, and +//! the resize zones along the window's edges. The menu bar is the title bar there (`menus::menu_bar`). -use craft_window::Button; +use craft_ui::runtime::windows::WindowHost; +use craft_window::policy::Frame; use egui::viewport::ResizeDirection; -use egui::{Context, CursorIcon, Id, LayerId, Order, PointerButton, Rect, Sense, Ui, ViewportCommand, pos2, vec2}; -use egui_phosphor::regular as icon; +use egui::{CursorIcon, Id, LayerId, Order, PointerButton, Rect, Sense, Ui, ViewportCommand, pos2, vec2}; -use crate::i18n::tr; - -fn label(button: Button) -> &'static str { - match button { - Button::Minimize => "Minimize", - Button::Maximize => "Maximize", - Button::Close => "Close", - } +/// Whether the app's menu bar is the window's title bar: the frame the runtime has for the window is the app's. +pub(crate) fn app_bar_is_title_bar(ctx: &egui::Context) -> bool { + !matches!(WindowHost::of(ctx).frame(), Frame::Native) } -fn glyph(button: Button) -> &'static str { - match button { - Button::Minimize => icon::MINUS, - Button::Maximize => icon::SQUARE, - Button::Close => icon::X, - } -} - -fn command(button: Button, maximized: bool) -> ViewportCommand { - match button { - Button::Minimize => ViewportCommand::Minimized(true), - Button::Maximize => ViewportCommand::Maximized(!maximized), - Button::Close => ViewportCommand::Close, - } +/// Whether the window has no frame of the system's, so the app gives it its resize edges (macOS keeps its own edges +/// under an inset title bar). +pub(crate) fn app_draws_frame(ctx: &egui::Context) -> bool { + matches!(WindowHost::of(ctx).frame(), Frame::Integrated(_)) } const EDGE: f32 = 5.0; @@ -70,18 +56,6 @@ pub(crate) fn resize_zones(ui: &mut Ui) { } } -/// Draw `buttons` in the given left-to-right order -pub(crate) fn buttons(ui: &mut Ui, ctx: &Context, buttons: &[Button]) { - for &button in buttons { - let response = crate::widgets::icon_button(ui, glyph(button), tr(label(button)), false, 18.0); - crate::widgets::name(&response, egui::Role::Button, label(button)); - if response.clicked() { - let maximized = ctx.input(|input| input.viewport().maximized).unwrap_or(false); - ctx.send_viewport_cmd(command(button, maximized)); - } - } -} - #[cfg(test)] #[path = "window_controls.test.rs"] mod tests; diff --git a/crates/ui-egui/src/window_controls.test.rs b/crates/ui-egui/src/window_controls.test.rs index e73504eb..3bf05a57 100644 --- a/crates/ui-egui/src/window_controls.test.rs +++ b/crates/ui-egui/src/window_controls.test.rs @@ -1,13 +1,5 @@ use super::*; -#[test] -fn each_button_sends_its_viewport_command() { - assert_eq!(command(Button::Minimize, false), ViewportCommand::Minimized(true)); - assert_eq!(command(Button::Maximize, false), ViewportCommand::Maximized(true)); - assert_eq!(command(Button::Maximize, true), ViewportCommand::Maximized(false)); - assert_eq!(command(Button::Close, false), ViewportCommand::Close); -} - fn commands_after_press_at(pos: egui::Pos2) -> Vec { let ctx = egui::Context::default(); let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0)); @@ -43,12 +35,22 @@ fn a_press_inside_the_window_does_not_resize() { assert!(!commands.iter().any(|command| matches!(command, ViewportCommand::BeginResize(_))), "{commands:?}"); } +/// The frame decision of a window whose bar the app draws, with the caption buttons of `layout`. +fn app_frame(layout: craft_window::Layout) -> craft_window::policy::Decision { + use craft_window::policy::{CaptionFamily, Captions, Decision}; + let desktop = craft_window::desktop::Desktop { kind: craft_window::desktop::DesktopKind::Other, ssd: Some(false), gtk_theme: None, icon_theme: None }; + Decision { frame: Frame::Integrated(Captions { family: CaptionFamily::Generic, layout }), overridden: Some(true), desktop } +} + #[test] fn the_menu_bar_shows_window_buttons_only_when_the_app_draws_the_frame() { let mut app = crate::MaterialCraftApp::headless(materialcraft_engine::sample_session(), crate::UiState::default()); - let mut labels_drawn = |layout: Option| { - app.window_layout = layout; + let mut labels_drawn = |frame: Option| { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); + if let Some(frame) = frame { + WindowHost::of(&ctx).set_root_frame(frame); + } ctx.enable_accesskit(); let mut output = ctx.run_ui(egui::RawInput::default(), |ui| crate::menus::menu_bar(&mut app, ui)); output.textures_delta.clear(); @@ -59,12 +61,12 @@ fn the_menu_bar_shows_window_buttons_only_when_the_app_draws_the_frame() { let desktop = labels_drawn(None); assert!(!desktop.iter().any(|label| label == "Close"), "{desktop:?}"); - let drawn = labels_drawn(Some(craft_window::Layout::default())); + let drawn = labels_drawn(Some(app_frame(craft_window::Layout::default()))); for button in ["Minimize", "Maximize", "Close"] { assert!(drawn.iter().any(|label| label == button), "{button} in {drawn:?}"); } - let left = labels_drawn(Some(craft_window::Layout { left: vec![Button::Close], right: Vec::new() })); + let left = labels_drawn(Some(app_frame(craft_window::Layout { left: vec![craft_window::Button::Close], right: Vec::new() }))); assert!(left.iter().any(|label| label == "Close"), "{left:?}"); assert!(!left.iter().any(|label| label == "Minimize"), "{left:?}"); } diff --git a/crates/ui-egui/src/windows.test.rs b/crates/ui-egui/src/windows.test.rs index a16a49ae..cd2167d1 100644 --- a/crates/ui-egui/src/windows.test.rs +++ b/crates/ui-egui/src/windows.test.rs @@ -8,16 +8,17 @@ mod home_modality_tests { let app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); // The icon font has to be in place for the frame that first draws Home let mut fonts_installed = false; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - move |ui, app: &mut MaterialCraftApp| { - if std::mem::replace(&mut fonts_installed, true) { - crate::windows::show(app, ui.ctx()); - } else { - crate::theme::install(ui.ctx()); - } - }, - app, - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + move |ui, app: &mut MaterialCraftApp| { + if std::mem::replace(&mut fonts_installed, true) { + crate::windows::show(app, ui.ctx()); + } else { + crate::theme::install(ui.ctx()); + } + }, + app, + ); let app = harness.state_mut(); app.ui.windows.home = true; app.ui.recent.push("recent.sbs".into()); diff --git a/crates/ui-egui/tests/it/canvas_focus.rs b/crates/ui-egui/tests/it/canvas_focus.rs new file mode 100644 index 00000000..0efc5370 --- /dev/null +++ b/crates/ui-egui/tests/it/canvas_focus.rs @@ -0,0 +1,166 @@ +//! The graph canvas as a Tab stop: it keeps the focus Tab gives it, a press and an opening graph give it the focus, Tab +//! over it opens the node search, and its keys work as with nothing focused + +use egui::accesskit::Role; +use egui::{Event, Id, Key, Modifiers, PointerButton, vec2}; +use egui_kittest::{ + Harness, + kittest::{By, Queryable}, +}; +use materialcraft_ui_egui::framework::{canvas_id, install_headless}; +use materialcraft_ui_egui::{MaterialCraftApp, UiState, menus}; + +type AppHarness = Harness<'static, MaterialCraftApp>; + +fn harness(session: materialcraft_engine::Session) -> AppHarness { + let mut h = Harness::builder().with_context_setup(install_headless).with_size(vec2(1600.0, 960.0)).build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + MaterialCraftApp::headless(session, UiState::default()), + ); + h.run_steps(8); + h +} + +fn focused(h: &AppHarness) -> Option { + h.ctx.memory(|memory| memory.focused()) +} + +fn press(h: &mut AppHarness, modifiers: Modifiers, key: Key) -> Option { + h.key_press_modifiers(modifiers, key); + h.run_steps(3); + focused(h) +} + +fn search_open(h: &AppHarness) -> bool { + h.query_by_label("Search nodes").is_some() +} + +fn hover_canvas(h: &mut AppHarness) { + h.hover_at(h.state().graph.view.center()); + h.run_steps(2); +} + +#[test] +fn tab_walks_over_the_canvas_to_the_stops_after_it_and_back() { + let mut h = harness(materialcraft_engine::new_session()); + let canvas = Some(canvas_id()); + assert_eq!(focused(&h), canvas, "an opened graph has the keyboard"); + + let after = press(&mut h, Modifiers::NONE, Key::Tab); + assert!(after.is_some() && after != canvas, "Tab moves on from the canvas"); + assert_eq!(press(&mut h, Modifiers::SHIFT, Key::Tab), canvas); + let before = press(&mut h, Modifiers::SHIFT, Key::Tab); + assert!(before.is_some() && before != canvas && before != after, "Shift+Tab leaves it backward"); + assert_eq!(press(&mut h, Modifiers::NONE, Key::Tab), canvas, "Tab from the stop before it stops at it"); + assert_eq!(press(&mut h, Modifiers::NONE, Key::Tab), after, "and reaches the stop after it"); + assert!(!search_open(&h)); +} + +#[test] +fn tab_with_the_pointer_over_the_canvas_opens_the_search_and_shift_tab_leaves_it() { + let mut h = harness(materialcraft_engine::new_session()); + let canvas = Some(canvas_id()); + hover_canvas(&mut h); + let left = press(&mut h, Modifiers::SHIFT, Key::Tab); + assert!(left.is_some() && left != canvas, "Shift+Tab leaves the canvas"); + assert!(!search_open(&h)); + h.ctx.memory_mut(|memory| memory.surrender_focus(left.unwrap())); + h.run_steps(2); + assert_eq!(focused(&h), canvas, "with nothing focused, the canvas under the pointer takes the keyboard"); + + press(&mut h, Modifiers::NONE, Key::Tab); + assert!(search_open(&h), "Tab opens the search"); + assert_eq!(press(&mut h, Modifiers::NONE, Key::Escape), canvas, "closing it gives the keyboard back"); + assert!(!search_open(&h)); +} + +#[test] +fn escape_releases_the_keyboard_from_the_dock_controls_after_the_canvas() { + let mut h = harness(materialcraft_engine::new_session()); + // The 3D view's tab row and its drag band + for stop in 1..=2 { + h.ctx.memory_mut(|memory| memory.request_focus(canvas_id())); + h.run_steps(2); + for _ in 0..stop { + press(&mut h, Modifiers::NONE, Key::Tab); + } + assert!(focused(&h).is_some_and(|id| id != canvas_id()), "Tab reaches stop {stop} after the canvas"); + assert_eq!(press(&mut h, Modifiers::NONE, Key::Escape), None, "Escape releases stop {stop}"); + } +} + +#[test] +fn a_press_in_the_canvas_takes_the_keyboard_from_a_toolbar_button() { + let mut h = harness(materialcraft_engine::new_session()); + h.get_by_label("Open package... (Ctrl+O)").focus(); + h.run_steps(2); + press(&mut h, Modifiers::SHIFT, Key::Tab); + assert!(h.get_by_label("New graph... (Ctrl+N)").is_focused()); + + hover_canvas(&mut h); + assert!(h.get_by_label("New graph... (Ctrl+N)").is_focused(), "the pointer alone takes no focus from a widget"); + let pos = h.state().graph.view.center(); + for pressed in [true, false] { + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(2); + assert_eq!(focused(&h), Some(canvas_id())); + } + press(&mut h, Modifiers::NONE, Key::Space); + assert!(search_open(&h), "Space goes to the canvas"); + assert!(!h.state().ui.windows.new_graph, "and not to the button"); +} + +#[test] +fn enter_in_the_canvas_menu_adds_the_node_its_letter_filters() { + let mut h = harness(materialcraft_engine::new_session()); + hover_canvas(&mut h); + let pos = h.state().graph.view.center(); + for pressed in [true, false] { + h.event(Event::PointerButton { pos, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE }); + } + h.run_steps(3); + h.get_by_label("Add node").hover(); + h.run_steps(3); + assert_eq!(focused(&h), Some(canvas_id())); + + press(&mut h, Modifiers::NONE, Key::L); + press(&mut h, Modifiers::NONE, Key::Enter); + assert_eq!(h.state().session.graph().unwrap().nodes.len(), 1); + assert!(h.query_by_label("Add node").is_none(), "and the menu closes"); +} + +#[test] +fn a_graph_created_by_keyboard_in_a_dialog_gets_the_focus() { + let mut h = harness(materialcraft_engine::sample_session()); + let ctx = h.ctx.clone(); + menus::invoke(h.state_mut(), &ctx, "ui.newFunctionGraph"); + h.run_steps(4); + h.state_mut().ui.new_graph_package = None; + h.get(By::new().role(Role::Button).label("Create")).focus(); + h.run_steps(2); + assert!(h.get(By::new().role(Role::Button).label("Create")).is_focused()); + + press(&mut h, Modifiers::NONE, Key::Enter); + h.run_steps(4); + assert!(h.state().session.graph().unwrap().function.is_some()); + assert_eq!(focused(&h), Some(canvas_id())); +} + +#[test] +fn shortcuts_run_with_the_canvas_focused() { + let mut h = harness(materialcraft_engine::sample_session()); + assert_eq!(focused(&h), Some(canvas_id())); + let nodes = |h: &AppHarness| h.state().session.graph().unwrap().nodes.len(); + let before = nodes(&h); + + press(&mut h, Modifiers::COMMAND, Key::A); + assert_eq!(h.state().session.selection.len(), before, "Ctrl+A selects every node"); + press(&mut h, Modifiers::NONE, Key::Delete); + assert_eq!(nodes(&h), 0, "Delete deletes them"); + press(&mut h, Modifiers::COMMAND, Key::Z); + assert_eq!(nodes(&h), before, "Ctrl+Z brings them back"); + assert_eq!(focused(&h), Some(canvas_id())); +} diff --git a/crates/ui-egui/tests/it/clipboard_shortcuts.rs b/crates/ui-egui/tests/it/clipboard_shortcuts.rs index 1519dad0..e0eff27c 100644 --- a/crates/ui-egui/tests/it/clipboard_shortcuts.rs +++ b/crates/ui-egui/tests/it/clipboard_shortcuts.rs @@ -13,7 +13,7 @@ fn harness(render: bool) -> Harness<'static, MaterialCraftApp> { let levels = app.run("graph.node.add", json!({"def": "levels", "connectFrom": {"node": source}})).unwrap()["id"].as_u64().unwrap(); app.run("graph.select", json!({"ids": [source, levels]})).unwrap(); - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)); + let builder = Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)); let builder = if render { builder.wgpu() } else { builder }; let mut harness = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { diff --git a/crates/ui-egui/tests/it/dialogs.rs b/crates/ui-egui/tests/it/dialogs.rs index 2957e820..67bf414d 100644 --- a/crates/ui-egui/tests/it/dialogs.rs +++ b/crates/ui-egui/tests/it/dialogs.rs @@ -10,7 +10,8 @@ fn harness(id: &'static str, render: bool) -> Harness<'static, State> { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.ui.windows.home = id == "home"; app.ui.windows.export = id == "export"; - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0); + let builder = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0); let builder = if render { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( move |ui, (app, rect): &mut State| { diff --git a/crates/ui-egui/tests/it/export_window.rs b/crates/ui-egui/tests/it/export_window.rs index 530eb053..9647dcfd 100644 --- a/crates/ui-egui/tests/it/export_window.rs +++ b/crates/ui-egui/tests/it/export_window.rs @@ -10,13 +10,17 @@ use materialcraft_ui_egui::{MaterialCraftApp, UiState}; fn harness() -> Harness<'static, MaterialCraftApp> { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.ui.dock.close(materialcraft_ui_egui::docking::Panel::Library); - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0).build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app, - ); + let mut harness = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app, + ); harness.run_steps(6); harness } diff --git a/crates/ui-egui/tests/it/graph_properties.rs b/crates/ui-egui/tests/it/graph_properties.rs index 61903aaf..fa640e32 100644 --- a/crates/ui-egui/tests/it/graph_properties.rs +++ b/crates/ui-egui/tests/it/graph_properties.rs @@ -25,7 +25,8 @@ fn harness(render: bool) -> Harness<'static, MaterialCraftApp> { } fn app_harness(app: MaterialCraftApp, render: bool) -> Harness<'static, MaterialCraftApp> { - let builder = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_step_dt(1.0 / 60.0); + let builder = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).with_step_dt(1.0 / 60.0); let builder = if render { builder.wgpu() } else { builder }; let mut harness = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { @@ -153,7 +154,9 @@ fn close_with_focused_graph_text(native_close: bool) { if native_close { let mut input = egui::RawInput::default(); input.viewports.get_mut(&egui::ViewportId::ROOT).unwrap().events.push(egui::ViewportEvent::Close); - let mut output = egui::Context::default().run_ui(input, |ui| materialcraft_ui_egui::unsaved::handle_close(harness.state_mut(), ui.ctx())); + let ctx = egui::Context::default(); + materialcraft_ui_egui::framework::install_headless(&ctx); + let mut output = ctx.run_ui(input, |ui| harness.state_mut().close_path(ui.ctx())); // This close-event frame has no renderer to consume texture updates output.textures_delta.clear(); diff --git a/crates/ui-egui/tests/it/interface_scale.rs b/crates/ui-egui/tests/it/interface_scale.rs index 90d22e03..b1b68f46 100644 --- a/crates/ui-egui/tests/it/interface_scale.rs +++ b/crates/ui-egui/tests/it/interface_scale.rs @@ -10,7 +10,11 @@ fn harness(scale: f32, render: bool) -> Harness<'static, MaterialCraftApp> { let mut app = MaterialCraftApp::headless(materialcraft_engine::new_session(), UiState::default()); app.ui.windows.preferences = true; app.ui.prefs.ui_scale = scale; - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0).with_step_dt(1.0 / 60.0); + let builder = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .with_step_dt(1.0 / 60.0); let builder = if render { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 24b52ae8..755ca4cd 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -2,6 +2,7 @@ //! Keep snapshot.rs standalone; language_switching.rs needs process isolation for global locale state. //! resize.rs isolates its bounded render wait from unrelated tests sharing the global Rayon pool. +mod canvas_focus; mod clipboard_shortcuts; mod dialogs; mod export_window; diff --git a/crates/ui-egui/tests/it/menu_bar.rs b/crates/ui-egui/tests/it/menu_bar.rs index 51dcd57a..c733785f 100644 --- a/crates/ui-egui/tests/it/menu_bar.rs +++ b/crates/ui-egui/tests/it/menu_bar.rs @@ -9,13 +9,17 @@ use materialcraft_ui_egui::{MaterialCraftApp, UiState, menus}; fn harness() -> Harness<'static, MaterialCraftApp> { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.ui.windows.home = false; - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0).build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app, - ); + let mut harness = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app, + ); harness.run_steps(6); harness } diff --git a/crates/ui-egui/tests/it/new_graph_dialog.rs b/crates/ui-egui/tests/it/new_graph_dialog.rs index 0d2a3a66..660a7ccd 100644 --- a/crates/ui-egui/tests/it/new_graph_dialog.rs +++ b/crates/ui-egui/tests/it/new_graph_dialog.rs @@ -9,13 +9,17 @@ use materialcraft_ui_egui::{MaterialCraftApp, UiState, menus}; fn harness() -> Harness<'static, MaterialCraftApp> { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.ui.windows.home = false; - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0).build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app, - ); + let mut harness = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app, + ); harness.run_steps(6); harness } diff --git a/crates/ui-egui/tests/it/node_look.rs b/crates/ui-egui/tests/it/node_look.rs index 2dab4a67..b7cad214 100644 --- a/crates/ui-egui/tests/it/node_look.rs +++ b/crates/ui-egui/tests/it/node_look.rs @@ -9,13 +9,18 @@ use serde_json::json; fn harness(app: MaterialCraftApp) -> Harness<'static, MaterialCraftApp> { // Short steps keep two clicks within the double-click delay - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0).with_step_dt(0.05).build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app, - ); + let mut harness = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .with_step_dt(0.05) + .build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app, + ); harness.run_steps(6); harness } diff --git a/crates/ui-egui/tests/it/normal_maps.rs b/crates/ui-egui/tests/it/normal_maps.rs index 59d6cdf3..7f48a988 100644 --- a/crates/ui-egui/tests/it/normal_maps.rs +++ b/crates/ui-egui/tests/it/normal_maps.rs @@ -51,7 +51,7 @@ fn toggle(h: &mut Harness<'static, MaterialCraftApp>) { #[test] fn display_toggle_updates_the_session_and_rerenders_the_normal_map() { - let mut h = Harness::builder().with_size(vec2(1400.0, 860.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 860.0)).build_ui_state( |ui, app: &mut MaterialCraftApp| { app.step(&ui.ctx().clone()); app.draw(ui); @@ -78,13 +78,14 @@ fn display_toggle_updates_the_session_and_rerenders_the_normal_map() { #[test] #[ignore = "requires an offscreen GPU; run explicitly with --ignored"] fn normal_convention_snapshot() { - let mut harness = Harness::builder().with_size(vec2(1400.0, 860.0)).wgpu().build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app(), - ); + let mut harness = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 860.0)).wgpu().build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app(), + ); settle(&mut harness, 0); let rendered = harness.state().view3d.renders; open_material_properties(&mut harness); diff --git a/crates/ui-egui/tests/it/numeric_input.rs b/crates/ui-egui/tests/it/numeric_input.rs index fcc7db08..ecd06e8b 100644 --- a/crates/ui-egui/tests/it/numeric_input.rs +++ b/crates/ui-egui/tests/it/numeric_input.rs @@ -13,7 +13,8 @@ fn harness(render: bool) -> (Harness<'static, MaterialCraftApp>, NodeId) { app.run("file.new", json!({"template":"empty"})).unwrap(); let id = NodeId(app.run("graph.node.add", json!({"def":"transformation"})).unwrap()["id"].as_u64().unwrap()); app.session.reset_history(); - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); + let builder = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); let builder = if render { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { @@ -51,7 +52,8 @@ fn graph_name_typed_across_frames_commits_on_focus_loss() { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.run("file.new", json!({"template":"empty"})).unwrap(); app.session.reset_history(); - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); + let builder = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); let mut h = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { app.step(&ui.ctx().clone()); diff --git a/crates/ui-egui/tests/it/preferences_window.rs b/crates/ui-egui/tests/it/preferences_window.rs index 96362811..e3f2bfc4 100644 --- a/crates/ui-egui/tests/it/preferences_window.rs +++ b/crates/ui-egui/tests/it/preferences_window.rs @@ -10,13 +10,17 @@ use materialcraft_ui_egui::{MaterialCraftApp, UiState}; fn harness() -> Harness<'static, MaterialCraftApp> { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.ui.windows.home = false; - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(1.0).build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app, - ); + let mut harness = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app, + ); harness.run_steps(6); harness } diff --git a/crates/ui-egui/tests/it/preview_resolution.rs b/crates/ui-egui/tests/it/preview_resolution.rs index 2513acab..f06b8423 100644 --- a/crates/ui-egui/tests/it/preview_resolution.rs +++ b/crates/ui-egui/tests/it/preview_resolution.rs @@ -12,7 +12,8 @@ fn harness(preview: u32, render: bool) -> (Harness<'static, MaterialCraftApp>, N let id = NodeId(app.run("graph.node.add", json!({"def":"uniform"})).unwrap()["id"].as_u64().unwrap()); app.apply_prefs(); app.session.cook(); - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); + let builder = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); let builder = if render { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { diff --git a/crates/ui-egui/tests/it/search.rs b/crates/ui-egui/tests/it/search.rs index a4fd4cd2..eae1947b 100644 --- a/crates/ui-egui/tests/it/search.rs +++ b/crates/ui-egui/tests/it/search.rs @@ -6,7 +6,8 @@ use materialcraft_ui_egui::{MaterialCraftApp, UiState}; fn harness() -> Harness<'static, MaterialCraftApp> { let app = MaterialCraftApp::headless(materialcraft_engine::new_session(), UiState::default()); - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); + let builder = + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)).with_step_dt(1.0 / 60.0); let builder = if std::env::var_os("MC_SNAPSHOT_DIR").is_some() { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { diff --git a/crates/ui-egui/tests/it/slider_round_values.rs b/crates/ui-egui/tests/it/slider_round_values.rs index deb0af40..9d3c0f73 100644 --- a/crates/ui-egui/tests/it/slider_round_values.rs +++ b/crates/ui-egui/tests/it/slider_round_values.rs @@ -18,7 +18,11 @@ fn harness(ppp: f32, render: bool, definition: &str) -> (Harness<'static, Materi let mut app = MaterialCraftApp::headless(materialcraft_engine::new_session(), UiState::default()); let id = NodeId(app.run("graph.node.add", json!({"def":definition})).unwrap()["id"].as_u64().unwrap()); app.session.reset_history(); - let builder = Harness::builder().with_size(vec2(1600.0, 960.0)).with_pixels_per_point(ppp).with_step_dt(1.0 / 60.0); + let builder = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(1600.0, 960.0)) + .with_pixels_per_point(ppp) + .with_step_dt(1.0 / 60.0); let builder = if render { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( |ui, app: &mut MaterialCraftApp| { @@ -85,12 +89,16 @@ fn fractional_parameter_values_remain_reachable() { #[test] fn bar_slider_drag_reaches_exact_round_values() { - let mut h = Harness::builder().with_size(vec2(800.0, 400.0)).with_pixels_per_point(1.0).build_ui_state( - |ui, value: &mut f32| { - widgets::bar_slider(ui, "Brightness", value, 0.0..=1.0, 128.0); - }, - 0.0f32, - ); + let mut h = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(800.0, 400.0)) + .with_pixels_per_point(1.0) + .build_ui_state( + |ui, value: &mut f32| { + widgets::bar_slider(ui, "Brightness", value, 0.0..=1.0, 128.0); + }, + 0.0f32, + ); h.run_steps(3); let rect = h.get(By::new().role(egui::accesskit::Role::Slider).label("Brightness")).rect(); let start = pos2(rect.left() + rect.width() * 0.2, rect.center().y); @@ -112,12 +120,16 @@ fn bar_slider_drag_reaches_exact_round_values() { #[test] fn bar_slider_drag_preserves_fractional_values() { - let mut h = Harness::builder().with_size(vec2(800.0, 400.0)).with_pixels_per_point(1.0).build_ui_state( - |ui, value: &mut f32| { - widgets::bar_slider(ui, "Brightness", value, 0.0..=1.0, 128.0); - }, - 0.0f32, - ); + let mut h = Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(800.0, 400.0)) + .with_pixels_per_point(1.0) + .build_ui_state( + |ui, value: &mut f32| { + widgets::bar_slider(ui, "Brightness", value, 0.0..=1.0, 128.0); + }, + 0.0f32, + ); h.run_steps(3); let rect = h.get(By::new().role(egui::accesskit::Role::Slider).label("Brightness")).rect(); let start = pos2(rect.left() + rect.width() * 0.2, rect.center().y); diff --git a/crates/ui-egui/tests/it/unsaved_changes.rs b/crates/ui-egui/tests/it/unsaved_changes.rs index b2d1d00c..a4336ac6 100644 --- a/crates/ui-egui/tests/it/unsaved_changes.rs +++ b/crates/ui-egui/tests/it/unsaved_changes.rs @@ -11,7 +11,7 @@ fn unsaved_dialog_snapshot_and_cancel() { let mut app = MaterialCraftApp::headless(materialcraft_engine::sample_session(), UiState::default()); app.session.modified = true; unsaved::guard(&mut app, Guarded::Menu { id: "ui.closeAll".into() }); - let mut h = Harness::builder().with_size(vec2(1600.0, 960.0)).wgpu().build_ui_state( + let mut h = Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 960.0)).wgpu().build_ui_state( |ui, app: &mut MaterialCraftApp| { app.step(&ui.ctx().clone()); app.draw(ui); diff --git a/crates/ui-egui/tests/resize.rs b/crates/ui-egui/tests/resize.rs index 3efbc5c4..1ade2a5b 100644 --- a/crates/ui-egui/tests/resize.rs +++ b/crates/ui-egui/tests/resize.rs @@ -14,7 +14,7 @@ fn harness(w: f32, h: f32) -> Harness<'static, MaterialCraftApp> { app.session.view3d.override_resolution = true; app.session.view3d.viewport_resolution = true; app.session.view3d.render_scale = 25; - Harness::builder().with_size(vec2(w, h)).with_pixels_per_point(1.0).build_ui_state( + Harness::builder().with_context_setup(materialcraft_ui_egui::framework::install_headless).with_size(vec2(w, h)).with_pixels_per_point(1.0).build_ui_state( |ui, app: &mut MaterialCraftApp| { app.step(&ui.ctx().clone()); app.draw(ui); diff --git a/crates/ui-egui/tests/snapshot.rs b/crates/ui-egui/tests/snapshot.rs index 85bc50b1..0d24a9b0 100644 --- a/crates/ui-egui/tests/snapshot.rs +++ b/crates/ui-egui/tests/snapshot.rs @@ -54,13 +54,18 @@ use materialcraft_ui_egui::{MaterialCraftApp, UiState}; use serde_json::json; fn harness(app: MaterialCraftApp, w: f32, h: f32) -> Harness<'static, MaterialCraftApp> { - Harness::builder().with_size(vec2(w, h)).with_pixels_per_point(1.0).wgpu().build_ui_state( - |ui, app: &mut MaterialCraftApp| { - app.step(&ui.ctx().clone()); - app.draw(ui); - }, - app, - ) + Harness::builder() + .with_context_setup(materialcraft_ui_egui::framework::install_headless) + .with_size(vec2(w, h)) + .with_pixels_per_point(1.0) + .wgpu() + .build_ui_state( + |ui, app: &mut MaterialCraftApp| { + app.step(&ui.ctx().clone()); + app.draw(ui); + }, + app, + ) } /// Run frames until background work (cooks, previews) settles diff --git a/crates/ui-egui/tests/snapshot/graph_items.rs b/crates/ui-egui/tests/snapshot/graph_items.rs index 852ebe61..a4005524 100644 --- a/crates/ui-egui/tests/snapshot/graph_items.rs +++ b/crates/ui-egui/tests/snapshot/graph_items.rs @@ -39,7 +39,7 @@ fn navigation_pin_library_drop_and_properties_in_every_canvas() { assert_eq!(target.items(&harness.state().session).unwrap().pins.len(), 1, "{kind}"); let input = By::new().role(Role::TextInput).label("Navigation Pin description"); assert!(harness.query(input.clone()).is_some(), "{kind}"); - assert!(harness.ctx.egui_wants_keyboard_input(), "new pin description must receive focus: {kind}"); + assert!(harness.ctx.text_edit_focused(), "new pin description must receive focus: {kind}"); harness.event(Event::ModifiersChanged(Modifiers::COMMAND)); harness.event(Event::Key { key: Key::A, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::COMMAND }); harness.step();