diff --git a/Cargo.lock b/Cargo.lock index dd197290f..ae86b2171 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,6 +129,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 = "aligned" version = "0.4.3" @@ -209,6 +218,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" @@ -240,7 +265,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.52.0", + "windows-sys 0.61.2", "wl-clipboard-rs", "x11rb", ] @@ -267,6 +292,9 @@ name = "arrayvec" version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" +dependencies = [ + "serde", +] [[package]] name = "as-raw-xcb-connection" @@ -343,7 +371,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 1.1.5", + "rustix 1.1.6", "slab", "windows-sys 0.61.2", ] @@ -374,7 +402,7 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -400,7 +428,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 1.1.5", + "rustix 1.1.6", "signal-hook-registry", "slab", "windows-sys 0.61.2", @@ -501,7 +529,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom", + "nom 8.0.0", "num-rational", "v_frame", ] @@ -518,6 +546,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" @@ -554,6 +601,12 @@ dependencies = [ "no_std_io2", ] +[[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" @@ -638,6 +691,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" @@ -660,7 +723,7 @@ checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" dependencies = [ "bitflags 2.13.2", "polling", - "rustix 1.1.5", + "rustix 1.1.6", "tracing", ] @@ -683,7 +746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" dependencies = [ "calloop 0.14.5", - "rustix 1.1.5", + "rustix 1.1.6", "wayland-backend", "wayland-client", ] @@ -703,7 +766,7 @@ dependencies = [ "find-msvc-tools", "jobserver", "libc", - "shlex", + "shlex 2.0.1", ] [[package]] @@ -712,6 +775,25 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[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]] name = "cfg-if" version = "1.0.5" @@ -733,6 +815,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 0.10.1", +] + [[package]] name = "chrono" version = "0.4.45" @@ -740,10 +833,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", + "js-sys", "num-traits", + "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.1" @@ -817,6 +923,12 @@ dependencies = [ "crossbeam-utils", ] +[[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" @@ -867,6 +979,19 @@ 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" @@ -931,64 +1056,152 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "craft-appkit" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "block2 0.6.2", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "craft-atomic" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "rustix 1.1.6", +] + [[package]] name = "craft-audio" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=010702ee9b030844c852939095b1da0d0656a890#010702ee9b030844c852939095b1da0d0656a890" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-media", "thiserror 2.0.21", ] +[[package]] +name = "craft-behavior" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "accesskit", + "bitflags 2.13.2", + "craft-host", + "craft-keymap", + "craft-theme", + "craft-tracked", + "craft-ui-macros", + "emath", + "kurbo", + "serde", + "smallvec", +] + [[package]] name = "craft-cfb" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1#8048f8ef92da80fb3ce5a056d59ca591ee66faf1" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" + +[[package]] +name = "craft-cloud-ui" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "egui", +] [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=254e9a409b410dc93c0e06ff66cd1e767893ac32#254e9a409b410dc93c0e06ff66cd1e767893ac32" - -[[package]] -name = "craft-codepage" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d0193d7e94b5ec180ecc2a152ea72047d39ac632#d0193d7e94b5ec180ecc2a152ea72047d39ac632" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" [[package]] name = "craft-deckcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=254e9a409b410dc93c0e06ff66cd1e767893ac32#254e9a409b410dc93c0e06ff66cd1e767893ac32" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=254e9a409b410dc93c0e06ff66cd1e767893ac32)", + "craft-zip", "serde", "serde_json", "thiserror 2.0.21", "zip 9.1.0", ] +[[package]] +name = "craft-docpath" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "serde", +] + [[package]] name = "craft-drawingml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1#8048f8ef92da80fb3ce5a056d59ca591ee66faf1" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ + "chrono", "craft-xml", "kurbo", "log", "serde", ] +[[package]] +name = "craft-font-catalog" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +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=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" + +[[package]] +name = "craft-host" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +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=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ + "chrono", "fixed_decimal", + "icu_calendar", + "icu_collator", + "icu_datetime", "icu_decimal", "icu_locale_core", "icu_locale_fallback", @@ -998,6 +1211,7 @@ dependencies = [ "icu_provider", "icu_provider_adapters", "icu_provider_blob", + "icu_time", "log", "objc2-foundation 0.3.2", "sys-locale", @@ -1006,10 +1220,25 @@ dependencies = [ "writeable", ] +[[package]] +name = "craft-keymap" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-host", + "craft-i18n", + "craft-tracked", + "craft-ui-macros", + "craft-xml", + "egui", + "serde", + "serde_json", +] + [[package]] name = "craft-mcp-server" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=bc186ca719958fcce3b6ee24794277eabed14609#bc186ca719958fcce3b6ee24794277eabed14609" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "serde_json", ] @@ -1017,7 +1246,7 @@ dependencies = [ [[package]] name = "craft-media" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=010702ee9b030844c852939095b1da0d0656a890#010702ee9b030844c852939095b1da0d0656a890" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "thiserror 2.0.21", ] @@ -1025,7 +1254,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f428c3d36e0faf3924b76956a01334c051543527#f428c3d36e0faf3924b76956a01334c051543527" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "encoding_rs", "image", @@ -1036,20 +1265,20 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=254e9a409b410dc93c0e06ff66cd1e767893ac32#254e9a409b410dc93c0e06ff66cd1e767893ac32" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "chrono", - "craft-codepage 0.1.0 (git+https://github.com/storytold/craft-libs?rev=254e9a409b410dc93c0e06ff66cd1e767893ac32)", + "craft-codepage", "encoding_rs", ] [[package]] name = "craft-opc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1#8048f8ef92da80fb3ce5a056d59ca591ee66faf1" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-xml", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1)", + "craft-zip", "log", "thiserror 2.0.21", ] @@ -1057,16 +1286,48 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "krilla", + "serde", "thiserror 2.0.21", ] +[[package]] +name = "craft-platform" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +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 0.62.2", + "x11rb", + "xcap", + "zbus", +] + [[package]] name = "craft-pptx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1#8048f8ef92da80fb3ce5a056d59ca591ee66faf1" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-drawingml", "craft-opc", @@ -1078,49 +1339,254 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-quit" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "dispatch2", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "craft-rtf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d0193d7e94b5ec180ecc2a152ea72047d39ac632#d0193d7e94b5ec180ecc2a152ea72047d39ac632" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ - "craft-codepage 0.1.0 (git+https://github.com/storytold/craft-libs?rev=d0193d7e94b5ec180ecc2a152ea72047d39ac632)", + "craft-codepage", "encoding_rs", ] +[[package]] +name = "craft-settings" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +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=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-xml", + "flate2", + "kurbo", + "quick-xml 0.41.0", + "resvg", + "roxmltree", + "thiserror 2.0.21", + "usvg", + "vectorcraft-geom", + "vectorcraft-pathops", +] + +[[package]] +name = "craft-theme" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "bitflags 2.13.2", + "craft-tracked", + "craft-ui-macros", + "ecolor", + "log", + "serde", + "serde_json", + "smallvec", +] + +[[package]] +name = "craft-tracked" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" + [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ - "craft-fonts-build", + "craft-cloud-ui", + "craft-ui-canvas", + "craft-ui-contract", + "craft-ui-panels", + "craft-ui-patterns", + "craft-ui-shell", + "craft-ui-widgets", +] + +[[package]] +name = "craft-ui-canvas" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-behavior", "craft-i18n", + "craft-keymap", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", "egui", - "epaint", - "js-sys", + "serde", + "serde_json", +] + +[[package]] +name = "craft-ui-contract" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +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", - "objc2 0.6.5", - "objc2-app-kit 0.3.2", - "objc2-foundation 0.3.2", + "scoped-tls", + "serde", + "serde_json", + "siphasher", "skrifa 0.44.0", - "wasm-bindgen", + "smallvec", + "toml", + "typeid", "wasm-bindgen-futures", - "web-sys", + "web-time", +] + +[[package]] +name = "craft-ui-macros" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "craft-ui-panels" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-quit", + "craft-theme", + "craft-ui-macros", + "craft-ui-widgets", + "egui", + "serde", + "serde_json", +] + +[[package]] +name = "craft-ui-patterns" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-pdf", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", + "egui", + "serde", + "serde_json", + "toml", + "toml_edit", + "zeroize", +] + +[[package]] +name = "craft-ui-shell" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-platform", + "craft-svg", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", + "craft-window", + "egui", + "raw-window-handle", + "serde", + "web-time", +] + +[[package]] +name = "craft-ui-widgets" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +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=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "chrono", + "craft-host", + "craft-theme", + "craft-ui", "dunce", "egui", "flate2", - "getrandom 0.3.4", "image", "log", "plist", - "rustix 1.1.5", + "rustix 1.1.6", "semver", "serde", "serde_json", @@ -1137,7 +1603,7 @@ dependencies = [ [[package]] name = "craft-video" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=010702ee9b030844c852939095b1da0d0656a890#010702ee9b030844c852939095b1da0d0656a890" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-media", "rav1e", @@ -1148,7 +1614,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=fd5e2feff6ea25bed371a99cc732b3968d621505#fd5e2feff6ea25bed371a99cc732b3968d621505" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "js-sys", "serde_json", @@ -1159,16 +1625,51 @@ dependencies = [ [[package]] name = "craft-web-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=fd5e2feff6ea25bed371a99cc732b3968d621505#fd5e2feff6ea25bed371a99cc732b3968d621505" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ + "craft-host", + "craft-platform", "wasm-bindgen", + "wasm-bindgen-futures", "web-sys", ] +[[package]] +name = "craft-win32" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "winsafe", +] + +[[package]] +name = "craft-window" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" +dependencies = [ + "craft-appkit", + "craft-atomic", + "craft-behavior", + "craft-host", + "craft-settings", + "craft-win32", + "egui", + "muda", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "raw-window-handle", + "serde", + "serde_json", + "wayland-client", + "winsafe", + "x11rb", +] + [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1#8048f8ef92da80fb3ce5a056d59ca591ee66faf1" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1178,17 +1679,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=254e9a409b410dc93c0e06ff66cd1e767893ac32#254e9a409b410dc93c0e06ff66cd1e767893ac32" -dependencies = [ - "flate2", - "thiserror 2.0.21", - "zip 9.1.0", -] - -[[package]] -name = "craft-zip" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8048f8ef92da80fb3ce5a056d59ca591ee66faf1#8048f8ef92da80fb3ce5a056d59ca591ee66faf1" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1266,6 +1757,12 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + [[package]] name = "deckcraft" version = "0.19.0" @@ -1503,8 +2000,12 @@ dependencies = [ name = "deckcraft-ui-egui" version = "0.19.0" dependencies = [ + "craft-host", + "craft-keymap", + "craft-theme", "craft-ui", "craft-update", + "craft-window", "deckcraft-anim", "deckcraft-color", "deckcraft-engine", @@ -1584,6 +2085,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.61.2", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1643,6 +2165,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" @@ -1652,7 +2229,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "emath", @@ -1661,7 +2238,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1696,7 +2273,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "accesskit", "ahash", @@ -1715,7 +2292,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1734,7 +2311,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "accesskit_winit", "arboard", @@ -1760,7 +2337,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "egui", @@ -1773,7 +2350,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "egui", @@ -1786,7 +2363,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "dify", "eframe", @@ -1812,11 +2389,23 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", ] +[[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.42" @@ -1881,7 +2470,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1907,7 +2496,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" [[package]] name = "equator" @@ -1942,7 +2531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2198,6 +2787,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" @@ -2214,7 +2827,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix 1.1.5", + "rustix 1.1.6", "windows-link", ] @@ -2260,6 +2873,7 @@ dependencies = [ "js-sys", "libc", "r-efi 6.0.0", + "rand_core 0.10.1", "wasm-bindgen", ] @@ -2273,6 +2887,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" @@ -2301,6 +2924,12 @@ dependencies = [ "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" @@ -2502,6 +3131,12 @@ dependencies = [ "zune-jpeg", ] +[[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" @@ -2596,6 +3231,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" @@ -2604,12 +3272,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" @@ -2671,6 +3364,7 @@ dependencies = [ "icu_normalizer_data", "icu_properties", "icu_provider", + "serde", "smallvec", "utf16_iter", "utf8_iter", @@ -2721,6 +3415,7 @@ dependencies = [ "icu_locale_core", "icu_properties_data", "icu_provider", + "serde", "zerotrie", "zerovec", ] @@ -2773,6 +3468,22 @@ 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 = "idna" version = "1.1.0" @@ -2829,6 +3540,12 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09e54e57b4c48b40f7aec75635392b12b3421fa26fe8b4332e63138ed278459c" +[[package]] +name = "imagesize" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b27460c2c92b037f3f94c538ed9a3342f3fdf923606781629ccb35f82d042a" + [[package]] name = "indexmap" version = "2.14.2" @@ -2850,6 +3567,15 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + [[package]] name = "is-docker" version = "0.2.0" @@ -2869,6 +3595,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.14.0" @@ -2988,6 +3723,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keyboard-types" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d" +dependencies = [ + "bitflags 2.13.2", + "serde", +] + [[package]] name = "khronos-egl" version = "6.0.0" @@ -3018,7 +3763,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "base64 0.22.1", "bumpalo", @@ -3026,7 +3771,7 @@ dependencies = [ "float-cmp", "gif", "image-webp", - "imagesize", + "imagesize 0.14.0", "indexmap", "pdf-writer", "png", @@ -3106,18 +3851,85 @@ dependencies = [ "redox_syscall 0.9.4", ] +[[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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" +[[package]] +name = "linesweeper" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a25df1b0c5432893f41bba817150e323703ee5f6d974f3a6808ac7fd7f046d18" +dependencies = [ + "arrayvec", + "kurbo", + "polycool", + "rustc-hash 2.1.3", + "smallvec", +] + [[package]] name = "linux-raw-sys" 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" @@ -3207,6 +4019,12 @@ dependencies = [ "walkdir", ] +[[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" @@ -3237,6 +4055,24 @@ dependencies = [ "pxfm", ] +[[package]] +name = "muda" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4340e89c178916e62879c5c36b7f699019369be413e496178a6983ce91b8bc03" +dependencies = [ + "crossbeam-channel", + "dpi", + "keyboard-types", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "png", + "thiserror 2.0.21", + "windows-sys 0.61.2", +] + [[package]] name = "multiversion_no_op" version = "1.0.0" @@ -3344,6 +4180,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" @@ -3365,7 +4211,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -3482,8 +4328,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", ] @@ -3496,10 +4342,17 @@ 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]] @@ -3517,6 +4370,38 @@ dependencies = [ "objc2-foundation 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", +] + [[package]] name = "objc2-cloud-kit" version = "0.2.2" @@ -3530,6 +4415,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" @@ -3575,6 +4471,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" @@ -3582,7 +4489,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", ] @@ -3593,10 +4502,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]] @@ -3611,6 +4523,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" @@ -3623,6 +4545,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" @@ -3650,10 +4615,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" @@ -3677,6 +4654,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" @@ -3747,9 +4736,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", @@ -3823,6 +4812,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" +[[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" @@ -3997,6 +4992,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project" version = "1.1.13" @@ -4034,6 +5035,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" @@ -4082,7 +5108,7 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 1.1.5", + "rustix 1.1.6", "windows-sys 0.61.2", ] @@ -4129,6 +5155,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", ] @@ -4259,7 +5287,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" dependencies = [ "rand_chacha", - "rand_core", + "rand_core 0.9.5", +] + +[[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 0.10.1", ] [[package]] @@ -4269,7 +5308,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.9.5", ] [[package]] @@ -4281,6 +5320,12 @@ dependencies = [ "getrandom 0.3.4", ] +[[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" @@ -4314,7 +5359,7 @@ dependencies = [ "num-traits", "paste", "profiling", - "rand", + "rand 0.9.5", "rand_chacha", "simd_helpers", "thiserror 2.0.21", @@ -4429,12 +5474,66 @@ 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 = "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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "resvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e3803f97b999e80cbf7c6ecdd07a8102204d92e1633cf48783720c521196bd" +dependencies = [ + "bytemuck", + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia", + "usvg", +] + [[package]] name = "rfd" version = "0.17.2" @@ -4462,6 +5561,15 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.17.14" @@ -4476,6 +5584,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "roxmltree" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" +dependencies = [ + "memchr", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -4512,15 +5629,15 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4577,7 +5694,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4772,10 +5889,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" @@ -4823,6 +5946,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + [[package]] name = "siphasher" version = "1.0.4" @@ -4921,7 +6053,7 @@ dependencies = [ "libc", "log", "memmap2", - "rustix 1.1.5", + "rustix 1.1.6", "thiserror 2.0.21", "wayland-backend", "wayland-client", @@ -4981,6 +6113,9 @@ name = "strict-num" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] [[package]] name = "subsetter" @@ -5000,6 +6135,16 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "svgtypes" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f12b12995e3638c70618c1facb1ce65302f6a6f706b675f07c58a5d7391120e" +dependencies = [ + "kurbo", + "siphasher", +] + [[package]] name = "symphonia" version = "0.5.5" @@ -5240,6 +6385,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" @@ -5250,6 +6408,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" @@ -5257,10 +6421,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", - "rustix 1.1.5", - "windows-sys 0.52.0", + "rustix 1.1.6", + "windows-sys 0.61.2", ] [[package]] @@ -5365,6 +6529,21 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-skia" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ffee5eaaf5527f630fb0e356b90ebdec84d5d18d937c5e440350f88c5a91ea" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png", + "tiny-skia-path", +] + [[package]] name = "tiny-skia-path" version = "0.12.0" @@ -5427,8 +6606,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614" dependencies = [ "indexmap", + "serde_core", + "serde_spanned", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] @@ -5486,7 +6668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" dependencies = [ "memchr", - "nom", + "nom 8.0.0", "petgraph", ] @@ -5514,6 +6696,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce898823d8cd0f028662d2f349694b1af0a5cc9be83f1d213a00d3147445e1e" +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "typenum" version = "1.20.1" @@ -5638,6 +6826,25 @@ dependencies = [ "serde", ] +[[package]] +name = "usvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977d0a4abdef933f424a99fe09f95576e089b90aebc6f016a3bc813762493e91" +dependencies = [ + "data-url", + "imagesize 0.15.0", + "kurbo", + "log", + "pico-args", + "roxmltree", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", +] + [[package]] name = "utf16_iter" version = "1.0.5" @@ -5678,6 +6885,27 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "vectorcraft-geom" +version = "0.18.0" +source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e" +dependencies = [ + "kurbo", + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "vectorcraft-pathops" +version = "0.18.0" +source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e" +dependencies = [ + "kurbo", + "linesweeper", + "thiserror 2.0.21", + "vectorcraft-geom", +] + [[package]] name = "vello_common" version = "0.2.0" @@ -5721,6 +6949,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" @@ -5855,7 +7089,7 @@ checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" dependencies = [ "cc", "downcast-rs", - "rustix 1.1.5", + "rustix 1.1.6", "scoped-tls", "smallvec", "wayland-sys", @@ -5868,7 +7102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" dependencies = [ "bitflags 2.13.2", - "rustix 1.1.5", + "rustix 1.1.6", "wayland-backend", "wayland-scanner", ] @@ -5890,7 +7124,7 @@ version = "0.31.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" dependencies = [ - "rustix 1.1.5", + "rustix 1.1.6", "wayland-client", "xcursor", ] @@ -5970,6 +7204,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" @@ -5977,7 +7224,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" dependencies = [ "dlib", + "libc", "log", + "memoffset", "once_cell", "pkg-config", ] @@ -6216,13 +7465,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + [[package]] name = "winapi-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -6632,7 +7887,7 @@ dependencies = [ "libc", "log", "os_pipe", - "rustix 1.1.5", + "rustix 1.1.6", "thiserror 2.0.21", "tree_magic_mini", "wayland-backend", @@ -6691,7 +7946,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix 1.1.5", + "rustix 1.1.6", "x11rb-protocol", ] @@ -6701,6 +7956,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 0.10.4", + "scopeguard", + "serde", + "thiserror 2.0.21", + "url", + "widestring", + "windows 0.62.2", + "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" @@ -6796,7 +8093,7 @@ dependencies = [ "hex", "libc", "ordered-stream", - "rustix 1.1.5", + "rustix 1.1.6", "serde", "serde_repr", "tracing", @@ -7077,14 +8374,14 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" diff --git a/Cargo.toml b/Cargo.toml index c089e8ecc..8e804ae36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,17 +12,17 @@ repository = "https://github.com/storytold/deckcraft" [workspace.dependencies] # OPC part-name primitives and package reader/writer. -craft-opc = { git = "https://github.com/storytold/craft-libs", rev = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" } +craft-opc = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # Compound File Binary directory reads (password-protected deck detection). -craft-cfb = { git = "https://github.com/storytold/craft-libs", rev = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" } +craft-cfb = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # Bounded XML reader and writer primitives. -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # DrawingML colours, themes, charts, tables and text (craft-libs#778, #792). -craft-drawingml = { git = "https://github.com/storytold/craft-libs", rev = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" } +craft-drawingml = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # PresentationML PPTX/POTX/PPSX reader and writer (craft-libs#778). -craft-pptx = { git = "https://github.com/storytold/craft-libs", rev = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" } +craft-pptx = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # Shared MCP stdio framing and protocol constants (craft-libs#778). -craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "bc186ca719958fcce3b6ee24794277eabed14609", version = "0.1.0" } +craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # internal deckcraft-geom = { path = "crates/geom" } deckcraft-color = { path = "crates/color" } @@ -62,21 +62,27 @@ vello_cpu = "0.2" vello_common = { version = "0.2", default-features = false } image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp", "gif", "tiff", "bmp"] } # Base64 for command payloads (engine); base64_compat keeps the legacy lenient decoder. Same rev as craft-deckcraft-format. -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "254e9a409b410dc93c0e06ff66cd1e767893ac32", version = "=0.1.0" } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } # craft-media, craft-audio and craft-video share types and stay on one rev. # The .deckcraft package layer (identity, manifest, member names, bounded reads); crates/format maps the presentation onto it. -craft-deckcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "254e9a409b410dc93c0e06ff66cd1e767893ac32", version = "=0.1.0" } -craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "d0193d7e94b5ec180ecc2a152ea72047d39ac632", version = "=0.1.0" } -craft-media = { git = "https://github.com/storytold/craft-libs", rev = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false } -craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false, features = ["opus-decode"] } +craft-deckcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +craft-media = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false } +craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false, features = ["opus-decode"] } # H.264, HEVC, VP9 and AV1 decoders. -craft-video = { git = "https://github.com/storytold/craft-libs", rev = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false, features = ["h264-decode", "hevc-decode", "vp9-decode", "av1-decode", "threads"] } +craft-video = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false, features = ["h264-decode", "hevc-decode", "vp9-decode", "av1-decode", "threads"] } # WMF, EMF and EMF+ reader. -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "f428c3d36e0faf3924b76956a01334c051543527", version = "=0.1.0" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0", default-features = false, features = ["write", "write-simple-text"] } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false, features = ["write", "write-simple-text"] } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "63196e66f3033a6623eb629af95a104d26986725", features = ["egui"] } -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0" } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["ui"] } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +# The framework runtime's host: the app's identity, its window services, its key overrides and the theme mode +# the framework's components draw in. +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" } i_overlay = "9" quick-xml = "0.41" zip = { version = "3", default-features = false, features = ["deflate"] } @@ -123,19 +129,19 @@ codegen-units = 16 debug = 0 [patch.crates-io] -krilla = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.8.2" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.8.2" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +emath = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } diff --git a/apps/deckcraft-web/Cargo.toml b/apps/deckcraft-web/Cargo.toml index da9dc7d8e..e8b6b39fb 100644 --- a/apps/deckcraft-web/Cargo.toml +++ b/apps/deckcraft-web/Cargo.toml @@ -17,9 +17,9 @@ path = "src/main.rs" deckcraft-engine = { workspace = true } deckcraft-ui-egui = { workspace = true } # The page command API (storytold/craft-libs#413): window.deckcraft over the control channel. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } # The host messages (storytold/craft-libs): one contract and one bridge for the web builds. -craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" } +craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" } egui = { workspace = true } log = { workspace = true } serde_json = { workspace = true } diff --git a/apps/deckcraft-web/src/web.rs b/apps/deckcraft-web/src/web.rs index 8801860c0..86e5e651b 100644 --- a/apps/deckcraft-web/src/web.rs +++ b/apps/deckcraft-web/src/web.rs @@ -49,10 +49,13 @@ pub fn start() { log::info!("deckcraft-web {}: wgpu backend {:?}", env!("CARGO_PKG_VERSION"), rs.adapter.get_info().backend); } deckcraft_ui_egui::install_ime_pass_hooks(&cc.egui_ctx); + // The presenter popup draws DeckCraft's presenter view only, with no framework component, so + // it runs without the framework runtime. if let Some(token) = crate::presenter::token() { let presenter = crate::presenter::Popup::new(token, cc.egui_ctx.clone()).map_err(std::io::Error::other)?; return Ok(Box::new(presenter) as Box); } + deckcraft_ui_egui::framework::install_headless(&cc.egui_ctx); let inbox: Inbox = Inbox::default(); let mut services = services(inbox.clone(), cc.egui_ctx.clone()); if let Some(bridge) = &app_bridge { @@ -131,6 +134,7 @@ impl eframe::App for WebShell { bridge.open_files(&mut self.app); } self.app.logic(ctx); + self.app.close_path(ctx); if let Some(bridge) = &self.bridge { bridge.report_dirty(&self.app); } @@ -166,6 +170,7 @@ impl eframe::App for WebShell { }); } self.app.raw_input_hook(ctx, raw); + self.app.before_input(ctx); } fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) { diff --git a/apps/deckcraft/src/main.rs b/apps/deckcraft/src/main.rs index 554b1ea87..9ea9cc085 100644 --- a/apps/deckcraft/src/main.rs +++ b/apps/deckcraft/src/main.rs @@ -49,12 +49,16 @@ impl eframe::App for App { #[cfg(target_os = "macos")] apple_events::poll(&self.1, &mut self.0, ctx); self.0.logic(ctx); + self.0.close_path(ctx); } - /// Forward native raw input to the wrapped application once per pass. + /// Forward native raw input to the wrapped application once per frame, then hand the framework + /// runtime this frame's root values. fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) { self.0.raw_input_hook(ctx, raw); + self.0.before_input(ctx); } - fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) { + fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) { + deckcraft_ui_egui::framework::before_ui(ui.ctx(), &*frame); self.0.ui(ui); } fn on_exit(&mut self) { @@ -361,6 +365,8 @@ fn main() -> eframe::Result { } }; // `Default` lets winit choose, and winit takes Wayland whenever `WAYLAND_DISPLAY` is set. + #[cfg(not(all(unix, not(target_os = "macos"))))] + let x11 = false; #[cfg(all(unix, not(target_os = "macos")))] let native_wayland = !x11 && std::env::var_os("WAYLAND_DISPLAY").is_some_and(|w| !w.is_empty()); #[cfg(not(all(unix, not(target_os = "macos"))))] @@ -391,6 +397,7 @@ fn main() -> eframe::Result { deckcraft_ui_egui::os_window::name_for(deckcraft_ui_egui::os_window::identity()), options, Box::new(move |cc| { + deckcraft_ui_egui::framework::install(&cc.egui_ctx, x11)?; deckcraft_ui_egui::install_ime_pass_hooks(&cc.egui_ctx); let mut app = SlideApp::new(Session::new(), services); // Presenter View asks winit how many displays there are when a show starts. diff --git a/clippy.toml b/clippy.toml index 3522a15b6..ea4e52e55 100644 --- a/clippy.toml +++ b/clippy.toml @@ -2,7 +2,4 @@ allow-unwrap-in-tests = true allow-expect-in-tests = true allow-panic-in-tests = true allow-indexing-slicing-in-tests = true -disallowed-types = [ - { path = "egui::ComboBox", reason = "use craft_ui::ComboBox: egui's combo box menu can't grow back while open (egui#5225)" }, -] cognitive-complexity-threshold = 30 diff --git a/crates/engine/src/keys.rs b/crates/engine/src/keys.rs index 0501a0299..c28430043 100644 --- a/crates/engine/src/keys.rs +++ b/crates/engine/src/keys.rs @@ -293,6 +293,14 @@ impl Session { Ok(true) } + /// Whether Tab has something to do here: text is being edited (it indents, types a tab or goes to the next table + /// cell), or the slide has an object after the selected one. Past the last object it has nothing left to select. + pub fn tab_has_work(&self) -> bool { + let Some(st) = self.active() else { return false }; + let last = st.shapes().iter().rev().find(|s| !s.hidden).map(|s| s.id); + st.selection.text.is_some() || (last.is_some() && st.selection.shapes.first().copied() != last) + } + fn cycle_selection(&mut self, forward: bool) -> Result<()> { let st = self.doc()?; let ids: Vec<_> = st.shapes().iter().filter(|s| !s.hidden).map(|s| s.id).collect(); diff --git a/crates/model/src/chart.rs b/crates/model/src/chart.rs index 38448c725..8f19dc185 100644 --- a/crates/model/src/chart.rs +++ b/crates/model/src/chart.rs @@ -1181,7 +1181,8 @@ mod tests { c.y_format = Some(r#"_-* #\ ##0\ "₽"_-;\-* #\ ##0\ "₽"_-;_-* "-"??\ "₽"_-;_-@_-"#.into()); c.lang = Some("ru-RU".into()); assert_eq!(c.axis_label(false, 800_000.0), "800\u{a0}000 ₽"); - assert_eq!(c.axis_label(false, 0.0), "- ₽"); + // Excel shows each `?` of the zero section as a space. + assert_eq!(c.axis_label(false, 0.0), "- ₽"); // No format: General. assert_eq!(c.axis_label(true, 2.5), "2,5"); c.lang = None; @@ -1190,7 +1191,7 @@ mod tests { c.lang = Some("ru-RU".into()); c.series[0].number_format = Some(r#"#,##0\ "₽""#.into()); assert_eq!(c.data_label(&c.series[0], 516_600_000.0), "516\u{a0}600\u{a0}000 ₽"); - assert_eq!(c.data_label(&c.series[1], 0.0), "- ₽"); + assert_eq!(c.data_label(&c.series[1], 0.0), "- ₽"); } #[test] diff --git a/crates/pptx/src/convert.rs b/crates/pptx/src/convert.rs index 3a31b1a3f..cd9c197de 100644 --- a/crates/pptx/src/convert.rs +++ b/crates/pptx/src/convert.rs @@ -1298,6 +1298,9 @@ fn chart_to(c: &dm_chart::Chart) -> cd_chart::Chart { gridlines: c.gridlines, minor_gridlines: c.minor_gridlines, axis_titles: c.axis_titles.clone(), + // DeckCraft's chart model keeps the raw category labels and the 1900 date system. + category_format: None, + date_1904: false, style: c.style, palette: c.palette.clone(), plot_fill: c.plot_fill.as_ref().map(fill_to), diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 166eba220..dfcd6c5c1 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -21,6 +21,10 @@ deckcraft-media = { workspace = true } egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] } egui_extras = { workspace = true } craft-ui = { workspace = true } +craft-host = { workspace = true } +craft-keymap = { workspace = true } +craft-theme = { workspace = true } +craft-window = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } log = { workspace = true } diff --git a/crates/ui-egui/src/animpane_tests.rs b/crates/ui-egui/src/animpane_tests.rs index 4268ec076..1ec5cb9a5 100644 --- a/crates/ui-egui/src/animpane_tests.rs +++ b/crates/ui-egui/src/animpane_tests.rs @@ -21,13 +21,17 @@ fn harness() -> Harness<'static, SlideApp> { } let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("animation".into()); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 6fa915a29..845f591f1 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -13,6 +13,7 @@ use super::{ mod clipboard; mod commands; mod control; +mod document_focus; pub(crate) mod files; mod frame; mod ime; @@ -22,6 +23,7 @@ mod playback; #[cfg(test)] pub(crate) use clipboard::{OBJECTS_MARKER, system_clipboard_text}; +pub(crate) use document_focus::DocumentFocus; #[cfg(test)] pub(crate) use files::web_image_files; pub use keys::key_name; @@ -69,6 +71,7 @@ impl SlideApp { synthetic_generation: 0, synthetic_target: None, synthetic_focus: None, + document_focus: DocumentFocus::default(), synthetic_injected_time: None, ribbon_scroll: HashMap::new(), show_instance: 0, @@ -86,6 +89,8 @@ impl SlideApp { print_previews: files::PrintPreviews::default(), #[cfg(not(target_arch = "wasm32"))] updates_rt: updates_ui::Runtime::default(), + framework_dialogs: craft_ui::dialog::DialogHost::new(), + framework_host: crate::framework::host(), pending_copy: None, capture: capture::Capture::default(), styled: false, @@ -247,14 +252,6 @@ impl SlideApp { if !self.synthetic.is_empty() || !self.synthetic_next.is_empty() || self.synthetic_pending { ctx.request_repaint(); } - // Closing the window with unsaved changes asks first. - if ctx.input(|i| i.viewport().close_requested()) && !self.quit_confirmed && self.session.documents().iter().any(|d| d.is_dirty()) { - ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); - self.show = None; - if self.dialog.as_ref().is_none_or(|d| d.id != "quit") { - self.dialog = Some(dialogs::Dialog::new("quit")); - } - } self.autosave_if_due(ctx); self.tick_media_clock(ctx); self.note_settled_composition(ctx); @@ -293,6 +290,7 @@ impl SlideApp { let ctx = ui.ctx().clone(); self.ime_frame_viewport = Some(ctx.viewport_id()); self.ime_pending = None; + let document_before = self.document_focus.drawn.take(); if !self.ui_setup(&ctx) { // This pass is discarded for the new fonts. The input events were already consumed // by egui, so keep them queued for the next frame instead of silently losing them. @@ -356,11 +354,13 @@ impl SlideApp { } } }); + self.finish_document(&ctx, document_before); toast::note_missing_fonts(self); toast::show(self, &ctx); dialogs::show(self, &ctx); #[cfg(not(target_arch = "wasm32"))] updates_ui::show(self, &ctx); + self.framework_dialogs.run(ui); menus::palette(self, &ctx); for url in std::mem::take(&mut self.pending_urls) { ctx.open_url(egui::OpenUrl::new_tab(url)); diff --git a/crates/ui-egui/src/app/document_focus.rs b/crates/ui-egui/src/app/document_focus.rs new file mode 100644 index 000000000..fee5c624b --- /dev/null +++ b/crates/ui-egui/src/app/document_focus.rs @@ -0,0 +1,125 @@ +//! The document window (the slide canvas, the slide sorter or the notes page) as the window's one document canvas: its +//! widget, its Tab stop and when it takes the keyboard focus. + +use craft_ui::runtime::overlay::{self, OpenFilter}; + +use super::{SlideApp, ViewMode}; +use crate::framework::{document_id, focus_document, focused_widget, host_canvas}; + +/// How many passes the document asks for the focus: egui names the widget of a closed palette, dialog or menu as +/// focused for one pass after it was last drawn. +const ASKING_PASSES: u8 = 2; + +/// What the document window's focus depends on from pass to pass. +#[derive(Default)] +pub(crate) struct DocumentFocus { + /// The presentation (its uid) whose document window the pass drew; `None` on the start screen, the File tab and in + /// a slide show. + pub(super) drawn: Option, + /// The passes left in which a presentation that opened or became active asks for the focus. + opened: u8, + /// The passes left in which the document asks for the focus after a dialog, menu or popup closed. + uncovered: u8, +} + +impl SlideApp { + /// Draws the document window's widget over `rect` and declares it as the window's canvas. A press in it gives it + /// the focus, unless a dialog is open. Real presses only: with the document focused, egui makes Enter and Space + /// clicks of it. + pub(crate) fn document_widget(&mut self, ui: &egui::Ui, rect: egui::Rect, sense: egui::Sense) -> egui::Response { + let resp = ui.interact(rect, document_id(), sense); + self.document_focus.drawn = self.session.active().map(|d| d.uid); + host_canvas(ui.ctx(), self.document_keeps_tab(ui.ctx())); + if resp.is_pointer_button_down_on() && ui.input(|i| i.pointer.any_pressed()) && !self.dialog_open(ui.ctx()) { + focus_document(ui.ctx()); + } + resp + } + + /// [`Self::document_widget`] behind widgets that take the presses (the slide sorter's thumbnails): a press on any of + /// them gives the document the focus, unless a text field has it. + pub(crate) fn document_behind(&mut self, ui: &egui::Ui, rect: egui::Rect) { + self.document_widget(ui, rect, egui::Sense::focusable_noninteractive()); + let pressed = ui.input(|i| i.pointer.any_pressed()) && ui.rect_contains_pointer(rect); + if pressed && !ui.ctx().text_edit_focused() && !self.overlay_open(ui.ctx()) { + focus_document(ui.ctx()); + } + } + + /// Whether the document window is the slide being edited, where Tab can have work. + fn editing_slide(&self) -> bool { + self.backstage.is_none() && matches!(self.ui.view, ViewMode::Normal | ViewMode::Outline | ViewMode::Reading) + } + + /// Whether the focused document keeps Tab: on the slide, while the session has something for it to do. A modal + /// dialog, a menu or a popup that is up gets it instead. + fn document_keeps_tab(&self, ctx: &egui::Context) -> bool { + self.editing_slide() && self.session.tab_has_work() && !self.overlay_open(ctx) + } + + /// Whether a dialog, DeckCraft's or a modal one of the framework's, the palette or the opening overlay is up. + fn dialog_open(&self, ctx: &egui::Context) -> bool { + self.dialog.as_ref().is_some_and(|d| d.modal()) + || self.palette.is_some() + || self.opening.is_some() + || overlay::any_open(ctx, OpenFilter::Modal) + } + + /// Whether a dialog ([`Self::dialog_open`]), or an egui menu or popup, is up. + fn overlay_open(&self, ctx: &egui::Context) -> bool { + self.dialog_open(ctx) || ctx.any_popup_open() || egui::Popup::is_any_open(ctx) + } + + /// Whether the document may take the focus: no text field and no widget of another layer (the framework's update + /// notice) has it. + fn focus_is_free(ctx: &egui::Context) -> bool { + let layer = |id| ctx.read_response(id).map(|widget| widget.layer_id); + !ctx.text_edit_focused() && focused_widget(ctx).is_none_or(|id| layer(id) == layer(document_id())) + } + + /// Ends the document window's pass, after the views; `before` is the presentation the last pass drew. The pass's + /// input has changed what Tab has to do, so the document is declared again. A presentation that opened or became + /// active asks for the focus. So does the document with nothing focused, when a dialog, menu or popup has closed, and + /// while Tab has work on the slide (a ribbon field committed with Enter leaves nothing focused). All wait for the + /// last dialog, menu or popup to close. + pub(super) fn finish_document(&mut self, ctx: &egui::Context, before: Option) { + let drawn = self.document_focus.drawn; + if drawn.is_none() { + self.document_focus.opened = 0; + self.document_focus.uncovered = 0; + return; + } + let keeps_tab = self.document_keeps_tab(ctx); + host_canvas(ctx, keeps_tab); + if drawn != before { + self.document_focus.opened = ASKING_PASSES; + } + if self.overlay_open(ctx) { + self.document_focus.uncovered = ASKING_PASSES; + return; + } + let unfocused = ctx.memory(|m| m.focused().is_none()); + let DocumentFocus { opened, uncovered, .. } = &mut self.document_focus; + if *opened == 0 && *uncovered == 0 && !(unfocused && keeps_tab) { + return; + } + if unfocused || (*opened > 0 && Self::focus_is_free(ctx)) { + (*opened, *uncovered) = (0, 0); + focus_document(ctx); + } else { + (*opened, *uncovered) = (opened.saturating_sub(1), uncovered.saturating_sub(1)); + ctx.request_repaint(); + } + } + + /// While slide text is being edited, the text owns the keyboard (#93). The focus on an ordinary widget (the ribbon + /// button whose Space inserted the text box) would swallow every later key and end text entry, and with nothing + /// focused (a ribbon field committed with Enter) Tab would leave the text. The document takes the focus; a text + /// field or an open menu keeps its keys. + pub(super) fn edited_text_takes_focus(&self, ctx: &egui::Context) { + let editing = self.editing_slide() && self.session.active().is_some_and(|d| d.selection.text.is_some()); + if editing && !ctx.memory(|m| m.has_focus(document_id())) && !self.overlay_open(ctx) && Self::focus_is_free(ctx) { + focus_document(ctx); + } + } +} diff --git a/crates/ui-egui/src/app/ime.rs b/crates/ui-egui/src/app/ime.rs index 3632b368f..4aaa6d031 100644 --- a/crates/ui-egui/src/app/ime.rs +++ b/crates/ui-egui/src/app/ime.rs @@ -145,7 +145,7 @@ impl SlideApp { && ctx.input(|i| i.viewport().focused.unwrap_or(true)) && ctx.input(|i| i.viewport().visible() != Some(false)) && !ctx.input(|i| i.viewport().close_requested()) - && ctx.memory(|m| m.focused().is_none()) + && !crate::framework::widget_has_keyboard(ctx) && self.dialog.as_ref().is_none_or(|d| !d.modal()) && self.palette.is_none() && self.backstage.is_none() diff --git a/crates/ui-egui/src/app/input.rs b/crates/ui-egui/src/app/input.rs index c50601712..701f08f32 100644 --- a/crates/ui-egui/src/app/input.rs +++ b/crates/ui-egui/src/app/input.rs @@ -140,7 +140,7 @@ impl SlideApp { return; } let current = self.input_target(); - let focus = ctx.memory(|m| m.focused()); + let focus = crate::framework::focused_widget(ctx); if self.synthetic_target == Some(current) && focus == self.synthetic_focus { return; } @@ -210,7 +210,7 @@ impl SlideApp { Err(e) => self.set_status(e), } } - let focus = ctx.memory(|m| m.focused()); + let focus = crate::framework::focused_widget(ctx); if self.synthetic_pending { let current = self.input_target(); if self.synthetic_target != Some(current) || focus != self.synthetic_focus { diff --git a/crates/ui-egui/src/app/keys.rs b/crates/ui-egui/src/app/keys.rs index 7523308c0..4c2769e6d 100644 --- a/crates/ui-egui/src/app/keys.rs +++ b/crates/ui-egui/src/app/keys.rs @@ -1,5 +1,6 @@ use super::clipboard::OBJECTS_MARKER; use super::{Mods, SlideApp, Value, backstage, json, menus}; +use crate::framework::widget_has_keyboard; impl SlideApp { /// The app shortcuts that still make sense on the empty File/start screen: create, open, @@ -47,9 +48,12 @@ impl SlideApp { } } - /// Keyboard and clipboard for the slide (when no text field has focus). + /// Keyboard and clipboard for the slide (with nothing or the document window focused). pub(super) fn keyboard(&mut self, ctx: &egui::Context) { - let events = ctx.input(|i| i.events.clone()); + let mut events = ctx.input(|i| i.events.clone()); + if crate::framework::window_escape(ctx) { + events.push(crate::framework::ESCAPE_PRESS); + } // Ctrl+V with only an image on the clipboard: egui-winit sends no Paste event and swallows the // key press, so the release of a V press never seen is the paste. Tracked even while a text // field has focus, so that a V typed there is not taken for one. @@ -76,26 +80,15 @@ impl SlideApp { // File-tab navigation and document-free shortcuts remain available. self.suspend_ime_reset(viewport); self.route_ime_controls_only(ctx, &events); - if self.palette.is_none() && self.dialog.as_ref().is_none_or(|d| !d.modal()) && ctx.memory(|m| m.focused().is_none()) { + if self.palette.is_none() && self.dialog.as_ref().is_none_or(|d| !d.modal()) && !widget_has_keyboard(ctx) { self.route_backstage_keys(events); } self.drain_requests(); return; } let modal = self.dialog.as_ref().is_some_and(|d| d.modal()) || self.palette.is_some(); - // While slide text is being edited, the text owns the keyboard (#93). Tab and the arrow - // keys move egui's keyboard focus onto ordinary widgets (the window's drag handle, ribbon - // buttons), and that stray focus would swallow every later key and end text entry. Let it - // go; a real text field or an open menu keeps its keys. - if !modal - && self.session.active().is_some_and(|d| d.selection.text.is_some()) - && !ctx.text_edit_focused() - && !ctx.any_popup_open() - && let Some(id) = ctx.memory(|m| m.focused()) - { - ctx.memory_mut(|m| m.surrender_focus(id)); - } - if ctx.memory(|m| m.focused().is_some()) || modal { + self.edited_text_takes_focus(ctx); + if widget_has_keyboard(ctx) || modal { // A stock field/modal/palette owns input now. Retire the custom fence, then visit // controls in raw order; stock text/key events are left for the stock widgets. self.suspend_ime_reset(viewport); @@ -177,12 +170,6 @@ impl SlideApp { } } egui::Event::Key { key, pressed: true, modifiers, .. } => { - if key == egui::Key::Tab { - // The slide has the keyboard, so Tab is ours (indent, tab character, next - // shape). Left to egui it would also focus the first ribbon widget, and - // every key after it would go there instead of the slide (#78). - ctx.memory_mut(|m| m.move_focus(egui::FocusDirection::None)); - } if key == egui::Key::Escape && self.anim_preview.is_some() && !modifiers.command && !modifiers.ctrl && !modifiers.alt { self.anim_preview = None; continue; diff --git a/crates/ui-egui/src/backstage/info.rs b/crates/ui-egui/src/backstage/info.rs index c01168467..5a9ed4aa5 100644 --- a/crates/ui-egui/src/backstage/info.rs +++ b/crates/ui-egui/src/backstage/info.rs @@ -156,7 +156,7 @@ pub(super) fn save_as(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage, out: ui.add_space(14.0); let current = SAVE_TYPES.iter().find(|s| s.0 == bs.file_type).map_or(SAVE_TYPES[0].1, |s| s.1); ui.horizontal(|ui| { - craft_ui::ComboBox::from_id_salt("backstage_save_type") + egui::ComboBox::from_id_salt("backstage_save_type") .width(340.0) // Every type in view: at the default height the last ones were behind a scroll. .height(f32::INFINITY) @@ -234,7 +234,7 @@ pub(super) fn about(app: &mut SlideApp, ui: &mut Ui) { ui.set_width(340.0); heading(ui, "Appearance"); let dark = app.ui.brightness == theme::Brightness::Dark; - craft_ui::ComboBox::from_id_salt("backstage_appearance") + egui::ComboBox::from_id_salt("backstage_appearance") .width(260.0) .selected_text(if dark { "Dark" } else { "Light" }) .show_ui(ui, |ui| { diff --git a/crates/ui-egui/src/backstage/print.rs b/crates/ui-egui/src/backstage/print.rs index f345fb73b..ba67c1e76 100644 --- a/crates/ui-egui/src/backstage/print.rs +++ b/crates/ui-egui/src/backstage/print.rs @@ -96,7 +96,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) { PrintScope::Current => "Print Current Slide", PrintScope::Custom => "Custom Range", }; - let combo = craft_ui::ComboBox::from_id_salt("backstage_print_scope").width(240.0).selected_text(scope).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("backstage_print_scope").width(240.0).selected_text(scope).show_ui(ui, |ui| { for (s, label) in [(PrintScope::All, "Print All Slides"), (PrintScope::Current, "Print Current Slide"), (PrintScope::Custom, "Custom Range")] { @@ -119,7 +119,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) { }); ui.add_space(4.0); let layout = LAYOUTS.iter().find(|l| l.0 == bs.print_layout).map_or("Full Page Slides", |l| l.1); - let combo = craft_ui::ComboBox::from_id_salt("backstage_print_layout").width(240.0).selected_text(layout).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("backstage_print_layout").width(240.0).selected_text(layout).show_ui(ui, |ui| { for (id, label) in LAYOUTS { if ui.selectable_label(bs.print_layout == id, label).clicked() { bs.print_layout = id; @@ -133,7 +133,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) { // for notes pages and handouts. ui.add_enabled_ui(bs.print_layout != "slides", |ui| { let paper = deckcraft_engine::cmd::file::PAPERS.iter().find(|p| p.0 == bs.print_paper).map_or("Letter", |p| p.1); - craft_ui::ComboBox::from_id_salt("backstage_print_paper") + egui::ComboBox::from_id_salt("backstage_print_paper") .width(240.0) .selected_text(paper) .show_ui(ui, |ui| { @@ -147,7 +147,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) { .widget_info(|| egui::WidgetInfo::labeled(egui::Role::ComboBox, true, "Paper size")); ui.add_space(4.0); let orient = if bs.print_landscape { "Landscape Orientation" } else { "Portrait Orientation" }; - craft_ui::ComboBox::from_id_salt("backstage_print_orientation") + egui::ComboBox::from_id_salt("backstage_print_orientation") .width(240.0) .selected_text(orient) .show_ui(ui, |ui| { @@ -321,7 +321,7 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) { ExportTask::Handouts => { ui.label(RichText::new("Create Handouts").font(theme::font(16.0)).color(t.text)); bullets(ui, &["Several slides on each page of a PDF", "Three a page leaves lines for notes", "Print them for your audience"]); - let combo = craft_ui::ComboBox::from_id_salt("backstage_handouts") + let combo = egui::ComboBox::from_id_salt("backstage_handouts") .width(240.0) .selected_text(format!("{} slides per page", bs.handouts_per_page)) .show_ui(ui, |ui| { diff --git a/crates/ui-egui/src/backstage/tests.rs b/crates/ui-egui/src/backstage/tests.rs index 9153f4c49..bd580553c 100644 --- a/crates/ui-egui/src/backstage/tests.rs +++ b/crates/ui-egui/src/backstage/tests.rs @@ -16,7 +16,7 @@ use crate::backstage::{Backstage, NAV_W, Nav, Page, PrintScope, entries, format_ use crate::{Services, SlideApp}; fn harness(app: SlideApp) -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -184,7 +184,7 @@ fn every_page_renders() { /// In a window narrower than the page's maximum width the New tiles stay inside the right margin (#1421). #[test] fn new_tiles_keep_the_right_margin_in_a_narrow_window() { - let mut h = Harness::builder().with_size(egui::vec2(1000.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1000.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -847,7 +847,7 @@ fn about_has_product_links_and_credits_without_account_controls() { /// At the 900-point minimum window width the About columns stack and Appearance stays on the page. #[test] fn about_appearance_stays_on_the_page_at_minimum_width() { - let mut h = Harness::builder().with_size(egui::vec2(900.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(900.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/browsetheme_tests.rs b/crates/ui-egui/src/browsetheme_tests.rs index cb65ec59b..d012f9a04 100644 --- a/crates/ui-egui/src/browsetheme_tests.rs +++ b/crates/ui-egui/src/browsetheme_tests.rs @@ -33,13 +33,17 @@ fn browse_button_applies_the_picked_files_theme() { s.execute("slide.new", &json!({"layout": "title", "title": "Hello"})).unwrap(); let mut app = SlideApp::new(s, services); app.ui.tab = "Design".into(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1600.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.get_by_label("Browse for Themes…").click(); h.run_steps(3); diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 526d046cd..9a2768d0f 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -112,9 +112,11 @@ fn wheel_navigation(app: &mut SlideApp, ui: &mut Ui, carry_id: egui::Id, doc_uid } fn empty_deck_prompt(app: &mut SlideApp, ui: &mut Ui, avail: Rect, t: &Tokens) { - let resp = ui.allocate_rect(avail, Sense::click()); + ui.advance_cursor_after_rect(avail); + let resp = app.document_widget(ui, avail, Sense::click()); ui.painter().text(avail.center(), Align2::CENTER_CENTER, "Click to add first slide", theme::font(22.0), t.text_dim); - if resp.clicked() { + // Enter on the focused document is the session's New Slide, not a click of the prompt. + if resp.clicked_by(egui::PointerButton::Primary) || ui.input(|i| i.has_accesskit_action_request(resp.id, egui::accesskit::Action::Click)) { let _ = app.run("slide.new", json!({"layout": "title"})); } } @@ -172,7 +174,8 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) { let last_id = scroll_id.with("last"); let mut offset: egui::Vec2 = ui.data_mut(|d| d.get_temp(scroll_id).unwrap_or_default()); let last: Option<(Rect, f32)> = ui.data_mut(|d| d.get_temp(last_id)); - let resp = ui.allocate_rect(avail, Sense::click_and_drag()); + ui.advance_cursor_after_rect(avail); + let resp = app.document_widget(ui, avail, Sense::click_and_drag()); let (wheel, zoom_delta, hover) = ui.input(|i| (i.smooth_scroll_delta, i.zoom_delta(), i.pointer.hover_pos())); let zooming = resp.hovered() && (zoom_delta - 1.0).abs() > 1e-3; if zooming { diff --git a/crates/ui-egui/src/canvas/context_menu.rs b/crates/ui-egui/src/canvas/context_menu.rs index 1aa1c9286..532521dac 100644 --- a/crates/ui-egui/src/canvas/context_menu.rs +++ b/crates/ui-egui/src/canvas/context_menu.rs @@ -7,7 +7,9 @@ pub(super) fn context_menu(app: &mut SlideApp, resp: &egui::Response) { { app.session.tool.edit_vertex = Some((path, index)); } - resp.context_menu(|ui| { + // Real clicks only: with the canvas focused, egui's own context menu would close on Enter and Space. + let open = if resp.secondary_clicked() { Some(true) } else { resp.clicked_by(egui::PointerButton::Primary).then_some(false) }; + egui::Popup::context_menu(resp).open_memory(open.map(egui::SetOpenCommand::Bool)).show(|ui| { let editing = app.session.active().and_then(|d| app.session.tool.editing_points(d).and_then(|id| d.shape(id).cloned())); if let Some(sh) = editing { edit_points_menu(app, ui, &sh); diff --git a/crates/ui-egui/src/canvas/guides_tests.rs b/crates/ui-egui/src/canvas/guides_tests.rs index baa480e52..a63362738 100644 --- a/crates/ui-egui/src/canvas/guides_tests.rs +++ b/crates/ui-egui/src/canvas/guides_tests.rs @@ -14,13 +14,17 @@ fn turn_guides_on_drag_one_and_drop_it_off_the_slide() { let mut s = Session::with_new(); s.execute("slide.new", &json!({"layout": "blank"})).unwrap(); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.state_mut().run("view.guides", json!({"on": true})).unwrap(); h.run_steps(2); diff --git a/crates/ui-egui/src/canvas/ime.rs b/crates/ui-egui/src/canvas/ime.rs index 61f47bc14..12253a12e 100644 --- a/crates/ui-egui/src/canvas/ime.rs +++ b/crates/ui-egui/src/canvas/ime.rs @@ -34,7 +34,7 @@ pub fn ime_area(app: &SlideApp, xf: Xf) -> Option { /// has settled. pub(super) fn ime_output(app: &mut SlideApp, ui: &Ui, xf: Xf) { let ctx = ui.ctx(); - if ctx.memory(|m| m.focused().is_some()) || app.dialog.as_ref().is_some_and(|d| d.modal()) || app.palette.is_some() || app.backstage_open() { + if crate::framework::widget_has_keyboard(ctx) || app.dialog.as_ref().is_some_and(|d| d.modal()) || app.palette.is_some() || app.backstage_open() { return; } let Some(r) = ime_area(app, xf) else { return }; diff --git a/crates/ui-egui/src/canvas/ruler_tests.rs b/crates/ui-egui/src/canvas/ruler_tests.rs index dd15c2a25..38a5c863d 100644 --- a/crates/ui-egui/src/canvas/ruler_tests.rs +++ b/crates/ui-egui/src/canvas/ruler_tests.rs @@ -42,13 +42,17 @@ fn drag_indents_add_move_and_remove_tabs_on_the_ruler() { s.execute("text.insert", &json!({"text": "Name\tRole\tTeam"})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.ruler = true; - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); let (slide, k) = (h.state().slide_rect.unwrap(), h.state().canvas_scale); let x0 = ruler(&mut h)["x"].as_f64().unwrap() as f32; @@ -93,13 +97,17 @@ fn editing_harness() -> Harness<'static, SlideApp> { s.execute("text.insert", &json!({"text": "Item\t9.50"})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.ruler = true; - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 802dec29a..24097a00c 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -95,7 +95,7 @@ fn a_placeholder_that_inherits_its_box_has_a_resize_cursor() { } fn harness() -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -315,13 +315,14 @@ fn app_with_table() -> (egui_kittest::Harness<'static, SlideApp>, deckcraft_mode let r = s.execute("insert.table", &json!({"rows": 2, "cols": 2, "rect": [100.0, 100.0, 400.0, 80.0], "data": data})).unwrap(); let id = deckcraft_model::ShapeId(r["id"].as_u64().unwrap() as u32); s.execute("edit.deselect", &json!({})).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(s, Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(s, Services::default()), + ); // The app keeps requesting repaints, so step frames instead of run(). harness.run_steps(2); (harness, id) diff --git a/crates/ui-egui/src/compare_tests.rs b/crates/ui-egui/src/compare_tests.rs index c51ce1fde..58c2f6715 100644 --- a/crates/ui-egui/src/compare_tests.rs +++ b/crates/ui-egui/src/compare_tests.rs @@ -22,13 +22,17 @@ fn harness() -> (Harness<'static, SlideApp>, usize) { s.set_active(0); s.execute("review.compare", &json!({"name": "Q3 review.deckcraft", "data": rev})).unwrap(); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(4); (h, n) } diff --git a/crates/ui-egui/src/datetime_tests.rs b/crates/ui-egui/src/datetime_tests.rs index 8a92c6379..f76278500 100644 --- a/crates/ui-egui/src/datetime_tests.rs +++ b/crates/ui-egui/src/datetime_tests.rs @@ -12,7 +12,7 @@ use crate::{Services, SlideApp}; fn harness() -> Harness<'static, SlideApp> { let mut app = SlideApp::new(Session::with_new(), Services::default()); app.ui.tab = "Insert".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index c7575dfd9..2074dfd04 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -109,7 +109,7 @@ pub fn show(app: &mut SlideApp, ctx: &egui::Context) { } close = body(app, ui, &mut d); }); - let escape = ctx.input(|i| i.key_pressed(egui::Key::Escape)); + let escape = crate::framework::escape_pressed(ctx); if open && !close && !escape { app.dialog = Some(d); } else if !close && d.id == "preferences" { @@ -262,7 +262,7 @@ fn color_label(v: &Value) -> String { fn choice(ui: &mut Ui, d: &mut Dialog, salt: &str, name: &str, key: &str, choices: &[(&str, &str)]) { let cur = d.get(key, ""); let label = choices.iter().find(|(v, _)| *v == cur).map(|(_, l)| *l).unwrap_or(cur.as_str()); - let combo = craft_ui::ComboBox::from_id_salt(salt).selected_text(label).width(140.0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt(salt).selected_text(label).width(140.0).show_ui(ui, |ui| { for (v, l) in choices { if ui.selectable_label(cur == *v, *l).clicked() { d.fields.insert((*key).into(), (*v).into()); diff --git a/crates/ui-egui/src/dialogs/about.rs b/crates/ui-egui/src/dialogs/about.rs index 79fa0c7b8..9c94db3dc 100644 --- a/crates/ui-egui/src/dialogs/about.rs +++ b/crates/ui-egui/src/dialogs/about.rs @@ -85,13 +85,17 @@ mod about_credits_tests { fn about_dialog_tabs_keep_responding() { let mut app = SlideApp::new(deckcraft_engine::Session::with_new(), Services::default()); app.dialog = Some(Dialog::new("about")); - let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1440.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(4); assert_eq!(tab_of(&h), "about"); for label in ["Contributors", "Models", "About", "Models", "Contributors"] { diff --git a/crates/ui-egui/src/dialogs/body.rs b/crates/ui-egui/src/dialogs/body.rs index 5399735ac..bcbc26082 100644 --- a/crates/ui-egui/src/dialogs/body.rs +++ b/crates/ui-egui/src/dialogs/body.rs @@ -101,7 +101,7 @@ fn dlg_slide_size(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { } let label = ui.label("Slides sized for:"); let preset = d.get("preset", ""); - let combo = craft_ui::ComboBox::from_id_salt("sizes").selected_text(if preset.is_empty() { "Custom" } else { &preset }).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("sizes").selected_text(if preset.is_empty() { "Custom" } else { &preset }).show_ui(ui, |ui| { for (label, w, h) in deckcraft_model::defaults::SLIDE_SIZES { if ui.selectable_label(preset == *label, *label).clicked() { d.fields.insert("preset".into(), label.to_string()); @@ -149,7 +149,7 @@ fn dlg_header_footer(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { ui.add_enabled_ui(date && automatic, |ui| { ui.horizontal(|ui| { ui.label(" Format:"); - craft_ui::ComboBox::from_id_salt("hf-date-format").selected_text(label).width(200.0).show_ui(ui, |ui| { + egui::ComboBox::from_id_salt("hf-date-format").selected_text(label).width(200.0).show_ui(ui, |ui| { for (kind, sample) in &rows { if ui.selectable_label(fmt == *kind, sample).clicked() { d.fields.insert("dateFormat".into(), (*kind).to_string()); @@ -264,7 +264,7 @@ fn dlg_setup_show(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { let chosen = d.fields.entry("custom".into()).or_insert_with(|| sh.custom_show.clone().unwrap_or_default()).clone(); let field = ui.label("Slides"); let label = if chosen.is_empty() { "All slides".to_string() } else { chosen.clone() }; - let combo = craft_ui::ComboBox::from_id_salt("setup_custom").selected_text(label).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("setup_custom").selected_text(label).show_ui(ui, |ui| { if ui.selectable_label(chosen.is_empty(), "All slides").clicked() { d.fields.insert("custom".into(), String::new()); } @@ -428,7 +428,7 @@ fn dlg_bullets(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { let color = d.get("color", ""); ui.horizontal(|ui| { let field = ui.add_sized(vec2(120.0, 20.0), egui::Label::new("Color:")); - let combo = craft_ui::ComboBox::from_id_salt("bullet-color") + let combo = egui::ComboBox::from_id_salt("bullet-color") .selected_text(colors.iter().find(|c| c.0 == color).map_or("Automatic", |c| c.1)) .show_ui(ui, |ui| { for (k, l) in colors { @@ -535,7 +535,7 @@ fn dlg_action(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { ]; let shown = targets.iter().find(|t| t.0 == kind).map_or("Next Slide", |t| t.1); ui.add_enabled_ui(hyperlink, |ui| { - let combo = craft_ui::ComboBox::from_id_salt("action-target").selected_text(shown).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("action-target").selected_text(shown).show_ui(ui, |ui| { for (k, l) in targets { if ui.selectable_label(kind == k, l).clicked() { d.fields.insert("kind".into(), k.into()); @@ -733,7 +733,7 @@ fn dlg_export(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { ui.add_space(4.0); ui.horizontal(|ui| { let field = ui.label("Print layout:"); - let combo = craft_ui::ComboBox::from_id_salt("pdf_layout") + let combo = egui::ComboBox::from_id_salt("pdf_layout") .selected_text(match pdf_layout.as_str() { "notes" => "Notes Pages", "h1" => "Handouts (1 slide per page)", @@ -818,7 +818,7 @@ fn dlg_replace_fonts(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { let mut to = d.get("to", ""); egui::Grid::new("replace_fonts").num_columns(2).spacing(vec2(10.0, 8.0)).show(ui, |ui| { let field = ui.label("Replace:"); - let combo = craft_ui::ComboBox::from_id_salt("rf_from").width(240.0).selected_text(from.clone()).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("rf_from").width(240.0).selected_text(from.clone()).show_ui(ui, |ui| { for f in &used { ui.selectable_value(&mut from, f.clone(), f); } diff --git a/crates/ui-egui/src/dialogs/columns_dialog_tests.rs b/crates/ui-egui/src/dialogs/columns_dialog_tests.rs index 7737031c4..e2a9d929a 100644 --- a/crates/ui-egui/src/dialogs/columns_dialog_tests.rs +++ b/crates/ui-egui/src/dialogs/columns_dialog_tests.rs @@ -31,13 +31,17 @@ fn two_boxes() -> Harness<'static, SlideApp> { fn harness_of(s: Session) -> Harness<'static, SlideApp> { let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1440.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(4); h } diff --git a/crates/ui-egui/src/dialogs/credits.rs b/crates/ui-egui/src/dialogs/credits.rs index b9b32e56e..fdb0c43fc 100644 --- a/crates/ui-egui/src/dialogs/credits.rs +++ b/crates/ui-egui/src/dialogs/credits.rs @@ -223,7 +223,7 @@ pub fn contributors_ui(ui: &mut egui::Ui) { } ui.separator(); let field = ui.label("Sort"); - let combo = craft_ui::ComboBox::from_id_salt("credits_sort").selected_text(v.key.label().0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("credits_sort").selected_text(v.key.label().0).show_ui(ui, |ui| { for k in SortKey::ALL { if ui.selectable_label(v.key == k, k.label().0).clicked() { v.key = k; diff --git a/crates/ui-egui/src/dialogs/date_time.rs b/crates/ui-egui/src/dialogs/date_time.rs index 3ba1c3d7e..487ccc5b8 100644 --- a/crates/ui-egui/src/dialogs/date_time.rs +++ b/crates/ui-egui/src/dialogs/date_time.rs @@ -49,7 +49,7 @@ pub(super) fn date_time_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) let lang_label = DATE_LANGS.iter().find(|(k, _)| *k == lang).map(|(_, l)| *l).unwrap_or("English (United States)"); ui.horizontal(|ui| { ui.label("Language:"); - let opened = craft_ui::ComboBox::from_id_salt("date-lang").selected_text(lang_label).width(240.0).show_ui(ui, |ui| { + let opened = egui::ComboBox::from_id_salt("date-lang").selected_text(lang_label).width(240.0).show_ui(ui, |ui| { for (k, l) in DATE_LANGS { if ui.selectable_label(lang == *k, *l).clicked() { d.fields.insert("language".into(), (*k).to_string()); diff --git a/crates/ui-egui/src/dialogs/export.rs b/crates/ui-egui/src/dialogs/export.rs index 432ac58ef..d4dad564e 100644 --- a/crates/ui-egui/src/dialogs/export.rs +++ b/crates/ui-egui/src/dialogs/export.rs @@ -16,7 +16,7 @@ pub(super) fn gif_options(app: &SlideApp, ui: &mut Ui, d: &mut Dialog) -> Result ui.add_space(4.0); ui.horizontal(|ui| { let field = ui.add_sized(vec2(120.0, 20.0), egui::Label::new("Size:")); - let combo = craft_ui::ComboBox::from_id_salt("gif_size").selected_text(size_label(&size)).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("gif_size").selected_text(size_label(&size)).show_ui(ui, |ui| { for k in SIZE_PRESETS.iter().map(|(k, _)| *k).chain(["custom"]) { if ui.selectable_label(size == k, size_label(k)).clicked() { d.fields.insert("gifSize".into(), k.into()); diff --git a/crates/ui-egui/src/dialogs/font.rs b/crates/ui-egui/src/dialogs/font.rs index a163e7bce..9a18e1bc8 100644 --- a/crates/ui-egui/src/dialogs/font.rs +++ b/crates/ui-egui/src/dialogs/font.rs @@ -26,7 +26,7 @@ pub(super) fn font_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bo } ui.horizontal(|ui| { let field = ui.add_sized(vec2(88.0, 20.0), egui::Label::new("Font")); - let combo = craft_ui::ComboBox::from_id_salt("font_dialog_family") + let combo = egui::ComboBox::from_id_salt("font_dialog_family") .selected_text(if family.is_empty() { " " } else { family.as_str() }) .width(300.0) .show_ui(ui, |ui| { @@ -75,7 +75,7 @@ pub(super) fn font_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bo let mut spacing = d.get("spacing", "0"); let edited = ui.add(egui::TextEdit::singleline(&mut spacing).desired_width(64.0).hint_text("pt")); let mut picked = None; - let combo = craft_ui::ComboBox::from_id_salt("font_dialog_spacing") + let combo = egui::ComboBox::from_id_salt("font_dialog_spacing") .selected_text(match spacing.as_str() { "-3" => "Very tight", "-1.5" => "Tight", diff --git a/crates/ui-egui/src/dialogs/font_dialog_tests.rs b/crates/ui-egui/src/dialogs/font_dialog_tests.rs index 06ccfc024..9a7e12f6e 100644 --- a/crates/ui-egui/src/dialogs/font_dialog_tests.rs +++ b/crates/ui-egui/src/dialogs/font_dialog_tests.rs @@ -13,13 +13,17 @@ fn harness() -> Harness<'static, SlideApp> { // A selected shape, not a caret: the dialog then formats the text that is already there. let _ = s.execute("text.exit", &json!({})); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1440.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(4); h } diff --git a/crates/ui-egui/src/dialogs/paragraph.rs b/crates/ui-egui/src/dialogs/paragraph.rs index 217076c35..89f4a0840 100644 --- a/crates/ui-egui/src/dialogs/paragraph.rs +++ b/crates/ui-egui/src/dialogs/paragraph.rs @@ -103,20 +103,19 @@ pub(super) fn paragraph_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) let field = ui.add_sized(vec2(110.0, 20.0), egui::Label::new("Line spacing")); let kind = d.get("lineKind", "multiple"); let value = d.get("lineValue", "1"); - let combo = - craft_ui::ComboBox::from_id_salt("paragraph_line").selected_text(line_preset_label(&kind, &value)).width(140.0).show_ui(ui, |ui| { - for (label, k, v) in [ - ("Single", "multiple", Some("1")), - ("1.5 lines", "multiple", Some("1.5")), - ("Double", "multiple", Some("2")), - ("Multiple", "multiple", None), - ("Exactly", "exactly", None), - ] { - if ui.selectable_label(line_preset_label(&kind, &value) == label, label).clicked() { - picked = Some((k, v)); - } + let combo = egui::ComboBox::from_id_salt("paragraph_line").selected_text(line_preset_label(&kind, &value)).width(140.0).show_ui(ui, |ui| { + for (label, k, v) in [ + ("Single", "multiple", Some("1")), + ("1.5 lines", "multiple", Some("1.5")), + ("Double", "multiple", Some("2")), + ("Multiple", "multiple", None), + ("Exactly", "exactly", None), + ] { + if ui.selectable_label(line_preset_label(&kind, &value) == label, label).clicked() { + picked = Some((k, v)); } - }); + } + }); let _ = combo.response.labelled_by(field.id); ui.add_space(8.0); let _ = labeled_text(ui, d, "At", "lineValue", 64.0); diff --git a/crates/ui-egui/src/dialogs/paragraph_dialog_tests.rs b/crates/ui-egui/src/dialogs/paragraph_dialog_tests.rs index 029773075..8d3a4fb7f 100644 --- a/crates/ui-egui/src/dialogs/paragraph_dialog_tests.rs +++ b/crates/ui-egui/src/dialogs/paragraph_dialog_tests.rs @@ -13,13 +13,17 @@ fn harness() -> Harness<'static, SlideApp> { s.execute("shape.insert", &json!({"preset": "rect", "rect": [80.0, 80.0, 320.0, 80.0], "text": "Hello"})).unwrap(); let _ = s.execute("text.exit", &json!({})); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1440.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(4); h } diff --git a/crates/ui-egui/src/dialogs/photo_album.rs b/crates/ui-egui/src/dialogs/photo_album.rs index 340e5832c..d6cb898a0 100644 --- a/crates/ui-egui/src/dialogs/photo_album.rs +++ b/crates/ui-egui/src/dialogs/photo_album.rs @@ -69,7 +69,7 @@ fn pick_album_picture(app: &mut SlideApp) -> Option { fn album_choice(ui: &mut Ui, d: &mut Dialog, id: &str, name: &str, key: &str, default: &str, choices: &[(&str, &str)]) { let cur = d.get(key, default); let label = choices.iter().find(|(k, _)| *k == cur).map(|(_, l)| *l).unwrap_or(default); - let opened = craft_ui::ComboBox::from_id_salt(id).selected_text(label).width(220.0).show_ui(ui, |ui| { + let opened = egui::ComboBox::from_id_salt(id).selected_text(label).width(220.0).show_ui(ui, |ui| { for (k, l) in choices { if ui.selectable_label(cur == *k, *l).clicked() { d.fields.insert(key.into(), (*k).to_string()); diff --git a/crates/ui-egui/src/dialogs/photo_album_tests.rs b/crates/ui-egui/src/dialogs/photo_album_tests.rs index b28a1c171..adeeaa7f8 100644 --- a/crates/ui-egui/src/dialogs/photo_album_tests.rs +++ b/crates/ui-egui/src/dialogs/photo_album_tests.rs @@ -18,13 +18,17 @@ fn png() -> Vec { } fn harness(app: SlideApp) -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1600.0, 1200.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/dialogs/preferences_tests.rs b/crates/ui-egui/src/dialogs/preferences_tests.rs index 549220b93..b53402ffc 100644 --- a/crates/ui-egui/src/dialogs/preferences_tests.rs +++ b/crates/ui-egui/src/dialogs/preferences_tests.rs @@ -18,7 +18,7 @@ fn interface_size<'a>(h: &'a Harness<'_, SlideApp>) -> Node<'a> { } fn harness() -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/dialogs/size_position_tests.rs b/crates/ui-egui/src/dialogs/size_position_tests.rs index 26baf7138..ae79253fc 100644 --- a/crates/ui-egui/src/dialogs/size_position_tests.rs +++ b/crates/ui-egui/src/dialogs/size_position_tests.rs @@ -7,7 +7,7 @@ use serde_json::json; use crate::{Services, SlideApp}; fn harness() -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/dialogs/spelling_tests.rs b/crates/ui-egui/src/dialogs/spelling_tests.rs index e67088fbb..144b42bf0 100644 --- a/crates/ui-egui/src/dialogs/spelling_tests.rs +++ b/crates/ui-egui/src/dialogs/spelling_tests.rs @@ -17,7 +17,7 @@ fn spelling_dialog_changes_and_ignores_words() { let mut app = SlideApp::new(Session::with_new(), Services::default()); app.session.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 500, 120], "text": "Our plna for teh quarter"})).unwrap(); app.dialog = Some(crate::dialogs::Dialog::new("spelling")); - let mut h = Harness::builder().with_size(egui::vec2(1100.0, 700.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 700.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -82,7 +82,7 @@ fn squiggles_mark_misspelt_words_in_the_background() { let st = app.session.active().unwrap().clone(); let lines = app.squiggles.settle(&st); assert_eq!(lines.len(), 3, "{lines:?}"); - let mut h = Harness::builder().with_size(egui::vec2(1100.0, 700.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 700.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -153,7 +153,7 @@ fn squiggles_in_table_cells_and_notes_and_on_the_ui_thread() { // Each under its own cell: the first in the top-left one, the second in the bottom-right one. assert!(lines[0].0.x < 380.0 && lines[0].0.y < 160.0 && lines[1].0.x > 380.0 && lines[1].0.y > 160.0, "{lines:?}"); assert_eq!(app.squiggles.settle_notes("Remmeber to show the totl", "xx-TB"), vec![(0, 8), (21, 25)]); - let mut h = Harness::builder().with_size(egui::vec2(1100.0, 760.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 760.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -226,7 +226,7 @@ fn notes_menu_language_dialog_and_repeated_words() { let st = app.session.active().unwrap().clone(); // "is is" is flagged as repeated, "wrok" as misspelt. assert_eq!(app.squiggles.settle(&st).len(), 2); - let mut h = Harness::builder().with_size(egui::vec2(1100.0, 760.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 760.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs index 452ff079c..20d0bb103 100644 --- a/crates/ui-egui/src/dialogs/tests.rs +++ b/crates/ui-egui/src/dialogs/tests.rs @@ -48,13 +48,14 @@ fn header_footer_apply_keeps_an_existing_date_format() { }) .collect() }; - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, crate::Services::default()), - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 900.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, crate::Services::default()), + ); harness.run_steps(2); assert_eq!(date_fields(harness.state()), vec!["datetime4".to_string()]); harness.state_mut().run("app.dialog", json!({"id": "headerFooter"})).unwrap(); @@ -89,13 +90,14 @@ fn export_dialog_writes_an_animated_gif() { }; let mut session = deckcraft_engine::Session::with_new(); session.execute("slide.new", &json!({})).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, services), - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 900.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, services), + ); harness.run_steps(2); harness.state_mut().run("app.exportDialog", json!({})).unwrap(); harness.run_steps(2); @@ -140,13 +142,14 @@ fn export_dialog_writes_a_png_with_a_transparent_background() { let path = dir.join("slide.png"); let picked = path.to_string_lossy().to_string(); let services = crate::Services { pick_save: Some(Box::new(move |_: &str| Some(picked.clone()))), ..Default::default() }; - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(deckcraft_engine::Session::with_new(), services), - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 900.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(deckcraft_engine::Session::with_new(), services), + ); harness.run_steps(2); harness.state_mut().run("app.exportDialog", json!({})).unwrap(); harness.run_steps(2); diff --git a/crates/ui-egui/src/dialogs/theme_colors_tests.rs b/crates/ui-egui/src/dialogs/theme_colors_tests.rs index d7dba9bba..98171b50f 100644 --- a/crates/ui-egui/src/dialogs/theme_colors_tests.rs +++ b/crates/ui-egui/src/dialogs/theme_colors_tests.rs @@ -10,7 +10,7 @@ use crate::{Services, SlideApp}; fn harness() -> Harness<'static, SlideApp> { let mut app = SlideApp::new(Session::with_new(), Services::default()); app.ui.tab = "Design".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/dialogs/theme_fonts.rs b/crates/ui-egui/src/dialogs/theme_fonts.rs index 0adcd3372..8975a77c6 100644 --- a/crates/ui-egui/src/dialogs/theme_fonts.rs +++ b/crates/ui-egui/src/dialogs/theme_fonts.rs @@ -30,7 +30,7 @@ fn theme_font_choices(app: &SlideApp, selected: &str) -> Vec { /// Draw an accessible font combo box and update the selected family; the caller supplies the /// visible label. fn font_combo(ui: &mut Ui, label: &str, choices: &[String], selected: &mut String) { - let resp = craft_ui::ComboBox::from_id_salt(label).selected_text(selected.as_str()).width(240.0).show_ui(ui, |ui| { + let resp = egui::ComboBox::from_id_salt(label).selected_text(selected.as_str()).width(240.0).show_ui(ui, |ui| { for face in choices { if ui.selectable_label(selected == face, face).clicked() { *selected = face.clone(); diff --git a/crates/ui-egui/src/dialogs/theme_fonts_tests.rs b/crates/ui-egui/src/dialogs/theme_fonts_tests.rs index adee8b998..e39cbdefd 100644 --- a/crates/ui-egui/src/dialogs/theme_fonts_tests.rs +++ b/crates/ui-egui/src/dialogs/theme_fonts_tests.rs @@ -9,7 +9,7 @@ use crate::{Services, SlideApp}; fn harness() -> Harness<'static, SlideApp> { let mut app = SlideApp::new(Session::with_new(), Services::default()); app.ui.tab = "Design".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/dialogs/updates_ui.rs b/crates/ui-egui/src/dialogs/updates_ui.rs index 41bebcc9c..63102f2ae 100644 --- a/crates/ui-egui/src/dialogs/updates_ui.rs +++ b/crates/ui-egui/src/dialogs/updates_ui.rs @@ -1,8 +1,11 @@ -//! One background check at start-up (and on demand from Help) for a newer release, and the modal -//! prompt that offers to update and restart. The flow itself is `craft_update::updater::Updater`. +//! One background check at start-up (and on demand from Help) for a newer release, the modal +//! prompt that offers to update and restart, and the result of a check, as craft-update's dialogs +//! on the app's [`DialogHost`](craft_ui::dialog::DialogHost). The flow itself is +//! `craft_update::updater::Updater`. +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::SlideApp; @@ -63,42 +66,62 @@ pub(crate) fn tick(app: &mut SlideApp, ctx: &egui::Context) { return; } if std::mem::take(&mut rt.check_requested) { - rt.updater.check_now(ctx); + rt.updater.check_now(); } else if rt.enabled { - rt.updater.check_at_start(ctx); + rt.updater.check_at_start(); } rt.updater.tick(ctx); } +/// One pass of the update flow, before the dialog host runs (`SlideApp::ui`): 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 SlideApp, ctx: &egui::Context) { if !app.updates_rt.stable_services { return; } // An installation starts, and a ready update asks the app to close, only while nothing is unsaved. let clean = !app.session.documents().iter().any(|d| d.is_dirty()); - match app.updates_rt.updater.show_if(ctx, clean) { + // Answered before the dialog is kept open below, so a dismissed result does not open again. + if let Some(result) = app.framework_dialogs.take::() { + answer(&mut app.updates_rt, ctx, result, clean); + } + match app.updates_rt.updater.run(&mut app.framework_dialogs, clean) { Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)), // The app's close path asks about unsaved work; `on_exit` starts the restart helper. Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close), - Action::None => {} + _ => {} } - // The result window reports a requested check, and at the first start after an update what + // The result dialog reports a requested check, and at the first start after an update what // that update came to (installed, or why it failed). - let rt = &mut app.updates_rt; - if !matches!(rt.updater.status(), Status::Idle) { - let response = CheckResultDialog::new(&crate::UPDATE_APP, VERSION).show(ctx, rt.updater.status()); - answer(rt, response); + let updater = &app.updates_rt.updater; + let reports = !matches!(updater.status(), Status::Idle); + let (status, installing, message) = (updater.status().clone(), updater.is_installing(), updater.status_message()); + let open = app.framework_dialogs.is_open::(); + if reports && !open { + app.framework_dialogs.open(UpdateCheckDialog::new(VERSION)); + } else if !reports && open { + app.framework_dialogs.cancel::(ctx); + } + if let Some(dialog) = app.framework_dialogs.get_mut::() { + dialog.set_status(status); + dialog.set_installing(installing); + dialog.set_message(message); } } -/// Acts on the result window's answer. -fn answer(rt: &mut Runtime, response: CheckResultResponse) { - match response { - CheckResultResponse::Close => rt.updater.dismiss_status(), - CheckResultResponse::CheckAgain => rt.check_requested = true, - // The next frame's `show_if` asks the window to close once nothing is unsaved. - CheckResultResponse::RestartToUpdate => rt.updater.restart_to_update(), - CheckResultResponse::None => {} +/// Acts on the result dialog's answer. +fn answer(rt: &mut Runtime, ctx: &egui::Context, result: DialogResult, clean: bool) { + match result { + DialogResult::Ok(CheckChoice::CheckNow | CheckChoice::CheckAgain) => rt.check_requested = true, + // The next pass's `run` asks the window to close once nothing is unsaved. + DialogResult::Ok(CheckChoice::RestartToUpdate) => rt.updater.restart_to_update(), + DialogResult::Ok(CheckChoice::Update) => { + rt.updater.request_install(clean); + } + DialogResult::Ok(CheckChoice::Download) => ctx.open_url(egui::OpenUrl::new_tab(crate::UPDATE_APP.releases_url())), + // OK, Esc and the close box dismiss the outcome it showed. + _ => rt.updater.dismiss_status(), } } @@ -110,9 +133,22 @@ mod tests { fn an_offered_release_opens_the_prompt() { let mut app = SlideApp::new(deckcraft_engine::Session::new(), crate::Services::default()); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); assert!(!app.updates_rt.updater.prompt_open()); app.updates_rt.updater.offer(craft_update::Release { tag: "v99.0.0".into(), ..Default::default() }); - ctx.run_ui(egui::RawInput::default(), |ui| show(&mut app, ui.ctx())).textures_delta.clear(); + // The offer reads on a thread whether this copy can install the release itself; a later + // pass's tick opens the prompt. + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + while !app.updates_rt.updater.prompt_open() && std::time::Instant::now() < deadline { + ctx.run_ui(egui::RawInput::default(), |ui| { + tick(&mut app, ui.ctx()); + show(&mut app, ui.ctx()); + app.framework_dialogs.run(ui); + }) + .textures_delta + .clear(); + std::thread::sleep(std::time::Duration::from_millis(2)); + } assert!(app.updates_rt.updater.prompt_open()); } @@ -169,14 +205,16 @@ mod tests { std::fs::write(root.join("data").join("self-update-done.txt"), VERSION).unwrap(); let mut app = app_with_records(&root); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); ctx.run_ui(egui::RawInput::default(), |ui| { tick(&mut app, ui.ctx()); show(&mut app, ui.ctx()); + app.framework_dialogs.run(ui); }) .textures_delta .clear(); assert!(matches!(app.updates_rt.updater.status(), Status::Updated(_)), "{:?}", app.updates_rt.updater.status()); - answer(&mut app.updates_rt, CheckResultResponse::Close); + answer(&mut app.updates_rt, &ctx, DialogResult::Ok(CheckChoice::Close), true); assert_eq!(app.updates_rt.updater.status(), &Status::Idle); let _ = std::fs::remove_dir_all(&root); } @@ -189,14 +227,16 @@ mod tests { std::fs::write(root.join("data").join("logs").join("self-update-error.txt"), "the disk is full").unwrap(); let mut app = app_with_records(&root); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); ctx.run_ui(egui::RawInput::default(), |ui| { tick(&mut app, ui.ctx()); show(&mut app, ui.ctx()); + app.framework_dialogs.run(ui); }) .textures_delta .clear(); assert_eq!(app.updates_rt.updater.status(), &Status::InstallFailed("the disk is full".into())); - answer(&mut app.updates_rt, CheckResultResponse::CheckAgain); + answer(&mut app.updates_rt, &ctx, DialogResult::Ok(CheckChoice::CheckAgain), true); assert!(app.updates_rt.check_requested); let _ = std::fs::remove_dir_all(&root); } diff --git a/crates/ui-egui/src/document_focus_tests.rs b/crates/ui-egui/src/document_focus_tests.rs new file mode 100644 index 000000000..6eabc22d9 --- /dev/null +++ b/crates/ui-egui/src/document_focus_tests.rs @@ -0,0 +1,232 @@ +//! The document window as the window's one canvas stop: Tab, real presses and its keys. + +use deckcraft_engine::Session; +use egui::{Event, Id, Key, Modifiers, PointerButton, Role, vec2}; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable as _; +use serde_json::json; + +use crate::framework::document_id; +use crate::state::ViewMode; +use crate::{Services, SlideApp}; + +fn harness() -> Harness<'static, SlideApp> { + let mut session = Session::with_new(); + session.prefs.autocorrect = false; + let mut app = SlideApp::new(session, Services::default()); + app.ui.notes = false; + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 800.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); + h.run_steps(4); + h +} + +fn focused(h: &Harness<'_, SlideApp>) -> Option { + h.ctx.memory(|m| m.focused()) +} + +fn press(h: &mut Harness<'_, SlideApp>, modifiers: Modifiers, key: Key) { + h.key_press_modifiers(modifiers, key); + h.run_steps(2); +} + +fn tab(h: &mut Harness<'_, SlideApp>) { + press(h, Modifiers::NONE, Key::Tab); +} + +fn selected(h: &Harness<'_, SlideApp>) -> Vec { + h.state().session.active().unwrap().selection.shapes.clone() +} + +#[test] +fn tab_selects_the_slides_objects_then_moves_on_and_shift_tab_walks_back() { + let mut h = harness(); + assert_eq!(focused(&h), Some(document_id()), "an opened presentation has the keyboard"); + let objects: Vec<_> = h.state().session.active().unwrap().shapes().iter().map(|s| s.id).collect(); + assert!(objects.len() > 1); + for object in &objects { + tab(&mut h); + assert_eq!((selected(&h), focused(&h)), (vec![*object], Some(document_id()))); + } + press(&mut h, Modifiers::SHIFT, Key::Tab); + let before = focused(&h); + assert!(before.is_some() && before != Some(document_id()), "with the last object selected, Shift+Tab leaves the slide"); + tab(&mut h); + assert_eq!(focused(&h), Some(document_id()), "Tab from the stop before it stops at the slide"); + tab(&mut h); + let after = focused(&h); + assert!(after.is_some() && after != Some(document_id()) && after != before, "past the last object, Tab moves on"); + press(&mut h, Modifiers::SHIFT, Key::Tab); + assert_eq!(focused(&h), Some(document_id()), "Shift+Tab walks back to the slide"); + assert_eq!(selected(&h), objects[objects.len() - 1..]); +} + +#[test] +fn a_press_on_the_slide_takes_the_keyboard_from_a_focused_button() { + let mut h = harness(); + h.get_by_role_and_label(Role::Button, "File").focus(); + h.run_steps(2); + assert!(h.get_by_role_and_label(Role::Button, "File").is_focused()); + let pos = h.state().canvas_rect.unwrap().right_bottom() - vec2(10.0, 10.0); + h.hover_at(pos); + h.run_steps(1); + for pressed in [true, false] { + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(1); + } + assert_eq!(focused(&h), Some(document_id())); + press(&mut h, Modifiers::NONE, Key::Enter); + assert!(!h.state().backstage_open(), "the File button isn't activated"); + assert_eq!(h.state().session.active().unwrap().doc.slides.len(), 2, "Enter adds a slide"); +} + +#[test] +fn after_a_press_on_a_pane_tab_selects_the_next_object() { + let mut h = harness(); + let pos = egui::pos2(h.state().ui.thumbs_width / 2.0, 300.0); + h.hover_at(pos); + h.run_steps(1); + for pressed in [true, false] { + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(2); + } + assert!(h.state().slides_focused, "the press is in the thumbnail pane"); + let first = h.state().session.active().unwrap().shapes()[0].id; + tab(&mut h); + assert_eq!((selected(&h), focused(&h)), (vec![first], Some(document_id()))); +} + +#[test] +fn after_a_dialog_closes_tab_selects_the_next_object() { + let mut h = harness(); + h.state_mut().dialog = Some(crate::dialogs::Dialog::new("find")); + h.run_steps(3); + assert!(h.ctx.text_edit_focused(), "the dialog's field has the focus"); + h.state_mut().dialog = None; + h.run_steps(4); + let first = h.state().session.active().unwrap().shapes()[0].id; + tab(&mut h); + assert_eq!((selected(&h), focused(&h)), (vec![first], Some(document_id()))); +} + +#[test] +fn after_enter_in_a_ribbon_field_tab_selects_the_next_object() { + let mut h = harness(); + h.state_mut().ui.tab = "Transitions".into(); + tab(&mut h); + let objects: Vec<_> = h.state().session.active().unwrap().shapes().iter().map(|s| s.id).collect(); + assert_eq!(selected(&h), objects[..1]); + h.get_by_role_and_label(Role::TextInput, "Duration value").focus(); + h.run_steps(2); + assert!(h.ctx.text_edit_focused()); + press(&mut h, Modifiers::NONE, Key::Enter); + assert!(!h.ctx.text_edit_focused(), "Enter commits the field"); + assert!(h.state().session.active().unwrap().selection.text.is_none(), "and reaches nothing on the slide"); + tab(&mut h); + assert_eq!((selected(&h), focused(&h)), (vec![objects[1]], Some(document_id()))); +} + +#[test] +fn a_press_in_the_sorter_takes_the_keyboard_from_a_focused_button() { + let mut h = harness(); + h.state_mut().ui.view = ViewMode::Sorter; + h.run_steps(3); + h.get_by_role_and_label(Role::Button, "File").focus(); + h.run_steps(2); + assert_ne!(focused(&h), Some(document_id())); + let pos = h.get_by_role_and_label(Role::Button, "Slide 1").rect().center(); + h.hover_at(pos); + h.run_steps(1); + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); + h.run_steps(2); + assert_eq!(focused(&h), Some(document_id())); +} + +#[test] +fn edited_text_traps_no_focus_in_the_sorter_or_the_file_tab() { + let mut h = harness(); + let title = h.state().session.active().unwrap().shapes()[0].id.0; + h.state_mut().session.execute("text.edit", &json!({"id": title})).unwrap(); + h.run_steps(2); + h.state_mut().ui.view = ViewMode::Sorter; + h.run_steps(2); + tab(&mut h); + let stop = focused(&h); + assert!(stop.is_some_and(|id| id != document_id()), "Tab moves on from the sorter"); + tab(&mut h); + assert!(focused(&h).is_some_and(|id| Some(id) != stop && id != document_id()), "and on again"); + h.state_mut().open_backstage(crate::backstage::Page::Home); + h.run_steps(3); + tab(&mut h); + h.run_steps(2); + assert!(h.state().session.active().unwrap().selection.text.is_some()); + assert!(focused(&h).is_some(), "Tab stays on a control of the File tab"); +} + +#[test] +fn a_presentation_opened_from_the_palette_gets_the_keyboard() { + let mut h = harness(); + h.state_mut().run("app.palette", json!({})).unwrap(); + h.run_steps(3); + assert!(h.ctx.text_edit_focused(), "the palette's field has the focus"); + let app = h.state_mut(); + app.palette = None; + app.run("file.new", json!({})).unwrap(); + app.run("slide.new", json!({"layout": "blank"})).unwrap(); + assert!(!app.session.tab_has_work(), "an empty slide, which asks for the focus only because it opened"); + h.run_steps(4); + assert_eq!(focused(&h), Some(document_id())); +} + +#[test] +fn the_focused_slide_takes_arrows_escape_typing_and_tab() { + let mut h = harness(); + let left = |h: &Harness<'_, SlideApp>| { + let st = h.state().session.active().unwrap(); + deckcraft_engine::cmd::xfrm_of(&st.doc, &st.selection, &st.shapes()[0]).x + }; + tab(&mut h); + let x = left(&h); + press(&mut h, Modifiers::NONE, Key::ArrowRight); + assert!(left(&h) > x, "the arrow moves the object, not the focus"); + press(&mut h, Modifiers::NONE, Key::Escape); + assert!(selected(&h).is_empty()); + assert_eq!(focused(&h), Some(document_id()), "Escape leaves the focus on the slide"); + tab(&mut h); + h.event(Event::Text("ab".into())); + h.run_steps(2); + tab(&mut h); + h.event(Event::Text("c".into())); + h.run_steps(2); + let st = h.state().session.active().unwrap(); + assert_eq!(st.shapes()[0].text.as_ref().unwrap().text(), "ab\tc"); + assert!(st.selection.text.is_some()); + press(&mut h, Modifiers::NONE, Key::Escape); + assert!(h.state().session.active().unwrap().selection.text.is_none(), "Escape ends text editing"); + assert_eq!(focused(&h), Some(document_id())); +} + +#[test] +fn every_view_draws_the_document_and_the_file_tab_takes_its_focus() { + let mut h = harness(); + for view in [ViewMode::Outline, ViewMode::Reading, ViewMode::NotesPage, ViewMode::Sorter] { + h.state_mut().ui.view = view; + h.run_steps(3); + assert_eq!(focused(&h), Some(document_id()), "the focus stays in the document window"); + } + tab(&mut h); + assert!(focused(&h).is_some_and(|id| id != document_id()), "Tab has no work in the slide sorter"); + h.state_mut().ui.view = ViewMode::Normal; + h.state_mut().open_backstage(crate::backstage::Page::Home); + h.run_steps(3); + assert!(h.state().backstage_open()); + h.key_press(Key::Escape); + h.run_steps(3); + assert!(!h.state().backstage_open(), "Escape leaves the File tab"); + assert_eq!(focused(&h), Some(document_id()), "and the slide has the keyboard again"); +} diff --git a/crates/ui-egui/src/eyedropper.rs b/crates/ui-egui/src/eyedropper.rs index 09a91a12a..6de3bc966 100644 --- a/crates/ui-egui/src/eyedropper.rs +++ b/crates/ui-egui/src/eyedropper.rs @@ -123,10 +123,11 @@ fn hex(c: [u8; 4]) -> String { } /// The slide canvas while the Eyedropper waits: the pointer is a crosshair with the colour under it -/// beside it, a click takes it. Returns true when it used the pointer (the tools get none). +/// beside it, a real click takes it (Enter and Space are egui's fake clicks of the focused canvas). Returns true when it +/// used the pointer (the tools get none). pub fn canvas(app: &mut SlideApp, ui: &Ui, resp: &egui::Response, xf: Xf) -> bool { let Some(state) = app.eyedropper.as_ref() else { return false }; - let escape = ui.input(|i| i.key_pressed(egui::Key::Escape)); + let escape = crate::framework::escape_pressed(ui.ctx()); if escape || resp.secondary_clicked() { app.eyedropper = None; return true; @@ -135,7 +136,7 @@ pub fn canvas(app: &mut SlideApp, ui: &Ui, resp: &egui::Response, xf: Xf) -> boo let on_slide = app.slide_rect.is_some_and(|r| r.contains(pos)); if !on_slide { ui.ctx().set_cursor_icon(CursorIcon::NotAllowed); - if resp.clicked() { + if resp.clicked_by(egui::PointerButton::Primary) { app.eyedropper = None; } return true; @@ -146,7 +147,7 @@ pub fn canvas(app: &mut SlideApp, ui: &Ui, resp: &egui::Response, xf: Xf) -> boo if let Some(c) = under { loupe(ui, pos, c); } - if resp.clicked() { + if resp.clicked_by(egui::PointerButton::Primary) { let (pick, slide) = (state.pick, state.slide); app.eyedropper = None; match pick { diff --git a/crates/ui-egui/src/eyedropper_tests.rs b/crates/ui-egui/src/eyedropper_tests.rs index 9c47e3954..44b5407bd 100644 --- a/crates/ui-egui/src/eyedropper_tests.rs +++ b/crates/ui-egui/src/eyedropper_tests.rs @@ -15,7 +15,7 @@ fn harness() -> Harness<'static, SlideApp> { session.execute("slide.new", &json!({"layout": "blank"})).unwrap(); session.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 200, 100]})).unwrap(); session.execute("shape.fill", &json!({"color": "#ff0000"})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -59,6 +59,19 @@ fn selection(h: &Harness<'static, SlideApp>) -> Vec { h.state().session.doc().unwrap().selection.shapes.iter().map(|s| s.0).collect() } +#[test] +fn space_on_the_focused_slide_picks_no_colour() { + let mut h = harness(); + ask(&mut h); + let on_shape = at(&h, 150.0, 150.0); + h.input_mut().events.push(Event::PointerMoved(on_shape)); + h.run_steps(3); + assert!(h.ctx.memory(|m| m.has_focus(crate::framework::document_id()))); + h.key_press(egui::Key::Space); + h.run_steps(3); + assert!(h.state().eyedropper.is_some() && !result_waits_for(&h.ctx, menu())); +} + #[test] fn a_click_on_the_slide_takes_the_colour_under_it_and_nothing_else_happens() { let mut h = harness(); @@ -125,7 +138,7 @@ fn set_transparent_color_takes_the_colour_clicked_in_the_picture() { session.execute("insert.picture", &json!({"data": data, "name": "a.png", "rect": [100, 100, 400, 200]})).unwrap(); let mut app = SlideApp::new(session, Services::default()); app.ui.tab = "Picture Format".into(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 1200.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/field_frame_tests.rs b/crates/ui-egui/src/field_frame_tests.rs index 14fdee3da..2aac9bc0f 100644 --- a/crates/ui-egui/src/field_frame_tests.rs +++ b/crates/ui-egui/src/field_frame_tests.rs @@ -13,13 +13,17 @@ use serde_json::json; use crate::{Services, SlideApp, theme}; fn harness(app: SlideApp) -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); // The app keeps asking for frames, so step instead of run(). h.run_steps(3); h diff --git a/crates/ui-egui/src/find_dialog_tests.rs b/crates/ui-egui/src/find_dialog_tests.rs index 25e71a28b..53f796438 100644 --- a/crates/ui-egui/src/find_dialog_tests.rs +++ b/crates/ui-egui/src/find_dialog_tests.rs @@ -14,13 +14,17 @@ fn ctrl_f_puts_the_caret_in_find_what() { s.execute("text.exit", &json!({})).unwrap(); s.doc_mut().unwrap().selection.shapes.clear(); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::F); h.run_steps(3); diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs new file mode 100644 index 000000000..6099d4a23 --- /dev/null +++ b/crates/ui-egui/src/framework.rs @@ -0,0 +1,182 @@ +//! The craft-ui runtime, hosted from DeckCraft's own eframe `App` (craft-libs docs/craft-framework.md, section 2.2). +//! The desktop app calls [`install`] once, [`SlideApp::before_input`] in `raw_input_hook`, [`SlideApp::close_path`] +//! last in `logic`, and [`before_ui`] first in `ui`; the browser build and tests install with [`install_headless`]. +//! `SlideApp::ui` runs the framework dialogs ([`SlideApp::framework_dialogs`]) after DeckCraft's own UI. +//! +//! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of DeckCraft's own egui +//! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] or [`take_window_cancel`]; the +//! document window is declared to the runtime with [`host_canvas`] each pass that draws it, which keeps the edit chords +//! and the clipboard events, and Tab while it has the focus and Tab has work, in egui's input for DeckCraft's own key +//! routing (`SlideApp::keyboard`). That routing has the keyboard unless [`widget_has_keyboard`]. + +use std::sync::Arc; + +use craft_host::target::ShellInfo; +use craft_host::{AppInfo, Host}; +use craft_keymap::{Chord, Key, Mods}; +use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; +use craft_ui::runtime::env::{RootEnv, Scale}; +use craft_ui::runtime::focus::{self, EditSet, FocusTarget, 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::system::WindowSystem; + +use crate::SlideApp; + +/// 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 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. DeckCraft's own definitions +/// (`theme::install_fonts_with`, in the first UI pass) 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) -> Result<(), String> { + let spec = craft_ui::InstallSpec::new(shell, windows).app_id(crate::os_window::app_id()); + embed::install(ctx, spec, &ui_fonts()).map(drop).map_err(|error| format!("the UI runtime could not be installed: {error}")) +} + +/// Installs the runtime on the desktop window's context, once, before the first pass. `forced_x11` when the app +/// opens its window through XWayland. DeckCraft draws its own title bar row (`ribbon::title_bar`) and gives the +/// runtime no frame decision, so the runtime takes no part of the window's move area or hit test. +#[cfg(not(target_arch = "wasm32"))] +pub fn install(ctx: &egui::Context, forced_x11: bool) -> Result<(), String> { + use craft_host::target::Backend; + let backend = if forced_x11 { Backend::X11 } else { Backend::from_env() }; + install_with(ctx, ShellInfo::default().backend(backend), Arc::new(craft_window::system::SystemWindows)) +} + +/// 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)) { + log::warn!("{error}"); + } +} + +/// Who DeckCraft is to the framework's dialogs (the update dialogs show its name and icon). +pub(crate) fn host() -> Arc { + Arc::new( + Host::builder(AppInfo { id: "deckcraft", name: "DeckCraft", version: env!("CARGO_PKG_VERSION") }) + .icon_png(include_bytes!("../../../assets/app-icon/hicolor/128x128/apps/ai.storyteller.deckcraft.png")) + .build(), + ) +} + +impl SlideApp { + /// 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). + pub fn before_input(&mut self, ctx: &egui::Context) { + embed::before_input(ctx, |output| self.frame_input(output)); + } + + /// The root values of this frame. DeckCraft registers no commands with the runtime and lets it toggle no chrome, + /// so the output carries nothing it acts on. The interface scale is DeckCraft's own (`UiState::ui_scale`, which + /// `ui_setup` applies), so the runtime's zoom and DeckCraft's agree. + fn frame_input(&mut self, _output: FrameOutput) -> FrameInput { + let mode = if self.ui.brightness == crate::theme::Brightness::Dark { craft_theme::Mode::Dark } else { craft_theme::Mode::Light }; + // The slide show and the canvas read Ctrl/Cmd+wheel themselves, so a smooth Ctrl+wheel stays a wheel event. + let root = RootEnv::new().mode(mode).scale(Scale::new(self.ui.ui_scale.clamp(0.5, 3.0))).ctrl_wheel_pinch(false); + FrameInput::new(root).host(Arc::clone(&self.framework_host)) + } + + /// The framework's part of `App::logic`, after DeckCraft's own: the root window's close path. With unsaved + /// presentations the window stays open while the quit dialog asks; its answer closes the window again with + /// `quit_confirmed` set. + pub fn close_path(&mut self, ctx: &egui::Context) { + embed::logic(ctx, || { + if self.quit_confirmed || !self.session.documents().iter().any(|d| d.is_dirty()) { + return CloseDecision::Close; + } + self.show = None; + if self.dialog.as_ref().is_none_or(|d| d.id != "quit") { + self.dialog = Some(crate::dialogs::Dialog::new("quit")); + } + CloseDecision::Hold + }); + } +} + +/// Alt+1 to Alt+9, the Quick Access Toolbar's positions on Windows and Linux (`menus::ui_shortcut`). Claimed, so +/// the runtime's Alt+numpad code entry leaves them to DeckCraft's shortcuts. +const QUICK_ACCESS_KEYS: [Chord; 9] = [ + Chord::new(Mods::ALT, Key::Num1), + Chord::new(Mods::ALT, Key::Num2), + Chord::new(Mods::ALT, Key::Num3), + Chord::new(Mods::ALT, Key::Num4), + Chord::new(Mods::ALT, Key::Num5), + Chord::new(Mods::ALT, Key::Num6), + Chord::new(Mods::ALT, Key::Num7), + Chord::new(Mods::ALT, Key::Num8), + Chord::new(Mods::ALT, Key::Num9), +]; + +/// The keys DeckCraft's document window keeps while it has the focus or is the window's key target: every clipboard +/// event and edit chord, and the Quick Access Toolbar's Alt+digits, which `SlideApp::keyboard` routes itself. +const DOCUMENT_KEYS: KeyUse = KeyUse::CANVAS.with_edits(EditSet::ALL).with_claims(&QUICK_ACCESS_KEYS); + +/// The document window's widget: the slide canvas, the slide sorter or the notes page, whichever the view draws. +pub(crate) fn document_id() -> egui::Id { + egui::Id::unique("deckcraft_document") +} + +/// Declares DeckCraft's document window, drawn in this pass, as the window's canvas. With nothing focused it is the +/// window's key target: the edit chords, the clipboard events and the claimed Alt+digits stay in egui's input for +/// DeckCraft. Tab and Shift+Tab stop at it; with `keeps_tab` the focused document keeps them in egui's input, else they +/// move on from it. +pub(crate) fn host_canvas(ctx: &egui::Context, keeps_tab: bool) { + let keys = if keeps_tab { DOCUMENT_KEYS.with_keep(KeepKeys::Tab) } else { DOCUMENT_KEYS }; + focus::host_canvas(ctx, document_id(), keys); +} + +/// Gives the document window the keyboard focus. It is the runtime's focus, which an Escape does not take away. +pub(crate) fn focus_document(ctx: &egui::Context) { + focus::request(ctx, FocusTarget::Id(document_id())); +} + +/// The widget that has the keyboard, the document window left out: a focused document leaves the keyboard to +/// DeckCraft's own key routing, as with nothing focused. +pub(crate) fn focused_widget(ctx: &egui::Context) -> Option { + ctx.memory(|m| m.focused()).filter(|id| *id != document_id()) +} + +/// Whether a widget other than the document window has the keyboard. +pub(crate) fn widget_has_keyboard(ctx: &egui::Context) -> bool { + focused_widget(ctx).is_some() +} + +/// Whether Escape was pressed in this pass: from egui while one of DeckCraft'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_escape(ctx) +} + +/// Whether the window's cancel (an Escape while nothing has framework focus, which the runtime takes out of egui's +/// events) is there and untaken. Key loops that read egui's events add it as an Escape press. +pub(crate) fn window_escape(ctx: &egui::Context) -> bool { + window_cancel(ctx, false) +} + +/// The Escape press [`window_escape`] stands for, for key loops over egui's events. +pub(crate) const ESCAPE_PRESS: egui::Event = + egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }; + +/// Takes the window's cancel (an Escape while nothing has framework focus): whether there was one. +pub(crate) fn take_window_cancel(ctx: &egui::Context) -> bool { + window_cancel(ctx, true) +} + +fn window_cancel(ctx: &egui::Context, take: bool) -> bool { + let mut pending = false; + with_window_intents(ctx, false, |intents| { + pending = intents.untaken(&Intent::Cancel); + take && pending && intents.take(Intent::Cancel) + }); + pending +} diff --git a/crates/ui-egui/src/huge_deck_tests.rs b/crates/ui-egui/src/huge_deck_tests.rs index 7e2ebb16e..5a546dea7 100644 --- a/crates/ui-egui/src/huge_deck_tests.rs +++ b/crates/ui-egui/src/huge_deck_tests.rs @@ -13,7 +13,7 @@ fn harness(n: usize) -> egui_kittest::Harness<'static, SlideApp> { for _ in 1..n { s.execute("slide.new", &json!({})).unwrap(); } - egui_kittest::Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ime_tests.rs b/crates/ui-egui/src/ime_tests.rs index 2c13e8864..731c16ac6 100644 --- a/crates/ui-egui/src/ime_tests.rs +++ b/crates/ui-egui/src/ime_tests.rs @@ -11,13 +11,14 @@ use deckcraft_engine::Session; /// Build the standard 1280×800 UI harness around a supplied session and run three frames. fn harness(session: Session) -> egui_kittest::Harness<'static, SlideApp> { - let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, Services::default()), - ); + let mut h = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1280.0, 800.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, Services::default()), + ); crate::install_ime_pass_hooks(&h.ctx); // The app keeps requesting repaints, so step frames instead of run(). h.run_steps(3); @@ -191,19 +192,20 @@ fn a_discarded_pass_keeps_the_tombstone_until_a_settled_pass_publishes_the_inter use std::sync::{Arc, Mutex}; let traces = Arc::new(Mutex::new(Vec::new())); let seen = traces.clone(); - let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state( - move |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - seen.lock().unwrap().push(( - app.ime_cancelled.is_some(), - app.ime_interrupt_pending, - app.ime_composition.is_none(), - ui.ctx().will_discard(), - )); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + let mut h = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1280.0, 800.0)).build_ui_state( + move |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + seen.lock().unwrap().push(( + app.ime_cancelled.is_some(), + app.ime_interrupt_pending, + app.ime_composition.is_none(), + ui.ctx().will_discard(), + )); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); h.run_steps(3); let title = h.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; h.state_mut().run("text.edit", json!({"id": title})).unwrap(); diff --git a/crates/ui-egui/src/last_color_tests.rs b/crates/ui-egui/src/last_color_tests.rs index b43d3a857..ca0ff8eb1 100644 --- a/crates/ui-egui/src/last_color_tests.rs +++ b/crates/ui-egui/src/last_color_tests.rs @@ -26,7 +26,7 @@ fn harness(tab: &str) -> (Harness<'static, SlideApp>, [ShapeId; 2]) { s.execute("selection.select", &json!({"ids": [ids[0].0]})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = tab.into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 3654fa153..f866144f4 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -23,6 +23,7 @@ pub mod dialogs; pub mod doc_window; pub mod eyedropper; pub mod flavor; +pub mod framework; pub mod icons; pub mod media; pub mod menus; @@ -267,8 +268,11 @@ pub struct SlideApp { synthetic_generation: u64, /// Document/slide/canvas identity the queued/injected batch belongs to. synthetic_target: Option, - /// Focus identity the pending batch was injected with; a focus change retracts it. + /// Focus identity the pending batch was injected with (the document window counts as none); a focus change + /// retracts it. synthetic_focus: Option, + /// The document window as a Tab stop, and when it takes the keyboard focus. + document_focus: app::DocumentFocus, /// `RawInput::time` of the pass the batch was injected into. A logic-only callback leaves /// `InputState` from the previous pass; comparing this value keeps retraction from draining /// an unrelated batch out of that stale input. @@ -300,6 +304,11 @@ pub struct SlideApp { print_previews: app::files::PrintPreviews, #[cfg(not(target_arch = "wasm32"))] updates_rt: updates_ui::Runtime, + /// The framework dialogs (the update prompt and check result), run once per pass after the + /// app's own UI. + pub framework_dialogs: craft_ui::dialog::DialogHost, + /// Who DeckCraft is to the framework's dialogs. + framework_host: std::sync::Arc, /// Text for the system clipboard from a Copy or Cut command, handed over on the next frame. pending_copy: Option, /// Bounded screenshot completion slots for the control channel (egui 0.37 callbacks). @@ -454,6 +463,8 @@ mod browsetheme_tests; #[cfg(test)] mod compare_tests; #[cfg(test)] +mod document_focus_tests; +#[cfg(test)] mod eyedropper_tests; #[cfg(test)] mod field_frame_tests; diff --git a/crates/ui-egui/src/media_bar_tests.rs b/crates/ui-egui/src/media_bar_tests.rs index 975e126f8..d18e0c90b 100644 --- a/crates/ui-egui/src/media_bar_tests.rs +++ b/crates/ui-egui/src/media_bar_tests.rs @@ -42,13 +42,17 @@ fn play_on_the_editor_media_bar_plays_the_selected_clip() { let r = s.execute("insert.audio", &json!({"name": "tone.wav", "data": deckcraft_engine::cmd::base64_encode(&wav(2.0))})).unwrap(); let id = ShapeId(r["id"].as_u64().unwrap() as u32); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); let d = h.state().session.active().unwrap(); assert_eq!(d.selection.shapes, vec![id], "the inserted clip is selected"); @@ -88,13 +92,17 @@ fn the_media_bar_never_paints_or_clicks_into_the_notes_pane() { let mut app = SlideApp::new(s, Services::default()); app.ui.notes = true; app.ui.notes_height = 140.0; - let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); let notes = h.query_all_by_role(Role::MultilineTextInput).next().map(|n| n.rect()).expect("the notes field"); let canvas = h.state().canvas_rect.unwrap(); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index b1b44200e..6dedc7c30 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -128,14 +128,9 @@ pub fn palette(app: &mut SlideApp, ctx: &egui::Context) { r.request_focus(); let q = query.to_lowercase(); let items = palette_items(&app.session, &q); - let (down, up, enter, esc) = ui.input(|i| { - ( - i.key_pressed(egui::Key::ArrowDown), - i.key_pressed(egui::Key::ArrowUp), - i.key_pressed(egui::Key::Enter), - i.key_pressed(egui::Key::Escape), - ) - }); + let (down, up, enter) = + ui.input(|i| (i.key_pressed(egui::Key::ArrowDown), i.key_pressed(egui::Key::ArrowUp), i.key_pressed(egui::Key::Enter))); + let esc = crate::framework::escape_pressed(ui.ctx()); if down { sel = (sel + 1).min(items.len().saturating_sub(1)); } diff --git a/crates/ui-egui/src/opening.rs b/crates/ui-egui/src/opening.rs index 1be088177..e40b8e0fe 100644 --- a/crates/ui-egui/src/opening.rs +++ b/crates/ui-egui/src/opening.rs @@ -116,7 +116,7 @@ impl SlideApp { cancel = ui.button("Cancel").clicked(); }); }); - if cancel || ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) { + if cancel || ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) || crate::framework::take_window_cancel(ctx) { self.cancel_opening(); } ctx.request_repaint_after(std::time::Duration::from_millis(100)); @@ -200,13 +200,16 @@ mod tests { // A read that never answers: the window stays until Cancel. let (_tx, rx) = std::sync::mpsc::channel(); app.opening = Some(Opening { path: "/decks/Big deck.pptx".into(), started_ms: crate::now_ms(), generation: 1, rx }); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1000.0, 700.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1000.0, 700.0)) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.get_by_label("Opening Big deck.pptx…"); harness.get_by_label("Cancel").click(); @@ -284,13 +287,16 @@ mod tests { for leave in [egui::Key::Escape, egui::Key::ArrowRight] { let mut app = SlideApp::new(Session::new(), crate::Services::default()); assert!(app.open_from_system(std::slice::from_ref(&path)).is_empty()); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1000.0, 700.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1000.0, 700.0)) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); assert!(harness.state().show.is_some(), "the show is running"); if leave == egui::Key::ArrowRight { diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 202f45b3c..dee8d6bfd 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -193,7 +193,7 @@ mod tests { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "fill".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -234,7 +234,7 @@ mod tests { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "fill".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -345,13 +345,14 @@ mod tests { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "fill".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = + Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h }; @@ -399,7 +400,7 @@ mod tests { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "fill".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/panels/background.rs b/crates/ui-egui/src/panels/background.rs index 906408a97..35cadf25d 100644 --- a/crates/ui-egui/src/panels/background.rs +++ b/crates/ui-egui/src/panels/background.rs @@ -156,7 +156,7 @@ fn picture_background_options(app: &mut SlideApp, ui: &mut Ui, pf: &deckcraft_mo }; ui.horizontal(|ui| { let field = ui.add_sized(vec2(72.0, 20.0), egui::Label::new("Alignment")); - let combo = craft_ui::ComboBox::from_id_salt("bg-align").selected_text(align_name).width(140.0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("bg-align").selected_text(align_name).width(140.0).show_ui(ui, |ui| { for (k, l) in [ ("tl", "Top Left"), ("t", "Top"), @@ -183,7 +183,7 @@ fn picture_background_options(app: &mut SlideApp, ui: &mut Ui, pf: &deckcraft_mo }; ui.horizontal(|ui| { let field = ui.add_sized(vec2(72.0, 20.0), egui::Label::new("Mirror")); - let combo = craft_ui::ComboBox::from_id_salt("bg-mirror").selected_text(mirror_name).width(140.0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("bg-mirror").selected_text(mirror_name).width(140.0).show_ui(ui, |ui| { for (k, l) in [("none", "None"), ("x", "Horizontal"), ("y", "Vertical"), ("xy", "Both")] { if ui.selectable_label(flip == k, l).clicked() { run(app, "design.background", json!({"pictureProps": {"mirror": k}})); diff --git a/crates/ui-egui/src/panels/background_tests.rs b/crates/ui-egui/src/panels/background_tests.rs index 673130ab3..92a4a9cf5 100644 --- a/crates/ui-egui/src/panels/background_tests.rs +++ b/crates/ui-egui/src/panels/background_tests.rs @@ -15,7 +15,7 @@ const PNG: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z fn harness(mut app: SlideApp) -> Harness<'static, SlideApp> { app.ui.tab = "Design".into(); app.ui.pane = Some("background".into()); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/panels/effect_presets_tests.rs b/crates/ui-egui/src/panels/effect_presets_tests.rs index d23651f22..5aa44d95b 100644 --- a/crates/ui-egui/src/panels/effect_presets_tests.rs +++ b/crates/ui-egui/src/panels/effect_presets_tests.rs @@ -17,7 +17,7 @@ fn harness() -> Harness<'static, SlideApp> { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "effects".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/panels/fillui.rs b/crates/ui-egui/src/panels/fillui.rs index a8a29680d..a83281a29 100644 --- a/crates/ui-egui/src/panels/fillui.rs +++ b/crates/ui-egui/src/panels/fillui.rs @@ -174,7 +174,7 @@ pub fn gradient_editor(ui: &mut Ui, id: &str, g: &Gradient, sc: &ColorScheme) -> }; ui.horizontal(|ui| { let field = ui.add_sized(vec2(70.0, 20.0), egui::Label::new("Type")); - let combo = craft_ui::ComboBox::from_id_salt((id, "kind")).selected_text(kind).width(120.0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt((id, "kind")).selected_text(kind).width(120.0).show_ui(ui, |ui| { for k in ["Linear", "Radial", "Rectangular", "Path"] { if ui.selectable_label(kind == k, k).clicked() && kind != k { let focus = match &g.shape { diff --git a/crates/ui-egui/src/panels/format_shape.rs b/crates/ui-egui/src/panels/format_shape.rs index deaac9c20..d2dfbc992 100644 --- a/crates/ui-egui/src/panels/format_shape.rs +++ b/crates/ui-egui/src/panels/format_shape.rs @@ -218,7 +218,7 @@ fn size_tab(app: &mut SlideApp, ui: &mut Ui, sh: &deckcraft_model::Shape, x: dec ui.horizontal(|ui| { ui.add_sized(vec2(90.0, 20.0), egui::Label::new("From")); let combo = - craft_ui::ComboBox::from_id_salt("fmt-origin").selected_text(if center { "Center" } else { "Top Left Corner" }).show_ui(ui, |ui| { + egui::ComboBox::from_id_salt("fmt-origin").selected_text(if center { "Center" } else { "Top Left Corner" }).show_ui(ui, |ui| { ui.selectable_value(&mut center, false, "Top Left Corner"); ui.selectable_value(&mut center, true, "Center"); }); @@ -493,7 +493,7 @@ fn line_choice(app: &mut SlideApp, ui: &mut Ui, label: &str, key: &str, current: ui.horizontal(|ui| { let field = ui.add_sized(vec2(90.0, 20.0), egui::Label::new(label)); let shown = items.iter().find(|(_, v)| *v == current).map_or(current, |(l, _)| *l); - let combo = craft_ui::ComboBox::from_id_salt(("fmt-line", key)).selected_text(shown).width(120.0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt(("fmt-line", key)).selected_text(shown).width(120.0).show_ui(ui, |ui| { for (l, v) in items { if ui.selectable_label(*v == current, *l).clicked() { run(app, "shape.line", json!({key: v})); @@ -653,7 +653,7 @@ fn picture_fill_options(app: &mut SlideApp, ui: &mut Ui, id: u32, pf: &deckcraft ui.horizontal(|ui| { let field = ui.add_sized(vec2(90.0, 20.0), egui::Label::new(label)); let shown = opts.iter().find(|(k, _)| k == cur).map_or(opts[0].1, |(_, l)| *l); - let combo = craft_ui::ComboBox::from_id_salt(("picfill", id, key)).selected_text(shown).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt(("picfill", id, key)).selected_text(shown).show_ui(ui, |ui| { for (k, l) in opts { if ui.selectable_label(*k == cur.as_str(), *l).clicked() { run(app, "shape.fill", json!({"pictureProps": {key: k}})); @@ -705,7 +705,7 @@ fn preset_label(name: &str) -> String { fn three_d_combo(app: &mut SlideApp, ui: &mut Ui, id: u32, label: &str, key: &str, cur: &str, options: &[&str]) { ui.horizontal(|ui| { let field = ui.add_sized(vec2(90.0, 20.0), egui::Label::new(label)); - let combo = craft_ui::ComboBox::from_id_salt(("3d", id, key)).selected_text(preset_label(cur)).width(170.0).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt(("3d", id, key)).selected_text(preset_label(cur)).width(170.0).show_ui(ui, |ui| { for o in options { if ui.selectable_label(*o == cur, preset_label(o)).clicked() { run(app, "shape.effects", json!({"threeD": {key: o}})); diff --git a/crates/ui-egui/src/panels/pattern_fill_tests.rs b/crates/ui-egui/src/panels/pattern_fill_tests.rs index f7f5a784d..de6839fe5 100644 --- a/crates/ui-egui/src/panels/pattern_fill_tests.rs +++ b/crates/ui-egui/src/panels/pattern_fill_tests.rs @@ -15,7 +15,7 @@ use crate::{Services, SlideApp}; fn harness(mut app: SlideApp, pane: &str) -> Harness<'static, SlideApp> { app.ui.pane = Some(pane.into()); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/panels/selpane.rs b/crates/ui-egui/src/panels/selpane.rs index b9325548d..c4aa5a85d 100644 --- a/crates/ui-egui/src/panels/selpane.rs +++ b/crates/ui-egui/src/panels/selpane.rs @@ -216,7 +216,7 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) { } app.selpane.rename_started = true; } - let (enter, esc) = ui.input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape))); + let (enter, esc) = (ui.input(|i| i.key_pressed(egui::Key::Enter)), crate::framework::escape_pressed(ui.ctx())); if out.lost_focus() || enter || esc { app.selpane.renaming = None; app.selpane.rename_started = false; @@ -342,16 +342,16 @@ fn click(app: &mut SlideApp, rows: &[Row], k: usize, ctrl: bool, shift: bool) { } fn keys(app: &mut SlideApp, ui: &Ui, rows: &[Row], selected: &[u32], focused: u32) { - let (up, down, home, end, f2, esc) = ui.input(|i| { + let (up, down, home, end, f2) = ui.input(|i| { ( i.key_pressed(egui::Key::ArrowUp), i.key_pressed(egui::Key::ArrowDown), i.key_pressed(egui::Key::Home), i.key_pressed(egui::Key::End), i.key_pressed(egui::Key::F2), - i.key_pressed(egui::Key::Escape), ) }); + let esc = crate::framework::escape_pressed(ui.ctx()); let cur = selected.last().and_then(|id| rows.iter().position(|r| r.id == *id)); let to = if up { Some(cur.map(|c| c.saturating_sub(1)).unwrap_or(0)) diff --git a/crates/ui-egui/src/panels/selpane/ui_tests.rs b/crates/ui-egui/src/panels/selpane/ui_tests.rs index 2c2181dc4..d37b310db 100644 --- a/crates/ui-egui/src/panels/selpane/ui_tests.rs +++ b/crates/ui-egui/src/panels/selpane/ui_tests.rs @@ -26,13 +26,17 @@ fn harness() -> (Harness<'static, SlideApp>, Vec) { ids.push(g); let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("selection".into()); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); (h, ids) } diff --git a/crates/ui-egui/src/panels/smartart.rs b/crates/ui-egui/src/panels/smartart.rs index a50f95070..6f098a57f 100644 --- a/crates/ui-egui/src/panels/smartart.rs +++ b/crates/ui-egui/src/panels/smartart.rs @@ -8,7 +8,7 @@ pub(super) fn smartart(app: &mut SlideApp, ui: &mut Ui) { return; }; let texts: Vec = d.nodes.iter().map(|n| n.text.clone()).collect(); - let focused_any = ui.ctx().memory(|m| m.focused().is_some()) || app.ui.smartart_focus.is_some(); + let focused_any = crate::framework::widget_has_keyboard(ui.ctx()) || app.ui.smartart_focus.is_some(); if app.ui.smartart_drafts.0 != gid.0 || app.ui.smartart_drafts.1.len() != texts.len() || !focused_any { app.ui.smartart_drafts = (gid.0, texts.clone()); } @@ -24,7 +24,8 @@ pub(super) fn smartart(app: &mut SlideApp, ui: &mut Ui) { ui.horizontal(|ui| { ui.add_space(16.0 * node.level as f32); ui.label("•"); - let te = egui::TextEdit::singleline(draft).id(id).hint_text("Diagram text").desired_width(f32::INFINITY); + // The line keeps Tab for its own command; Escape leaves it. + let te = egui::TextEdit::singleline(draft).id(id).hint_text("Diagram text").desired_width(f32::INFINITY).lock_focus(true); let r = ui.add(te); if app.ui.smartart_focus == Some(i) { r.request_focus(); @@ -39,13 +40,15 @@ pub(super) fn smartart(app: &mut SlideApp, ui: &mut Ui) { action = Some(("smartArt.removeNode", json!({"index": i}))); focus_row = Some(i.saturating_sub(1)); } - } - if r.lost_focus() { let (tab, shift) = ui.input(|inp| (inp.key_pressed(egui::Key::Tab), inp.modifiers.shift)); if tab { action = Some((if shift { "smartArt.promote" } else { "smartArt.demote" }, json!({"index": i}))); focus_row = Some(i); - } else if ui.input(|inp| inp.key_pressed(egui::Key::Enter)) { + commit = Some(i); + } + } + if r.lost_focus() { + if ui.input(|inp| inp.key_pressed(egui::Key::Enter)) { action = Some(("smartArt.addNode", json!({"index": i, "position": "after"}))); focus_row = Some(i + 1); } diff --git a/crates/ui-egui/src/panels/smartart_tests.rs b/crates/ui-egui/src/panels/smartart_tests.rs index dfba4e6c8..b15b833e8 100644 --- a/crates/ui-egui/src/panels/smartart_tests.rs +++ b/crates/ui-egui/src/panels/smartart_tests.rs @@ -25,13 +25,17 @@ fn text_pane_types_adds_and_demotes() { s.execute("insert.smartArt", &json!({"kind": "list", "items": ["Plan", "Build"]})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("smartart".into()); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); assert!(h.query_by_label("Text Pane").is_some()); @@ -58,13 +62,17 @@ fn home_convert_to_smartart_gallery_converts_the_text() { s.execute("slide.new", &json!({"layout": "blank"})).unwrap(); s.execute("insert.textBox", &json!({"text": "Goals\nRevenue\nGrowth"})).unwrap(); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1600.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.get_by_label("Convert to Diagram").click(); h.run_steps(3); @@ -84,13 +92,17 @@ fn layout_gallery_shows_cached_pictures_and_previews_on_hover() { s.execute("insert.smartArt", &json!({"kind": "process", "items": ["Plan", "Build", "Ship"]})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = "SmartArt Design".into(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1600.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.get_by_label("Layouts").click(); h.run_steps(3); diff --git a/crates/ui-egui/src/panels/thesaurus_tests.rs b/crates/ui-egui/src/panels/thesaurus_tests.rs index e52e4503e..2028cb671 100644 --- a/crates/ui-egui/src/panels/thesaurus_tests.rs +++ b/crates/ui-egui/src/panels/thesaurus_tests.rs @@ -18,13 +18,17 @@ fn thesaurus_pane_swaps_the_word_at_the_caret() { s.execute("text.edit", &json!({"id": id, "at": [0, 6]})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = "Review".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.get_by_label("Thesaurus").click(); h.run_steps(3); diff --git a/crates/ui-egui/src/panels/thumbs.rs b/crates/ui-egui/src/panels/thumbs.rs index 4956f2b0b..6d7e0d2e2 100644 --- a/crates/ui-egui/src/panels/thumbs.rs +++ b/crates/ui-egui/src/panels/thumbs.rs @@ -437,7 +437,7 @@ mod tests { use deckcraft_engine::Session; fn harness() -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -506,13 +506,17 @@ mod tests { while s.doc().unwrap().doc.slides.len() < slides { s.execute("slide.new", &json!({})).unwrap(); } - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 1600.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(s, Services::default()), - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1200.0, 1600.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(s, Services::default()), + ); h.run_steps(3); let ids = order(&h); (h, ids) diff --git a/crates/ui-egui/src/reflection_pane_tests.rs b/crates/ui-egui/src/reflection_pane_tests.rs index a0ef4b986..41f1f1868 100644 --- a/crates/ui-egui/src/reflection_pane_tests.rs +++ b/crates/ui-egui/src/reflection_pane_tests.rs @@ -23,7 +23,7 @@ fn reflection_none_clears_after_a_second_preset() { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "effects".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -51,7 +51,7 @@ fn reflection_none_stays_cleared_when_a_slider_only_had_focus() { let mut app = SlideApp::new(s, Services::default()); app.ui.pane = Some("format".into()); app.ui.format_tab = "effects".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/replacefonts_tests.rs b/crates/ui-egui/src/replacefonts_tests.rs index 449b4b46f..39692f85c 100644 --- a/crates/ui-egui/src/replacefonts_tests.rs +++ b/crates/ui-egui/src/replacefonts_tests.rs @@ -19,13 +19,17 @@ fn harness() -> Harness<'static, SlideApp> { // The product's default window. The Home ribbon overflows here with the bundled interface // fonts; the ribbon's own edge chevron must make its Editing group reachable instead of the // regression widening the fixture past the width the app actually opens at. - let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1440.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/reuse_picker_tests.rs b/crates/ui-egui/src/reuse_picker_tests.rs index 4f640afcd..5b8099a3d 100644 --- a/crates/ui-egui/src/reuse_picker_tests.rs +++ b/crates/ui-egui/src/reuse_picker_tests.rs @@ -32,13 +32,17 @@ fn harness(file: &Rc>>) -> Harness<'static, SlideApp> { ..Services::default() }; let app = SlideApp::new(s, services); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/ribbon/add_animation_menu_tests.rs b/crates/ui-egui/src/ribbon/add_animation_menu_tests.rs index f760b5985..b98e21d37 100644 --- a/crates/ui-egui/src/ribbon/add_animation_menu_tests.rs +++ b/crates/ui-egui/src/ribbon/add_animation_menu_tests.rs @@ -13,7 +13,7 @@ fn harness(size: egui::Vec2) -> Harness<'static, SlideApp> { session.execute("edit.select", &json!({"ids": [id]})).unwrap(); let mut app = SlideApp::new(session, Services::default()); app.ui.tab = "Animations".into(); - let mut h = Harness::builder().with_size(size).with_step_dt(1.0 / 60.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).with_step_dt(1.0 / 60.0).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ribbon/align_tests.rs b/crates/ui-egui/src/ribbon/align_tests.rs index 969ef2fe5..291b60c44 100644 --- a/crates/ui-egui/src/ribbon/align_tests.rs +++ b/crates/ui-egui/src/ribbon/align_tests.rs @@ -26,7 +26,7 @@ fn harness(select: &[usize]) -> (Harness<'static, SlideApp>, Vec) { s.execute("selection.select", &json!({"ids": picked})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = "Shape Format".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ribbon/drawtable_tests.rs b/crates/ui-egui/src/ribbon/drawtable_tests.rs index dac1be11e..8c9b9d26d 100644 --- a/crates/ui-egui/src/ribbon/drawtable_tests.rs +++ b/crates/ui-egui/src/ribbon/drawtable_tests.rs @@ -35,13 +35,17 @@ fn draw_a_table_split_it_and_erase_the_border() { s.execute("slide.new", &json!({"layout": "blank"})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = "Insert".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.get_by_label("Table").click(); h.run_steps(2); diff --git a/crates/ui-egui/src/ribbon/effects_tests.rs b/crates/ui-egui/src/ribbon/effects_tests.rs index 37d856fef..32e11b44f 100644 --- a/crates/ui-egui/src/ribbon/effects_tests.rs +++ b/crates/ui-egui/src/ribbon/effects_tests.rs @@ -9,7 +9,7 @@ use crate::{Services, SlideApp}; fn harness() -> Harness<'static, SlideApp> { let mut app = SlideApp::new(Session::with_new(), Services::default()); app.ui.tab = "Design".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ribbon/icons_popup_tests.rs b/crates/ui-egui/src/ribbon/icons_popup_tests.rs index 63b5886e6..c766fadef 100644 --- a/crates/ui-egui/src/ribbon/icons_popup_tests.rs +++ b/crates/ui-egui/src/ribbon/icons_popup_tests.rs @@ -11,7 +11,7 @@ use crate::{Services, SlideApp}; fn clicking_inside_the_icons_popup_keeps_it_open() { let mut app = SlideApp::new(Session::with_new(), Services::default()); app.ui.tab = "Insert".into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ribbon/inktoshape_tests.rs b/crates/ui-egui/src/ribbon/inktoshape_tests.rs index ce7875adc..49165b441 100644 --- a/crates/ui-egui/src/ribbon/inktoshape_tests.rs +++ b/crates/ui-egui/src/ribbon/inktoshape_tests.rs @@ -16,13 +16,17 @@ fn pen_a_rectangle_then_ink_to_shape() { s.execute("slide.new", &json!({"layout": "blank"})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = "Draw".into(); - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.get_by_label("Black Pen").click(); h.run_steps(2); diff --git a/crates/ui-egui/src/ribbon/master_layout_tests.rs b/crates/ui-egui/src/ribbon/master_layout_tests.rs index d4f5efa02..25aa9477d 100644 --- a/crates/ui-egui/src/ribbon/master_layout_tests.rs +++ b/crates/ui-egui/src/ribbon/master_layout_tests.rs @@ -11,7 +11,7 @@ use serde_json::json; use crate::{Services, SlideApp}; fn harness(app: SlideApp) -> Harness<'static, SlideApp> { - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ribbon/picture_styles_tests.rs b/crates/ui-egui/src/ribbon/picture_styles_tests.rs index e80d14ab7..0e383f393 100644 --- a/crates/ui-egui/src/ribbon/picture_styles_tests.rs +++ b/crates/ui-egui/src/ribbon/picture_styles_tests.rs @@ -22,7 +22,7 @@ fn picture_format(width: f32) -> (Harness<'static, SlideApp>, ShapeId) { s.execute("edit.select", &json!({"ids": [id]})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = "Picture Format".into(); - let mut h = Harness::builder().with_size(egui::vec2(width, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(width, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/ribbon/transitions.rs b/crates/ui-egui/src/ribbon/transitions.rs index 6986d828c..c1272fa38 100644 --- a/crates/ui-egui/src/ribbon/transitions.rs +++ b/crates/ui-egui/src/ribbon/transitions.rs @@ -82,7 +82,7 @@ pub(super) fn transitions(app: &mut SlideApp, ui: &mut Ui) { .and_then(|t| t.sound) .and_then(|m| app.session.active().and_then(|d| d.doc.media(m).map(|i| i.name.trim_end_matches(".wav").to_string()))) .unwrap_or_else(|| if stop { "[Stop Previous Sound]".into() } else { "[No Sound]".into() }); - let combo = craft_ui::ComboBox::from_id_salt("transition_sound").width(140.0).selected_text(name).show_ui(ui, |ui| { + let combo = egui::ComboBox::from_id_salt("transition_sound").width(140.0).selected_text(name).show_ui(ui, |ui| { let none = cur.as_ref().is_none_or(|t| t.sound.is_none() && !t.stop_sound); if ui.selectable_label(none, "[No Sound]").clicked() { run(app, "transition.sound", json!({"none": true})); diff --git a/crates/ui-egui/src/settings.rs b/crates/ui-egui/src/settings.rs index 1fd5223b2..fb175b9eb 100644 --- a/crates/ui-egui/src/settings.rs +++ b/crates/ui-egui/src/settings.rs @@ -157,13 +157,16 @@ mod tests { let mut app = crate::SlideApp::new(deckcraft_engine::Session::with_new(), crate::Services::default()); // The second case is not sanitized: the canvas keeps a stray zoom in range itself. app.ui = ui; - let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut crate::SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1200.0, 800.0)) + .build_ui_state( + |ui, app: &mut crate::SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(4); assert!(h.state().canvas_scale <= *crate::ZOOM_RANGE.end() + 1e-3, "{}", h.state().canvas_scale); } diff --git a/crates/ui-egui/src/show/keys.rs b/crates/ui-egui/src/show/keys.rs index 77741866d..3299c278b 100644 --- a/crates/ui-egui/src/show/keys.rs +++ b/crates/ui-egui/src/show/keys.rs @@ -6,12 +6,15 @@ use super::{Color32, Presentation, Show, ShowAction}; /// audience window and Presenter View use this path, including animation steps and end-of-show. /// `presenter` is true for Presenter View, where G opens that window's own grid (#1130). pub(super) fn keyboard(ctx: &egui::Context, show: &mut Show, doc: &Presentation, now: f64, presenter: bool) -> bool { - let keys: Vec<(egui::Key, egui::Modifiers)> = ctx.input(|i| { + let mut keys: Vec<(egui::Key, egui::Modifiers)> = ctx.input(|i| { i.events .iter() .filter_map(|e| if let egui::Event::Key { key, pressed: true, modifiers, .. } = e { Some((*key, *modifiers)) } else { None }) .collect() }); + if crate::framework::window_escape(ctx) { + keys.push((egui::Key::Escape, egui::Modifiers::NONE)); + } let (keep, consumed) = handle_keys(show, doc, now, keys, presenter); for (key, modifiers) in consumed { ctx.input_mut(|i| i.consume_key(modifiers, key)); diff --git a/crates/ui-egui/src/show/tests.rs b/crates/ui-egui/src/show/tests.rs index 58fa5ffa3..58305cb2b 100644 --- a/crates/ui-egui/src/show/tests.rs +++ b/crates/ui-egui/src/show/tests.rs @@ -35,13 +35,17 @@ fn a_still_cursor_hides_over_a_clickable_shape() { let r = session.execute("shape.insert", &json!({"preset": "rect", "rect": [0.0, 0.0, size.width, size.height]})).unwrap(); session.execute("insert.hyperlink", &json!({"url": "https://example.org", "ids": [r["id"]]})).unwrap(); let app = SlideApp::new(session, crate::Services::default()); - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(vec2(1000.0, 700.0)) + .with_step_dt(0.25) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(0, false); harness.run_steps(2); @@ -65,13 +69,17 @@ fn keep_cursor_visible_leaves_a_still_cursor_over_a_link() { let mut app = SlideApp::new(session, crate::Services::default()); app.ui.presenter_view = false; app.run("show.keepCursor", json!({"on": true})).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(vec2(1000.0, 700.0)) + .with_step_dt(0.25) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(0, false); harness.run_steps(2); @@ -90,13 +98,14 @@ fn set_up_slide_show_keeps_the_cursor_visible() { use egui_kittest::kittest::Queryable; let app = SlideApp::new(deckcraft_engine::Session::with_new(), crate::Services::default()); - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 800.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); for on in [true, false] { harness.state_mut().run("app.dialog", json!({"id": "setupShow"})).unwrap(); harness.run_steps(6); @@ -204,18 +213,19 @@ fn show_with_clip() -> (egui_kittest::Harness<'static, SlideApp>, ShapeId, Pos2, // Presenter view opens an embedded window over the whole screen here, which takes the clicks. let mut app = SlideApp::new(session, crate::Services::default()); app.ui.presenter_view = false; - let mut harness = egui_kittest::Harness::builder().with_size(size).with_step_dt(0.25).build_ui_state( - move |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) { - let now = ui.input(|i| i.time); - seen.set(pointer_on_media_bar(ui.ctx(), ui, &d.doc, show, now)); - slide_seen.set(shown_slide_rect(ui, show, &d.doc)); - } - app.ui(ui); - }, - app, - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).with_step_dt(0.25).build_ui_state( + move |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) { + let now = ui.input(|i| i.time); + seen.set(pointer_on_media_bar(ui.ctx(), ui, &d.doc, show, now)); + slide_seen.set(shown_slide_rect(ui, show, &d.doc)); + } + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(0, false); harness.run_steps(2); @@ -304,16 +314,20 @@ fn show_with_gif() -> (egui_kittest::Harness<'static, SlideApp>, ShapeId, Pos2) let slide_seen = slide.clone(); let mut app = SlideApp::new(session, crate::Services::default()); app.ui.presenter_view = false; - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25).build_ui_state( - move |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) { - slide_seen.set(shown_slide_rect(ui, show, &d.doc)); - } - app.ui(ui); - }, - app, - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(vec2(1000.0, 700.0)) + .with_step_dt(0.25) + .build_ui_state( + move |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) { + slide_seen.set(shown_slide_rect(ui, show, &d.doc)); + } + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(1, false); harness.run_steps(2); @@ -415,13 +429,14 @@ fn slideshow_navigation_advances_once_with_presenter_view() { session.execute("slide.new", &json!({})).unwrap(); let mut app = SlideApp::new(session, crate::Services::default()); app.ui.presenter_view = true; - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1000.0, 700.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(0, false); harness.run_steps(2); @@ -810,13 +825,17 @@ fn show_of_three() -> egui_kittest::Harness<'static, SlideApp> { session.execute("slide.new", &json!({})).unwrap(); let mut app = SlideApp::new(session, crate::Services::default()); app.ui.presenter_view = false; - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(vec2(1000.0, 700.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(0, false); harness.run_steps(2); @@ -1089,13 +1108,14 @@ fn back_leaves_a_slide_whose_first_animation_is_with_previous() { .execute("animation.add", &json!({"effect": "fade", "class": "entrance", "ids": [id.0], "start": "withPrevious", "duration": 500})) .unwrap(); let app = SlideApp::new(session, crate::Services::default()); - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1000.0, 700.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); harness.run_steps(3); harness.state_mut().start_show(0, false); harness.run_steps(2); @@ -1196,13 +1216,14 @@ fn remote_presenter_uses_the_audience_state_and_closes_with_the_show() { let services = crate::Services { presenter: Some(Box::new(Mock(bridge.clone()))), ..Default::default() }; let mut app = SlideApp::new(session, services); app.ui.presenter_view = true; - let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1000.0, 700.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h.state_mut().start_show(0, false); h.run_steps(2); diff --git a/crates/ui-egui/src/slide_size_tests.rs b/crates/ui-egui/src/slide_size_tests.rs index 0ad779943..7168675db 100644 --- a/crates/ui-egui/src/slide_size_tests.rs +++ b/crates/ui-egui/src/slide_size_tests.rs @@ -18,7 +18,7 @@ fn open_with_size(w: f64, h: f64) -> egui_kittest::Harness<'static, SlideApp> { let mut s = Session::new(); s.execute("file.open", &json!({"path": path.to_string_lossy()})).unwrap(); let _ = std::fs::remove_file(&path); - egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state( + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1280.0, 800.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/sorter.rs b/crates/ui-egui/src/sorter.rs index 638cdb267..b521b068f 100644 --- a/crates/ui-egui/src/sorter.rs +++ b/crates/ui-egui/src/sorter.rs @@ -110,7 +110,7 @@ fn section_header(app: &mut SlideApp, ui: &mut Ui, h: &Header<'_>) -> Rect { } app.sorter.rename_started = true; } - let (enter, esc) = ui.input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape))); + let (enter, esc) = (ui.input(|i| i.key_pressed(egui::Key::Enter)), crate::framework::escape_pressed(ui.ctx())); // The frame that asks for focus has not had it yet; committing then would cancel the rename. if already && (out.lost_focus() || enter || esc) { app.sorter.renaming = None; @@ -278,6 +278,8 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) { let multi = st.selection.slides.clone(); let zoom = app.ui.sorter_zoom.clamp(0.5, 3.0); let grouped = groups(&doc); + // Behind the thumbnails, which take the presses: the document's Tab stop and key target. + app.document_behind(ui, ui.available_rect_before_wrap()); egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { ui.add_space(12.0); ui.horizontal(|ui| { @@ -363,6 +365,9 @@ pub fn notes_page(app: &mut SlideApp, ui: &mut Ui) { let t = Tokens::get(ui.ctx()); let avail = ui.available_rect_before_wrap(); ui.painter().rect_filled(avail, CornerRadius::ZERO, t.canvas); + if app.session.active().is_some() { + app.document_widget(ui, avail, Sense::click()); + } let Some(st) = app.session.active() else { return }; let doc = st.doc.clone(); let idx = st.selection.slide; diff --git a/crates/ui-egui/src/sorter/ui_tests.rs b/crates/ui-egui/src/sorter/ui_tests.rs index 07b42d02f..b0c5cfa06 100644 --- a/crates/ui-egui/src/sorter/ui_tests.rs +++ b/crates/ui-egui/src/sorter/ui_tests.rs @@ -19,13 +19,17 @@ fn harness(with_sections: bool) -> Harness<'static, SlideApp> { } let mut app = SlideApp::new(s, Services::default()); app.ui.view = crate::ViewMode::Sorter; - let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1400.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/split_button_tests.rs b/crates/ui-egui/src/split_button_tests.rs index 3f91942b6..3f0063d21 100644 --- a/crates/ui-egui/src/split_button_tests.rs +++ b/crates/ui-egui/src/split_button_tests.rs @@ -23,7 +23,7 @@ fn harness(tab: &str) -> (Harness<'static, SlideApp>, [ShapeId; 2]) { s.execute("selection.select", &json!({"ids": [ids[0].0, ids[1].0]})).unwrap(); let mut app = SlideApp::new(s, Services::default()); app.ui.tab = tab.into(); - let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/status.rs b/crates/ui-egui/src/status.rs index 0301af446..2b25e65ff 100644 --- a/crates/ui-egui/src/status.rs +++ b/crates/ui-egui/src/status.rs @@ -332,7 +332,7 @@ mod tests { app.session.execute("format.language", &json!({"lang": "en-US-x-a-very-long-private-use-tag"})).unwrap(); app.ui.notes = false; let size = egui::vec2(700.0, 800.0); - let mut h = Harness::builder().with_size(size).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -379,7 +379,7 @@ mod tests { /// hear which view button is on, and read the slide counter and the status message. #[test] fn status_bar_controls_have_names() { - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 40c62b38b..7dabe3fe3 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -13,13 +13,14 @@ fn shape_rot(app: &SlideApp) -> f64 { /// letting go is one undo step. Off the canvas it does nothing. #[test] fn a_trackpad_twist_rotates_the_shape_under_the_canvas() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let id = harness.state_mut().session.execute("shape.insert", &json!({"preset": "rect", "rect": [80.0, 80.0, 100.0, 60.0]})).unwrap(); let id = id.get("id").and_then(|v| v.as_u64()).unwrap(); @@ -117,13 +118,14 @@ fn title_text(app: &SlideApp) -> String { #[test] fn quick_access_toolbar_adds_removes_resets_and_persists() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let ids = |app: &SlideApp| app.ui.qat.iter().map(|q| q.id.clone()).collect::>(); assert_eq!(ids(harness.state()), ["app.home", "file.save", "app.exportDialog", "edit.undo", "edit.redo", "show.fromStart"]); @@ -179,13 +181,14 @@ fn opening_a_file_with_missing_fonts_shows_a_toast_once() { body.paragraphs[0].runs[0].props.font = Some("Qqq Nonexistent Sans".into()); slide.shapes[0].text = Some(body); let data = deckcraft_engine::cmd::base64_encode(&deckcraft_engine::cmd::file::save_bytes(&p, "pptx").unwrap()); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); assert!(harness.state().toast.is_none(), "a new presentation has nothing to say"); harness.state_mut().session.execute("file.openBytes", &json!({"name": "a.pptx", "data": data})).unwrap(); @@ -254,13 +257,14 @@ fn change_picture_replaces_the_selected_picture() { /// #17: Home created a new blank presentation instead of going to the start screen. #[test] fn home_shows_the_start_screen_over_the_open_presentation() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); // The app keeps requesting repaints, so step frames instead of run(). harness.run_steps(2); let title = harness.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; @@ -302,13 +306,14 @@ fn ctrl_word_keys_edit_text() { let mut session = Session::with_new(); session.mac_keys = false; session.prefs.autocorrect = false; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, Services::default()), + ); harness.run_steps(2); let title = harness.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; harness.state_mut().session.execute("text.edit", &json!({"id": title})).unwrap(); @@ -380,13 +385,14 @@ fn ctrl_word_keys_edit_text() { /// Export… had no visible control: only the command palette reached it. #[test] fn title_bar_export_opens_the_export_dialog() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); assert!(harness.state().dialog.is_none()); // Quick access: Home, Save, Export, each 24 points wide with 2 between, from x = 10. @@ -424,13 +430,16 @@ fn ctrl_v_pastes_the_picture_a_browser_copied_not_its_link() { clipboard_html: Some(Box::new(move || html.clone())), ..Default::default() }; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, services), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, services), + ); harness.run_steps(2); let shapes_before = harness.state().session.active().unwrap().doc.slides[0].shapes.len(); harness.event(egui::Event::Paste(text.clone())); @@ -458,13 +467,14 @@ fn ctrl_v_pastes_an_image_when_no_paste_event_arrives() { }; assert!(!png.is_empty()); let services = Services { clipboard_image: Some(Box::new(move || Some(png.clone()))), ..Default::default() }; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, services), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, services), + ); harness.run_steps(2); let pictures = |app: &SlideApp| { let d = app.session.active().unwrap(); @@ -490,17 +500,18 @@ fn ctrl_v_pastes_an_image_when_no_paste_event_arrives() { /// #78: after Tab in a text box, typing and deleting no longer reached the text. #[test] fn typing_goes_on_after_tab_in_a_text_box() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - { - let mut session = Session::with_new(); - session.prefs.autocorrect = false; - SlideApp::new(session, Services::default()) - }, - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + { + let mut session = Session::with_new(); + session.prefs.autocorrect = false; + SlideApp::new(session, Services::default()) + }, + ); harness.run_steps(2); let title = harness.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; harness.state_mut().session.execute("text.edit", &json!({"id": title})).unwrap(); @@ -533,13 +544,14 @@ fn typing_goes_on_after_tab_in_a_text_box() { /// list could neither be typed into nor continued with Enter. #[test] fn tab_in_an_edited_list_keeps_the_keyboard() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let title = harness.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; harness.state_mut().session.execute("text.edit", &json!({"id": title})).unwrap(); @@ -637,13 +649,14 @@ fn grid_options_sets_spacing_and_display_or_opens_the_dialog() { #[test] fn grid_options_dialog_lists_spacing_and_display() { use egui_kittest::kittest::Queryable; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); harness.state_mut().run("view.gridOptions", json!({})).unwrap(); harness.run_steps(2); @@ -680,13 +693,14 @@ fn grid_options_dialog_lists_spacing_and_display() { #[test] fn preferences_cancel_restores_the_settings_done_keeps_them() { use egui_kittest::kittest::Queryable; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let before = harness.state().session.prefs.clone(); let dark_before = harness.state().ui.brightness; @@ -740,13 +754,14 @@ fn preferences_cancel_restores_the_settings_done_keeps_them() { #[test] fn about_dialog_close_and_cancel_close_it() { use egui_kittest::kittest::Queryable; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); harness.state_mut().run("app.about", json!({})).unwrap(); harness.run_steps(2); @@ -772,13 +787,14 @@ fn about_dialog_close_and_cancel_close_it() { } fn canvas_harness() -> egui_kittest::Harness<'static, SlideApp> { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let app = harness.state_mut(); // Zoomed out, the canvas shows plenty of pasteboard around the slide. @@ -880,13 +896,14 @@ fn the_canvas_renders_only_the_slide_when_nothing_is_off_it() { /// Ctrl+X do. #[test] fn copy_and_cut_commands_reach_the_system_clipboard() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let copied = |h: &egui_kittest::Harness<'_, SlideApp>| { h.output().platform_output.commands.iter().find_map(|c| match c { @@ -917,13 +934,14 @@ fn copy_and_cut_commands_reach_the_system_clipboard() { /// egui-winit drops Ctrl+V when the system clipboard is empty; the context menu worked. #[test] fn copy_then_paste_shortcut_duplicates_an_object_without_text() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); harness.state_mut().session.execute("shape.insert", &json!({"preset": "rect", "rect": [10, 10, 50, 50]})).unwrap(); let count = |h: &egui_kittest::Harness<'_, SlideApp>| h.state().session.doc().unwrap().current_slide().unwrap().shapes.len(); @@ -946,13 +964,14 @@ fn copy_then_paste_shortcut_duplicates_an_object_without_text() { /// canvas focused it still selects shapes. #[test] fn select_all_follows_the_focused_pane() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); for _ in 0..2 { harness.state_mut().run("slide.new", json!({})).unwrap(); @@ -985,7 +1004,7 @@ fn select_all_follows_the_focused_pane() { } fn harness() -> egui_kittest::Harness<'static, SlideApp> { - egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -994,6 +1013,24 @@ fn harness() -> egui_kittest::Harness<'static, SlideApp> { ) } +/// With the framework runtime installed, the window's keys still reach DeckCraft's own routing: Alt+1 runs the +/// first Quick Access Toolbar item (Alt+numpad code entry leaves the claimed chord alone off macOS), and Escape with +/// nothing focused leaves the File tab. +#[test] +fn alt_digit_and_escape_reach_the_app_through_the_runtime() { + let mut h = harness(); + h.state_mut().run("file.new", json!({})).unwrap(); + h.state_mut().session.mac_keys = false; + h.run_steps(3); + assert!(!h.state().backstage_open()); + h.key_press_modifiers(egui::Modifiers::ALT, egui::Key::Num1); + h.run_steps(2); + assert!(h.state().backstage_open(), "Alt+1 runs app.home, which opens the File tab"); + h.key_press(egui::Key::Escape); + h.run_steps(2); + assert!(!h.state().backstage_open(), "Escape leaves the File tab"); +} + /// #172: a recent file that no longer exists is marked on File › Home, and clicking it draws /// the open error right there (the status bar is hidden while the backstage is open, so the /// message used to vanish). @@ -1053,13 +1090,14 @@ fn recent_exists_tells_missing_from_present() { #[test] fn the_language_dialog_marks_the_selected_text() { use egui_kittest::kittest::Queryable; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let title = harness.state().session.active().unwrap().doc.slides[0].shapes[0].id.0; harness.state_mut().session.execute("text.edit", &json!({"id": title})).unwrap(); @@ -1083,13 +1121,14 @@ fn the_language_dialog_marks_the_selected_text() { #[test] fn the_language_dialog_marks_the_whole_presentation() { use egui_kittest::kittest::Queryable; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let s = &mut harness.state_mut().session; let title = s.active().unwrap().doc.slides[0].shapes[0].id.0; @@ -1119,13 +1158,14 @@ fn the_language_dialog_marks_the_whole_presentation() { #[test] fn the_language_dialog_marks_the_whole_presentation_with_nothing_selected() { use egui_kittest::kittest::{NodeT, Queryable}; - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let s = &mut harness.state_mut().session; let title = s.active().unwrap().doc.slides[0].shapes[0].id.0; @@ -1179,13 +1219,14 @@ fn editing_notes_in_the_pane_keeps_their_formatting() { }; let mut session = Session::with_new(); session.execute("slide.notes", &json!({"index": 0, "body": notes})).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(session, Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(session, Services::default()), + ); harness.run_steps(2); let id = egui::Id::unique("notes_edit"); let caret = |h: &mut egui_kittest::Harness<'_, SlideApp>, at: usize| { @@ -1233,13 +1274,14 @@ fn editing_notes_in_the_pane_keeps_their_formatting() { } fn step_app(services: Services) -> egui_kittest::Harness<'static, SlideApp> { - let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), services), - ); + let mut h = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), services), + ); h.run_steps(2); h } @@ -1394,13 +1436,17 @@ fn preview_hides_an_entrance_until_it_plays() { #[test] fn animation_preview_plays_on_the_canvas_then_stops() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).with_step_dt(0.05).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1200.0, 800.0)) + .with_step_dt(0.05) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let none = harness.state_mut().run("animation.preview", json!({})).unwrap(); assert_eq!(none["playing"], false); @@ -1461,13 +1507,17 @@ fn animation_preview_plays_on_the_canvas_then_stops() { } fn flick_harness() -> egui_kittest::Harness<'static, SlideApp> { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .with_size(egui::vec2(1200.0, 800.0)) + .with_step_dt(1.0 / 60.0) + .build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); // Fitted: the slide is smaller than the window, so a flick turns the page instead of panning. harness.state_mut().ui.zoom = Some(0.4); @@ -1741,13 +1791,14 @@ fn the_pen_ignores_a_swipe_during_the_show() { /// until the pointer lets go, so the slider doesn't grow under the pointer mid-drag. #[test] fn interface_size_applies_when_the_slider_is_let_go() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); harness.state_mut().run("app.preferences", json!({})).unwrap(); harness.run_steps(4); @@ -1775,7 +1826,7 @@ fn interface_size_applies_when_the_slider_is_let_go() { #[test] fn status_zoom_slider_is_named_without_growing_the_status_bar() { for size in [egui::vec2(900.0, 560.0), egui::vec2(1440.0, 900.0)] { - let mut harness = egui_kittest::Harness::builder().with_size(size).build_ui_state( + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); @@ -1803,13 +1854,14 @@ fn status_zoom_slider_is_named_without_growing_the_status_bar() { /// than a visible label duplicated by `Slider::text`. #[test] fn preferences_and_format_pane_name_every_input() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + 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( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(3); harness.state_mut().run("app.preferences", json!({})).unwrap(); harness.run_steps(3); @@ -1832,13 +1884,14 @@ fn preferences_and_format_pane_name_every_input() { /// kittest's screenshot callback, and replied to exactly once after a logic drain. #[test] fn ui_screenshot_round_trips_through_the_callable_slot() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(900.0, 600.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(900.0, 600.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); let (tx, rx) = std::sync::mpsc::channel(); harness.state_mut().control_rx = Some(rx); let (req, reply) = ControlRequest::new("ui.screenshot", json!({})); @@ -1860,6 +1913,7 @@ fn ui_screenshot_round_trips_through_the_callable_slot() { fn logic_drains_control_without_a_ui_pass() { let mut app = SlideApp::new(Session::with_new(), Services::default()); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let (tx, rx) = std::sync::mpsc::channel(); app.control_rx = Some(rx); let (req, reply) = ControlRequest::new("ui.inspect", json!({})); @@ -1876,6 +1930,7 @@ fn logic_drains_control_without_a_ui_pass() { fn synthetic_input_is_one_pending_batch_and_never_replays() { let mut app = SlideApp::new(Session::with_new(), Services::default()); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); app.queue_input(egui::Event::PointerMoved(egui::pos2(10.0, 10.0))); let mut raw = egui::RawInput::default(); app.raw_input_hook(&ctx, &mut raw); @@ -1943,6 +1998,7 @@ fn a_control_click_on_the_first_font_discard_is_requeued_and_lands() { app.fonts_ready = true; app.styled = true; let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let pass = |app: &mut SlideApp, time: f64| { let mut raw = egui::RawInput { time: Some(time), ..Default::default() }; raw.viewports.insert( @@ -1993,6 +2049,7 @@ fn a_control_click_on_the_first_font_discard_is_requeued_and_lands() { fn synthetic_batch_is_retracted_when_a_modal_opens_first() { let mut app = SlideApp::new(Session::with_new(), Services::default()); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); app.queue_input(egui::Event::PointerMoved(egui::pos2(10.0, 10.0))); let mut raw = egui::RawInput::default(); app.raw_input_hook(&ctx, &mut raw); @@ -2022,6 +2079,7 @@ fn synthetic_click_is_consumed_on_its_old_target_before_logic_changes_the_docume app.fonts_ready = true; app.styled = true; let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let pass = |app: &mut SlideApp, time: f64| { let mut raw = egui::RawInput { time: Some(time), ..Default::default() }; raw.viewports.insert( @@ -2183,6 +2241,7 @@ fn input_target_changes_retract_a_queued_click() { fn hidden_logic_pass_carries_a_synthetic_batch_and_drops_it_when_the_document_changes() { let mut app = SlideApp::new(Session::with_new(), Services::default()); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let (tx, rx) = std::sync::mpsc::channel(); app.control_rx = Some(rx); app.queue_input(egui::Event::PointerMoved(egui::pos2(10.0, 10.0))); @@ -2277,6 +2336,7 @@ fn carried_batch_is_consumed_before_the_full_pass_applies_a_control_change() { app.fonts_ready = true; app.styled = true; let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let (tx, rx) = std::sync::mpsc::channel(); app.control_rx = Some(rx); app.queue_input(egui::Event::PointerMoved(egui::pos2(10.0, 10.0))); @@ -2333,6 +2393,7 @@ fn hidden_full_pass_receives_synthetic_ui_input() { app.dialog = Some(crate::dialogs::Dialog::new("replaceFonts")); app.queue_input(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut hidden = egui::RawInput { time: Some(4.0), ..Default::default() }; hidden.viewports.insert( egui::ViewportId::ROOT, @@ -2356,13 +2417,14 @@ fn hidden_full_pass_receives_synthetic_ui_input() { /// asking the host clipboard service for the same image again. #[test] fn paste_image_event_inserts_one_picture() { - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(900.0, 600.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + let mut harness = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(900.0, 600.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); harness.run_steps(2); let before = harness.state().session.active().unwrap().doc.slides[0].shapes.len(); let image = egui::ColorImage::filled([2, 2], egui::Color32::from_rgb(1, 2, 3)); @@ -2395,6 +2457,7 @@ fn hidden_viewport_advances_show_and_presenter_clocks_from_logic() { app.session.execute("transition.timing", &json!({"index": 1, "after": null})).unwrap(); app.start_show(0, false); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); // A real visible UI pass starts the show and its clocks. There is no renderer here, so // each frame's texture uploads are cleared explicitly (egui 0.37 panics on drop). @@ -2459,6 +2522,7 @@ fn overdue_visible_logic_does_not_reanchor_a_later_hidden_show() { app.session.execute("transition.timing", &json!({"index": 1, "after": null})).unwrap(); app.start_show(0, false); let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); // The full visible pass is the only pass that anchors the show: egui time 10. ctx.run_ui(raw_at(10.0, false, false), |ui| { @@ -2485,13 +2549,14 @@ fn overdue_visible_logic_does_not_reanchor_a_later_hidden_show() { /// frame until it stuck at its widest and dragging its edge did nothing. #[test] fn comments_pane_keeps_its_width_and_resizes() { - let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - SlideApp::new(Session::with_new(), Services::default()), - ); + let mut h = + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + SlideApp::new(Session::with_new(), Services::default()), + ); h.run_steps(3); h.state_mut().run("comment.add", json!({"text": "Check the figures on this slide"})).unwrap(); h.state_mut().run("comment.add", json!({"text": "Resolved one"})).unwrap(); diff --git a/crates/ui-egui/src/texture_limit_tests.rs b/crates/ui-egui/src/texture_limit_tests.rs index d73273e61..ea19ba552 100644 --- a/crates/ui-egui/src/texture_limit_tests.rs +++ b/crates/ui-egui/src/texture_limit_tests.rs @@ -9,7 +9,7 @@ use crate::{Services, SlideApp}; use deckcraft_engine::Session; fn harness(session: Session, size: egui::Vec2) -> egui_kittest::Harness<'static, SlideApp> { - egui_kittest::Harness::builder().with_size(size).build_ui_state( + egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 2e14bbaad..25f10b123 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -179,7 +179,7 @@ pub fn install_fonts(ctx: &egui::Context) { /// installed or embedded faces that draw text the interface faces lack (Hangul, Simplified /// Chinese, Devanagari…, #101). See [`crate::uifonts`]. pub fn install_fonts_with(ctx: &egui::Context, extra: &[std::sync::Arc]) { - ctx.set_fonts(font_definitions(extra)); + craft_ui::fonts::load(ctx, font_definitions(extra)); } /// The interface font definitions; see [`install_fonts_with`]. @@ -213,6 +213,10 @@ pub fn font_definitions(extra: &[std::sync::Arc]) -> // A bold family for headings and selected tabs. let mut bold: Vec = names.iter().filter(|(fam, st, _)| *fam == "Inter" && *st == "SemiBold").map(|(_, _, n)| n.clone()).collect(); bold.extend(defs.families.get(&FontFamily::Proportional).cloned().unwrap_or_default()); + // The framework's dialogs draw their titles in the semibold family and signatures in the + // signature family; DeckCraft's SemiBold chain and its proportional chain are those. + defs.families.insert(FontFamily::Name(craft_ui::fonts::SEMIBOLD.into()), bold.clone()); + defs.families.insert(craft_ui::fonts::FontRef::signature().family(), defs.families.get(&FontFamily::Proportional).cloned().unwrap_or_default()); defs.families.insert(FontFamily::Name("bold".into()), bold); // Hack is already bundled for Monospace and covers the interface's arrows and triangles. // Keep it after every proportional face so ordinary text metrics stay unchanged. diff --git a/crates/ui-egui/src/ui_soak_tests.rs b/crates/ui-egui/src/ui_soak_tests.rs index edfd169f7..0d6e909f8 100644 --- a/crates/ui-egui/src/ui_soak_tests.rs +++ b/crates/ui-egui/src/ui_soak_tests.rs @@ -72,13 +72,14 @@ fn harness() -> Harness<'static, SlideApp> { let mut s = Session::new(); deckcraft_engine::sample::open_sample(&mut s).unwrap(); let app = SlideApp::new(s, Services::default()); - let mut h = Harness::builder().with_size(vec2(W, H)).with_step_dt(1.0 / 60.0).build_ui_state( - |ui, app: &mut SlideApp| { - app.logic(ui.ctx()); - app.ui(ui); - }, - app, - ); + let mut h = + Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(W, H)).with_step_dt(1.0 / 60.0).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); h.run_steps(3); h } diff --git a/crates/ui-egui/src/units_tests.rs b/crates/ui-egui/src/units_tests.rs index 503e8a2b8..5e6533d0a 100644 --- a/crates/ui-egui/src/units_tests.rs +++ b/crates/ui-egui/src/units_tests.rs @@ -12,7 +12,7 @@ use deckcraft_engine::Session; use deckcraft_geom::Unit; fn harness(app: SlideApp) -> Harness<'static, SlideApp> { - Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state( + Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state( |ui, app: &mut SlideApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index d80e7cdde..4ce1ce640 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -7,7 +7,7 @@ use std::process::Command; use serde_json::Value; const SHARED_REPO: &str = "https://github.com/storytold/craft-libs"; -const SHARED_REV: &str = "63196e66f3033a6623eb629af95a104d26986725"; +const SHARED_REV: &str = "8fa4db64a9bb943520259ea95331a303ba788f21"; const REGISTRY: &str = "registry+https://github.com/rust-lang/crates.io-index"; pub fn run(root: &Path) -> Result<(), String> {