diff --git a/Cargo.lock b/Cargo.lock index 0daa69e0..7ae22ac1 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" @@ -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,58 @@ 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-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "rustix 1.1.6", ] +[[package]] +name = "craft-behavior" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "rayon", ] @@ -853,27 +1019,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +dependencies = [ + "serde", +] + +[[package]] +name = "craft-font-catalog" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" + +[[package]] +name = "craft-host" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ + "chrono", "fixed_decimal", + "icu_calendar", + "icu_collator", + "icu_datetime", "icu_decimal", "icu_locale_core", "icu_locale_fallback", @@ -883,6 +1095,7 @@ dependencies = [ "icu_provider", "icu_provider_adapters", "icu_provider_blob", + "icu_time", "log", "objc2-foundation 0.3.2", "sys-locale", @@ -894,7 +1107,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "craft-dds", "craft-jpeg", @@ -921,7 +1134,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "thiserror 2.0.21", ] @@ -929,8 +1142,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ + "craft-host", + "craft-i18n", + "craft-tracked", + "craft-ui-macros", + "craft-xml", "egui", "serde", "serde_json", @@ -939,18 +1157,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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 +1177,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "serde_json", ] @@ -980,7 +1203,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "brotli-decompressor", "chrono", @@ -992,56 +1215,106 @@ 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "chrono", "craft-codepage", "encoding_rs", ] +[[package]] +name = "craft-pdf" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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", @@ -1055,7 +1328,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "bytemuck", "dds", @@ -1063,46 +1336,205 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-theme" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "serde", "thiserror 2.0.21", + "tiff", ] +[[package]] +name = "craft-tracked" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" + [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=453b0da782ccef39be9a6dac8d27c80b553ef1cc#453b0da782ccef39be9a6dac8d27c80b553ef1cc" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" 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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "chrono", + "craft-host", + "craft-theme", + "craft-ui", "dunce", "egui", "flate2", - "getrandom 0.3.4", "image", "log", "plist", @@ -1120,31 +1552,40 @@ dependencies = [ "zip 9.5.0", ] +[[package]] +name = "craft-win32" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" +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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ + "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", ] [[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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1154,17 +1595,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/aiongg/craft-libs?rev=22e82c930ec7062fba45757a8cac8ba5e3cb94bc#22e82c930ec7062fba45757a8cac8ba5e3cb94bc" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1329,6 +1760,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.59.0", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1388,6 +1840,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" @@ -1403,7 +1910,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "bytemuck", "emath", @@ -1413,7 +1920,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "ahash", "bytemuck", @@ -1450,14 +1957,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "accesskit", "ahash", "bitflags 2.13.2", "emath", "epaint", - "itertools", + "itertools 0.15.0", "log", "nohash-hasher", "profiling", @@ -1478,7 +1985,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "ahash", "bytemuck", @@ -1497,7 +2004,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "accesskit_winit", "arboard", @@ -1520,7 +2027,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "bytemuck", "egui", @@ -1533,7 +2040,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "dify", "eframe", @@ -1559,12 +2066,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" 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" @@ -1620,7 +2139,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "ahash", "bytemuck", @@ -1628,14 +2147,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", @@ -1647,7 +2166,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=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" [[package]] name = "equivalent" @@ -1854,6 +2373,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" @@ -1966,6 +2494,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" @@ -2028,6 +2580,7 @@ dependencies = [ "js-sys", "libc", "r-efi 6.0.0", + "rand_core", "wasm-bindgen", ] @@ -2041,6 +2594,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" @@ -2085,11 +2647,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" @@ -2211,7 +2779,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", ] @@ -2253,6 +2834,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" @@ -2305,6 +2892,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" @@ -2313,12 +2933,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" @@ -2380,6 +3025,7 @@ dependencies = [ "icu_normalizer_data", "icu_properties", "icu_provider", + "serde", "smallvec", "utf16_iter", "utf8_iter", @@ -2430,6 +3076,7 @@ dependencies = [ "icu_locale_core", "icu_properties_data", "icu_provider", + "serde", "zerotrie", "zerovec", ] @@ -2482,12 +3129,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" @@ -2537,6 +3221,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" @@ -2584,6 +3277,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" @@ -2780,6 +3482,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" @@ -2805,6 +3555,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" @@ -2946,8 +3702,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", @@ -2999,10 +3755,13 @@ version = "0.4.1" dependencies = [ "base64 0.22.1", "craft-atomic", + "craft-behavior", "craft-dialogs", + "craft-host", + "craft-i18n", "craft-keymap", "craft-platform", - "craft-quit", + "craft-theme", "craft-ui", "craft-update", "craft-window", @@ -3079,6 +3838,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" @@ -3230,6 +3995,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" @@ -3322,8 +4097,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", ] @@ -3336,9 +4111,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", ] @@ -3355,6 +4169,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" @@ -3366,6 +4191,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" @@ -3378,6 +4225,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" @@ -3385,7 +4243,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", ] @@ -3396,10 +4256,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]] @@ -3414,6 +4277,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" @@ -3426,6 +4299,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" @@ -3453,10 +4369,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" @@ -3480,6 +4408,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" @@ -3550,9 +4490,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", @@ -3620,6 +4560,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" @@ -3816,6 +4762,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" @@ -3911,6 +4882,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", ] @@ -4044,6 +5017,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" @@ -4108,6 +5098,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" @@ -4141,6 +5153,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" @@ -4161,6 +5183,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" @@ -4622,10 +5673,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" @@ -4686,7 +5743,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]] @@ -4854,6 +5921,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" @@ -4864,6 +5944,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" @@ -5095,8 +6181,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", ] @@ -5153,7 +6242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" dependencies = [ "memchr", - "nom", + "nom 8.0.0", "petgraph", ] @@ -5278,6 +6367,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" @@ -5287,7 +6388,7 @@ dependencies = [ "base64 0.23.1", "data-url", "fontdb", - "harfrust", + "harfrust 0.12.0", "imagesize", "kurbo", "log", @@ -5295,7 +6396,7 @@ dependencies = [ "roxmltree", "simplecss", "siphasher", - "skrifa", + "skrifa 0.44.0", "strict-num", "svgtypes", "tiny-skia-path", @@ -5405,6 +6506,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" @@ -5588,6 +6695,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" @@ -5595,7 +6715,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" dependencies = [ "dlib", + "libc", "log", + "memoffset", "once_cell", "pkg-config", ] @@ -5818,6 +6940,12 @@ 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" @@ -6279,6 +7407,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 870bff04..dd3c697a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,6 +96,9 @@ craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c9 craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } +craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } +craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } +craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc" } # Keyboard bindings (chords, dispatch and display text): storytold/craft-libs, MIT OR Apache-2.0 craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "22e82c930ec7062fba45757a8cac8ba5e3cb94bc", features = ["egui"] } # Native dialogs that do not block the event loop: storytold/craft-libs, MIT OR Apache-2.0 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/src/main.rs b/apps/materialcraft/src/main.rs index 672c499e..5326c0eb 100644 --- a/apps/materialcraft/src/main.rs +++ b/apps/materialcraft/src/main.rs @@ -102,10 +102,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("MaterialCraft").with_inner_size(DEFAULT_SIZE).with_min_inner_size(MIN_SIZE), - &window_frame, + &window_frame.frame, ); if let Some(i) = icon() { viewport = viewport.with_icon(i); @@ -120,8 +120,8 @@ fn main() { "MaterialCraft", options, Box::new(move |cc| { + materialcraft_ui_egui::framework::install(&cc.egui_ctx, window_frame)?; let mut app = MaterialCraftApp::new(cc, session); - 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, "MaterialCraft") { diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index f6b7d5bb..d2341db0 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -15,6 +15,10 @@ 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 +34,6 @@ sha2 = { workspace = true } sys-locale = "0.3" craft-update = { workspace = true } craft-dialogs = { workspace = true } -craft-quit = { workspace = true, features = ["ui"] } -craft-window = { workspace = true, features = ["ui"] } -# Floating panels open as OS windows. -craft-ui = { workspace = true } # 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 bc6742a6..77d99b7d 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -1,24 +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_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions}; -use craft_ui::docking::{DockArea, DockContent, DockStyle, PanelLimits}; +use std::sync::Arc; + +use craft_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions, SplitSize}; use craft_behavior::flow::Axis; -use craft_behavior::dock::SplitSize; -use egui::{Id, Margin, RichText, Ui, vec2}; +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 { @@ -65,31 +67,31 @@ 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. +/// 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: Axis, ratio: f32, first: Node, second: Node) -> Node { - Node::Split { axis, size: SplitSize::Ratio(ratio), first: Box::new(first), second: Box::new(second) } + 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 @@ -100,33 +102,27 @@ pub fn default_workspace() -> Workspace { 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 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: DockPlacement::Tab { before: None }, - size: None, - stack: None, - sibling: Vec::new(), - group: None, - }; - workspace.hidden.push((panel, location)); - } - } - workspace + 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; @@ -143,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)) => { @@ -158,17 +154,15 @@ 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, - /// A panel to bring in front of the other floating windows on the next frame. - raise: Option, } impl Default for Dock { fn default() -> Self { - Dock { workspace: default_workspace(), raise: None } + Dock { workspace: default_workspace() } } } @@ -201,7 +195,7 @@ impl Dock { if validate(&workspace).is_err() { return Dock::default(); } - Dock { workspace, raise: None } + Dock { workspace } } pub fn workspace(&self) -> &Workspace { @@ -209,12 +203,12 @@ 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 } /// Hide a visible panel, otherwise bring it up. @@ -223,7 +217,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}"); } } @@ -232,11 +226,8 @@ impl Dock { /// front. pub fn focus(&mut self, p: Panel) { let mut next = self.workspace.clone(); - match next.set_visible(p, true, None, permissions) { - Ok(()) if validate(&next).is_ok() => { - self.workspace = next; - self.raise = Some(p); - } + match next.set_visible(p, true, None, false, permissions) { + Ok(()) if validate(&next).is_ok() => self.workspace = next, Ok(()) => log::warn!("panel {p:?} was not opened: it would break the graph's rules"), Err(error) => log::warn!("panel {p:?} was not opened: {error}"), } @@ -246,7 +237,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}"), @@ -254,73 +245,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 +/// The graph editor's id as the window's document canvas. +fn graph_canvas_id() -> egui::Id { + egui::Id::unique("materialcraft-graph-canvas") } /// 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); + // 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 }; + DockArea::new("Panels", Bind::given(Arc::clone(&shown)), &specs, &mut panels, config).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), _ => { @@ -336,31 +371,15 @@ 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, as the window's document canvas. + 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::framework::host_canvas(ui.ctx(), graph_canvas_id()); + crate::graph::show(self.app, ui); + Some(rect.height()) } } @@ -373,28 +392,10 @@ 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"); } } - #[test] - 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"))) - }; - - assert_eq!(frame(&mut app), Some(false)); - 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"); - app.ui.windows.unsaved = None; - app.ui.windows.shortcuts = true; - assert_eq!(frame(&mut app), Some(false), "the Shortcuts list does not block"); - } - #[test] fn default_dock_round_trips() { let dock = Dock::default(); diff --git a/crates/ui-egui/src/explorer/actions.rs b/crates/ui-egui/src/explorer/actions.rs index f743227e..bec17d4a 100644 --- a/crates/ui-egui/src/explorer/actions.rs +++ b/crates/ui-egui/src/explorer/actions.rs @@ -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..4b2258fb --- /dev/null +++ b/crates/ui-egui/src/framework.rs @@ -0,0 +1,144 @@ +//! 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 is declared to the runtime with [`host_canvas`], which keeps Tab, the edit +//! chords and the clipboard events in egui's input for MaterialCraft's shortcuts. + +use std::sync::Arc; + +use craft_host::target::ShellInfo; +use craft_host::{AppInfo, Host}; +use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; +use craft_ui::runtime::env::{RootEnv, Scale}; +use craft_ui::runtime::focus::{EditSet, KeepKeys, KeyUse}; +use craft_ui::runtime::frame::{FrameInput, FrameOutput}; +use craft_ui::runtime::keys::{Intent, with_window_intents}; +use craft_ui::shell::embed::{self, CloseDecision}; +use craft_window::policy::Decision; +use craft_window::system::WindowSystem; + +use crate::MaterialCraftApp; + +/// 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 id every OS window of the app carries, as the desktop entry and the update app name it. +const APP_ID: &str = "ai.storyteller.materialcraft"; + +/// 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(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). +pub(crate) fn host() -> Arc { + Arc::new(Host::builder(AppInfo { id: "materialcraft", name: "MaterialCraft", version: materialcraft_engine::VERSION }).build()) +} + +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(output, scale)); + } + + /// The root values of this frame. MaterialCraft registers no commands with the runtime and lets it toggle no + /// chrome, so the output carries nothing it acts on. + fn frame_input(&mut self, _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); + FrameInput::new(root).host(Arc::clone(&self.framework_host)) + } + + /// 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 }); + } +} + +/// Declares the graph editor `id`, drawn in this pass, as the window's document canvas. With nothing focused it is the +/// window's key target: Tab (node search), the edit chords and the clipboard events stay in egui's input for +/// MaterialCraft's shortcuts. +pub(crate) fn host_canvas(ctx: &egui::Context, id: egui::Id) { + const KEYS: KeyUse = KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(EditSet::ALL); + craft_ui::runtime::focus::host_canvas(ctx, id, KEYS); +} + +/// 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) +} + +/// 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/search.rs b/crates/ui-egui/src/function/search.rs index fc24d6ea..95c9de89 100644 --- a/crates/ui-egui/src/function/search.rs +++ b/crates/ui-egui/src/function/search.rs @@ -115,10 +115,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)); } 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/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/search.rs b/crates/ui-egui/src/graph/search.rs index 055092a8..4b910140 100644 --- a/crates/ui-egui/src/graph/search.rs +++ b/crates/ui-egui/src/graph/search.rs @@ -71,10 +71,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)); } 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 83b0b057..e6ce1ce4 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -8,6 +8,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; @@ -26,6 +27,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 e775d2bb..13b2f413 100644 --- a/crates/ui-egui/src/material_craft_app.rs +++ b/crates/ui-egui/src/material_craft_app.rs @@ -58,12 +58,15 @@ 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 @@ -135,12 +138,11 @@ 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, @@ -450,18 +452,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)); @@ -471,13 +474,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 { @@ -509,7 +505,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"))] @@ -565,8 +561,9 @@ 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); #[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); } diff --git a/crates/ui-egui/src/material_craft_app.test.rs b/crates/ui-egui/src/material_craft_app.test.rs index df5940a0..30e34881 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(); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index f8c1b33c..167a3d96 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, Binding, Chord, CommandDef, Keymap, Platform, Scope, Scopes}; +use craft_keymap::{Binding, Chord, CommandDef, Keymap, Platform, Scope, Scopes}; use egui::class::HasClasses as _; use serde_json::Value; @@ -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); + } + }); + } }); } @@ -460,6 +460,14 @@ pub fn shortcuts(app: &mut MaterialCraftApp, ctx: &egui::Context) { 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) { + ctx.input_mut(|i| { + let modifiers = i.modifiers; + 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,7 +499,7 @@ 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 @@ -551,7 +559,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 +790,7 @@ 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 +810,7 @@ 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 +906,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 +916,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..e4921467 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 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/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/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..ec8dfdfb --- /dev/null +++ b/crates/ui-egui/src/shortcut_dispatch.rs @@ -0,0 +1,249 @@ +//! 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..6150efdb 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,14 @@ 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 f26e5468..d450a0be 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 +//! the prompts that report them, as craft-update's dialogs on the app's +//! [`DialogHost`](craft_ui::dialog::DialogHost) +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; @@ -58,9 +60,9 @@ pub(crate) fn tick(app: &mut MaterialCraftApp, ctx: &egui::Context) { let rt = &mut app.updates_rt; rt.repaint = Some(ctx.clone()); if std::mem::take(&mut rt.check_requested) { - rt.updater.check_now(ctx); + rt.updater.check_now(); } else if rt.startup_check { - rt.updater.check_at_start(ctx); + rt.updater.check_at_start(); } rt.updater.tick(ctx); } @@ -72,25 +74,44 @@ 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) { // An installation, and the close for a ready update, wait until nothing is unsaved let clean = !crate::unsaved::needs_confirmation(&app.session); - match app.updates_rt.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)) => app.updates_rt.updater.restart_to_update(), + Some(DialogResult::Ok(CheckChoice::Update)) => { + app.updates_rt.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(_) => app.updates_rt.updater.dismiss_status(), + None => {} + } + match app.updates_rt.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 - let rt = &mut app.updates_rt; - if result_window_shows(rt.updater.status(), rt.updater.prompt_open()) { - match CheckResultDialog::new(&crate::UPDATE_APP, materialcraft_engine::VERSION).with_translator(translate).show(ctx, rt.updater.status()) { - CheckResultResponse::None => {} - // Closing the dialog dismisses the outcome it showed - CheckResultResponse::Close => rt.updater.dismiss_status(), - CheckResultResponse::CheckAgain => rt.check_requested = true, - // The next `show_if` asks the window to close once nothing is unsaved - CheckResultResponse::RestartToUpdate => rt.updater.restart_to_update(), - } + let updater = &app.updates_rt.updater; + 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); + } + 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 36442b40..887f0f5c 100644 --- a/crates/ui-egui/src/updates_ui.test.rs +++ b/crates/ui-egui/src/updates_ui.test.rs @@ -111,6 +111,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); @@ -167,7 +168,13 @@ 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); @@ -191,7 +198,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/view3d/navigation.rs b/crates/ui-egui/src/view3d/navigation.rs index ad0b0bc1..bf142cc6 100644 --- a/crates/ui-egui/src/view3d/navigation.rs +++ b/crates/ui-egui/src/view3d/navigation.rs @@ -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..13469a5b 100644 --- a/crates/ui-egui/src/windows.test.rs +++ b/crates/ui-egui/src/windows.test.rs @@ -8,7 +8,7 @@ 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( + 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()); 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..502eea7d 100644 --- a/crates/ui-egui/tests/it/dialogs.rs +++ b/crates/ui-egui/tests/it/dialogs.rs @@ -10,7 +10,7 @@ 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..858759ee 100644 --- a/crates/ui-egui/tests/it/export_window.rs +++ b/crates/ui-egui/tests/it/export_window.rs @@ -10,7 +10,7 @@ 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( + 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); diff --git a/crates/ui-egui/tests/it/graph_properties.rs b/crates/ui-egui/tests/it/graph_properties.rs index 61903aaf..3852174f 100644 --- a/crates/ui-egui/tests/it/graph_properties.rs +++ b/crates/ui-egui/tests/it/graph_properties.rs @@ -25,7 +25,7 @@ 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 +153,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..1385e329 100644 --- a/crates/ui-egui/tests/it/interface_scale.rs +++ b/crates/ui-egui/tests/it/interface_scale.rs @@ -10,7 +10,7 @@ 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/menu_bar.rs b/crates/ui-egui/tests/it/menu_bar.rs index 51dcd57a..aa71a814 100644 --- a/crates/ui-egui/tests/it/menu_bar.rs +++ b/crates/ui-egui/tests/it/menu_bar.rs @@ -9,7 +9,7 @@ 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( + 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); diff --git a/crates/ui-egui/tests/it/new_graph_dialog.rs b/crates/ui-egui/tests/it/new_graph_dialog.rs index 0d2a3a66..55c6559b 100644 --- a/crates/ui-egui/tests/it/new_graph_dialog.rs +++ b/crates/ui-egui/tests/it/new_graph_dialog.rs @@ -9,7 +9,7 @@ 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( + 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); diff --git a/crates/ui-egui/tests/it/node_look.rs b/crates/ui-egui/tests/it/node_look.rs index 2dab4a67..ead588a4 100644 --- a/crates/ui-egui/tests/it/node_look.rs +++ b/crates/ui-egui/tests/it/node_look.rs @@ -9,7 +9,7 @@ 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( + 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); diff --git a/crates/ui-egui/tests/it/normal_maps.rs b/crates/ui-egui/tests/it/normal_maps.rs index 59d6cdf3..1e9d2987 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,7 +78,7 @@ 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( + 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); diff --git a/crates/ui-egui/tests/it/numeric_input.rs b/crates/ui-egui/tests/it/numeric_input.rs index fcc7db08..da015e7f 100644 --- a/crates/ui-egui/tests/it/numeric_input.rs +++ b/crates/ui-egui/tests/it/numeric_input.rs @@ -13,7 +13,7 @@ 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 +51,7 @@ 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..3aadc7d7 100644 --- a/crates/ui-egui/tests/it/preferences_window.rs +++ b/crates/ui-egui/tests/it/preferences_window.rs @@ -10,7 +10,7 @@ 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( + 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); diff --git a/crates/ui-egui/tests/it/preview_resolution.rs b/crates/ui-egui/tests/it/preview_resolution.rs index 2513acab..1fa2a201 100644 --- a/crates/ui-egui/tests/it/preview_resolution.rs +++ b/crates/ui-egui/tests/it/preview_resolution.rs @@ -12,7 +12,7 @@ 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..24fb4621 100644 --- a/crates/ui-egui/tests/it/search.rs +++ b/crates/ui-egui/tests/it/search.rs @@ -6,7 +6,7 @@ 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..64c28c22 100644 --- a/crates/ui-egui/tests/it/slider_round_values.rs +++ b/crates/ui-egui/tests/it/slider_round_values.rs @@ -18,7 +18,7 @@ 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,7 +85,7 @@ 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( + 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); }, @@ -112,7 +112,7 @@ 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( + 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); }, 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..404ef2ed 100644 --- a/crates/ui-egui/tests/snapshot.rs +++ b/crates/ui-egui/tests/snapshot.rs @@ -54,7 +54,7 @@ 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( + 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);