From b9ebf45a0344a9e1d21424ae23665c016b2ef64b Mon Sep 17 00:00:00 2001 From: Ryan Andersen Date: Tue, 4 Mar 2025 22:39:38 -0800 Subject: [PATCH 01/11] Relax perform from Fn to more general FnOnce --- runtime/src/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/task.rs b/runtime/src/task.rs index 710be5d9..fd5970ac 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -37,7 +37,7 @@ impl Task { /// output with the given closure. pub fn perform( future: impl Future + MaybeSend + 'static, - f: impl Fn(A) -> T + MaybeSend + 'static, + f: impl FnOnce(A) -> T + MaybeSend + 'static, ) -> Self where T: MaybeSend + 'static, From f369bc86e2abb12024cb781cdba94bbfa047c800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 9 Mar 2025 01:28:27 +0100 Subject: [PATCH 02/11] Update `Cargo.lock` --- Cargo.lock | 398 ++++++++++++++++++++++++++++------------------------- 1 file changed, 214 insertions(+), 184 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 072f8e61..25fe2b77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ab_glyph" @@ -74,7 +74,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.8.0", + "bitflags 2.9.0", "cc", "cesu8", "jni", @@ -123,9 +123,9 @@ checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "approx" @@ -472,9 +472,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97" dependencies = [ "proc-macro2", "quote", @@ -538,9 +538,9 @@ dependencies = [ [[package]] name = "avif-serialize" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62" +checksum = "98922d6a4cfbcb08820c69d8eeccc05bb1f29bfa06b4f5b1dbfe9a868bd7608e" dependencies = [ "arrayvec", ] @@ -617,9 +617,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bitstream-io" @@ -672,9 +672,9 @@ checksum = "e79769241dcd44edf79a732545e8b5cec84c247ac060f5252cd51885d093a8fc" [[package]] name = "built" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73848a43c5d63a1251d17adf6c2bf78aa94830e60a335a95eeea45d6ba9e1e4d" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" [[package]] name = "bumpalo" @@ -690,9 +690,9 @@ checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" dependencies = [ "bytemuck_derive", ] @@ -722,9 +722,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "bytesize" @@ -748,7 +748,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "log", "polling 3.7.4", "rustix 0.38.44", @@ -776,9 +776,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.14" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "jobserver", "libc", @@ -842,16 +842,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -883,18 +883,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.29" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.29" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstyle", "clap_lex", @@ -1069,7 +1069,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "core-foundation 0.10.0", "core-graphics-types 0.2.0", "foreign-types 0.5.0", @@ -1093,7 +1093,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "core-foundation 0.10.0", "libc", ] @@ -1104,7 +1104,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59fd57d82eb4bfe7ffa9b1cec0c05e2fd378155b47f255a67983cb4afe0e80c2" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "fontdb 0.16.2", "log", "rangemap", @@ -1355,9 +1355,9 @@ dependencies = [ [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] @@ -1387,7 +1387,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98888c4bbd601524c11a7ed63f814b8825f420514f78e96f752c437ae9cbb5d1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "bytemuck", "drm-ffi", "drm-fourcc", @@ -1431,9 +1431,9 @@ dependencies = [ [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "encoding_rs" @@ -1618,9 +1618,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" dependencies = [ "crc32fast", "miniz_oxide", @@ -2102,7 +2102,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "gpu-alloc-types", ] @@ -2112,7 +2112,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -2133,7 +2133,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf29e94d6d243368b7a56caa16bc213e4f9f8ed38c4d9557069527b5d5281ca" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "gpu-descriptor-types", "hashbrown", ] @@ -2144,7 +2144,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -2204,9 +2204,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "5017294ff4bb30944501348f6f8e42e6ad28f42c8bbef7a74029aff064a4e3c2" dependencies = [ "atomic-waker", "bytes", @@ -2288,6 +2288,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" +[[package]] +name = "hermit-abi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" + [[package]] name = "hex" version = "0.4.3" @@ -2367,9 +2373,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "httpdate" @@ -2410,7 +2416,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.7", + "h2 0.4.8", "http 1.2.0", "http-body 1.0.1", "httparse", @@ -2434,7 +2440,7 @@ dependencies = [ "rustls 0.23.23", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.1", + "tokio-rustls 0.26.2", "tower-service", ] @@ -2517,7 +2523,7 @@ name = "iced_core" version = "0.14.0-dev" dependencies = [ "approx", - "bitflags 2.8.0", + "bitflags 2.9.0", "bytes", "dark-light", "glam", @@ -2550,7 +2556,7 @@ dependencies = [ name = "iced_graphics" version = "0.14.0-dev" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "bytemuck", "cosmic-text", "half", @@ -2627,7 +2633,7 @@ dependencies = [ name = "iced_wgpu" version = "0.14.0-dev" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "bytemuck", "futures", "glam", @@ -2934,11 +2940,11 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ - "hermit-abi 0.4.0", + "hermit-abi 0.5.0", "libc", "windows-sys 0.59.0", ] @@ -2973,9 +2979,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jni" @@ -3107,9 +3113,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "libfuzzer-sys" @@ -3143,9 +3149,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.10", ] [[package]] @@ -3182,10 +3188,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a385b1be4e5c3e362ad2ffa73c392e53f031eaa5b7d648e64cd87f27f6063d7" [[package]] -name = "litemap" -version = "0.7.4" +name = "linux-raw-sys" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "litrs" @@ -3213,9 +3225,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" dependencies = [ "value-bag", ] @@ -3275,9 +3287,9 @@ dependencies = [ [[package]] name = "lyon_path" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e0b8aec2f58586f6eef237985b9a9b7cb3a3aff4417c575075cf95bf925252e" +checksum = "0047f508cd7a85ad6bad9518f68cce7b1bf6b943fb71f6da0ee3bc1e8cb75f25" dependencies = [ "lyon_geom", "num-traits", @@ -3363,7 +3375,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block", "core-graphics-types 0.1.3", "foreign-types 0.5.0", @@ -3396,9 +3408,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", "simd-adler32", @@ -3470,7 +3482,7 @@ checksum = "364f94bc34f61332abebe8cad6f6cd82a5b65cff22c828d05d0968911462ca4f" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg_aliases 0.1.1", "codespan-reporting", "hexf-parse", @@ -3485,9 +3497,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" dependencies = [ "libc", "log", @@ -3506,7 +3518,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "jni-sys", "log", "ndk-sys 0.6.0+11769913", @@ -3551,7 +3563,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg-if", "cfg_aliases 0.2.1", "libc", @@ -3723,7 +3735,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "libc", "objc2", @@ -3739,7 +3751,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-core-location", @@ -3763,7 +3775,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-foundation", @@ -3805,7 +3817,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "dispatch", "libc", @@ -3830,7 +3842,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-foundation", @@ -3842,7 +3854,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-foundation", @@ -3865,7 +3877,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-cloud-kit", @@ -3897,7 +3909,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-core-location", @@ -3952,9 +3964,9 @@ dependencies = [ [[package]] name = "oorandom" -version = "11.1.4" +version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] name = "open" @@ -3969,11 +3981,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.70" +version = "0.10.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" +checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg-if", "foreign-types 0.3.2", "libc", @@ -4001,9 +4013,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.105" +version = "0.9.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" dependencies = [ "cc", "libc", @@ -4142,7 +4154,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.10", "smallvec", "windows-targets 0.52.6", ] @@ -4222,18 +4234,18 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe2e71e1471fe07709406bf725f710b02927c9c54b2b5b2ec0e8087d97c327d" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e859e6e5bd50440ab63c47e3ebabc90f26251f7c73c3d3e837b74a1cc3fa67" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", @@ -4265,9 +4277,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plist" @@ -4389,18 +4401,18 @@ checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -4450,7 +4462,7 @@ version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "getopts", "memchr", "pulldown-cmark-escape", @@ -4511,9 +4523,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801" dependencies = [ "proc-macro2", ] @@ -4536,8 +4548,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.0", - "zerocopy 0.8.18", + "rand_core 0.9.3", + "zerocopy 0.8.23", ] [[package]] @@ -4557,7 +4569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -4571,12 +4583,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.18", ] [[package]] @@ -4694,11 +4705,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -4709,7 +4720,7 @@ checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ "getrandom 0.2.15", "libredox", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -4758,7 +4769,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.4.7", + "h2 0.4.8", "http 1.2.0", "http-body 1.0.1", "http-body-util", @@ -4843,9 +4854,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.9" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75ec5e92c4d8aede845126adc388046234541629e76029599ed35a003c7ed24" +checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" dependencies = [ "cc", "cfg-if", @@ -4899,13 +4910,26 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "errno", "libc", "linux-raw-sys 0.4.15", "windows-sys 0.59.0", ] +[[package]] +name = "rustix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dade4812df5c384711475be5fcd8c162555352945401aed22a35bffeab61f657" +dependencies = [ + "bitflags 2.9.0", + "errno", + "libc", + "linux-raw-sys 0.9.2", + "windows-sys 0.59.0", +] + [[package]] name = "rustls" version = "0.22.4" @@ -4961,9 +4985,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "rustybuzz" @@ -4971,7 +4995,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfb9cf8877777222e4a3bc7eb247e398b56baba500c38c1c46842431adc8b55c" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "bytemuck", "libm", "smallvec", @@ -4984,9 +5008,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -5054,7 +5078,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -5079,18 +5103,18 @@ checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -5099,9 +5123,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -5111,9 +5135,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", @@ -5282,7 +5306,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "calloop", "calloop-wayland-source", "cursor-icon", @@ -5378,7 +5402,7 @@ dependencies = [ "objc2-foundation", "objc2-quartz-core", "raw-window-handle 0.6.2", - "redox_syscall 0.5.8", + "redox_syscall 0.5.10", "rustix 0.38.44", "tiny-xlib", "wasm-bindgen", @@ -5411,7 +5435,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -5491,9 +5515,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.98" +version = "2.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2" dependencies = [ "proc-macro2", "quote", @@ -5571,7 +5595,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -5615,15 +5639,15 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.16.0" +version = "3.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567" dependencies = [ "cfg-if", "fastrand 2.3.0", "getrandom 0.3.1", "once_cell", - "rustix 0.38.44", + "rustix 1.0.1", "windows-sys 0.59.0", ] @@ -5656,11 +5680,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -5676,9 +5700,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -5708,9 +5732,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" dependencies = [ "deranged", "itoa", @@ -5723,15 +5747,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "e8093bc3e81c3bc5f7879de09619d06c9a5a5e45ca44dfeeb7225bae38005c5c" dependencies = [ "num-conv", "time-core", @@ -5798,9 +5822,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" dependencies = [ "tinyvec_macros", ] @@ -5836,9 +5860,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a" dependencies = [ "backtrace", "bytes", @@ -5873,9 +5897,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ "rustls 0.23.23", "tokio", @@ -6089,9 +6113,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "uds_windows" @@ -6130,9 +6154,9 @@ checksum = "1df77b101bcc4ea3d78dafc5ad7e4f58ceffe0b2b16bf446aeb50b6cb4157656" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-linebreak" @@ -6248,9 +6272,9 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "uuid" -version = "1.13.1" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" +checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587" dependencies = [ "getrandom 0.3.1", "js-sys", @@ -6510,7 +6534,7 @@ version = "0.31.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2120de3d33638aaef5b9f4472bff75f07c56379cf76ea320bd3a3d65ecaf73f" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "rustix 0.38.44", "wayland-backend", "wayland-scanner", @@ -6522,7 +6546,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cursor-icon", "wayland-backend", ] @@ -6544,7 +6568,7 @@ version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0781cf46869b37e36928f7b432273c0995aa8aed9552c556fb18754420541efc" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "wayland-backend", "wayland-client", "wayland-scanner", @@ -6556,7 +6580,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ccaacc76703fefd6763022ac565b590fcade92202492381c95b2edfdf7d46b3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6569,7 +6593,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248a02e6f595aad796561fa82d25601bd2c8c3b145b1c7453fc8f94c1a58f8b2" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6695,7 +6719,7 @@ checksum = "d63c3c478de8e7e01786479919c8769f62a22eec16788d8c2ac77ce2c132778a" dependencies = [ "arrayvec", "bit-vec", - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg_aliases 0.1.1", "document-features", "indexmap", @@ -6722,7 +6746,7 @@ dependencies = [ "arrayvec", "ash", "bit-set", - "bitflags 2.8.0", + "bitflags 2.9.0", "block", "bytemuck", "cfg_aliases 0.1.1", @@ -6763,7 +6787,7 @@ version = "23.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610f6ff27778148c31093f3b03abc4840f9636d58d597ca2f5977433acfe0068" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "js-sys", "web-sys", ] @@ -6911,6 +6935,12 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-link" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3" + [[package]] name = "windows-registry" version = "0.2.0" @@ -7172,7 +7202,7 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.8.0", + "bitflags 2.9.0", "block2", "bytemuck", "calloop", @@ -7217,9 +7247,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" +checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" dependencies = [ "memchr", ] @@ -7240,7 +7270,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -7309,7 +7339,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "dlib", "log", "once_cell", @@ -7460,11 +7490,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.18" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79386d31a42a4996e3336b0919ddb90f81112af416270cff95b5f5af22b839c2" +checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" dependencies = [ - "zerocopy-derive 0.8.18", + "zerocopy-derive 0.8.23", ] [[package]] @@ -7480,9 +7510,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.18" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76331675d372f91bf8d17e13afbd5fe639200b73d01f0fc748bb059f9cca2db7" +checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" dependencies = [ "proc-macro2", "quote", @@ -7491,18 +7521,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", From 86e8494bfa460bdbf506695f8f4b4f01a9cf5088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 9 Mar 2025 01:28:35 +0100 Subject: [PATCH 03/11] Reuse `wgpu` device in all benchmarks --- benches/wgpu.rs | 80 ++++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/benches/wgpu.rs b/benches/wgpu.rs index de19c4cf..033eb46d 100644 --- a/benches/wgpu.rs +++ b/benches/wgpu.rs @@ -8,44 +8,15 @@ use iced::{ Color, Element, Font, Length, Pixels, Point, Rectangle, Size, Theme, }; use iced_wgpu::Renderer; +use iced_wgpu::wgpu; criterion_main!(benches); criterion_group!(benches, wgpu_benchmark); #[allow(unused_results)] pub fn wgpu_benchmark(c: &mut Criterion) { - c.bench_function("wgpu — canvas (light)", |b| { - benchmark(b, |_| scene(10)); - }); - c.bench_function("wgpu — canvas (heavy)", |b| { - benchmark(b, |_| scene(1_000)); - }); - - c.bench_function("wgpu - layered text (light)", |b| { - benchmark(b, |_| layered_text(10)); - }); - c.bench_function("wgpu - layered text (heavy)", |b| { - benchmark(b, |_| layered_text(1_000)); - }); - - c.bench_function("wgpu - dynamic text (light)", |b| { - benchmark(b, |i| dynamic_text(1_000, i)); - }); - c.bench_function("wgpu - dynamic text (heavy)", |b| { - benchmark(b, |i| dynamic_text(100_000, i)); - }); -} - -fn benchmark<'a>( - bencher: &mut Bencher<'_>, - view: impl Fn(usize) -> Element<'a, (), Theme, Renderer>, -) { use iced_futures::futures::executor; - use iced_wgpu::graphics; - use iced_wgpu::graphics::Antialiasing; use iced_wgpu::wgpu; - use iced_winit::core; - use iced_winit::runtime; let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { backends: wgpu::Backends::all(), @@ -72,18 +43,53 @@ fn benchmark<'a>( )) .expect("request device"); + c.bench_function("wgpu — canvas (light)", |b| { + benchmark(b, &adapter, &device, &queue, |_| scene(10)); + }); + c.bench_function("wgpu — canvas (heavy)", |b| { + benchmark(b, &adapter, &device, &queue, |_| scene(1_000)); + }); + + c.bench_function("wgpu - layered text (light)", |b| { + benchmark(b, &adapter, &device, &queue, |_| layered_text(10)); + }); + c.bench_function("wgpu - layered text (heavy)", |b| { + benchmark(b, &adapter, &device, &queue, |_| layered_text(1_000)); + }); + + c.bench_function("wgpu - dynamic text (light)", |b| { + benchmark(b, &adapter, &device, &queue, |i| dynamic_text(1_000, i)); + }); + c.bench_function("wgpu - dynamic text (heavy)", |b| { + benchmark(b, &adapter, &device, &queue, |i| dynamic_text(100_000, i)); + }); +} + +fn benchmark<'a>( + bencher: &mut Bencher<'_>, + adapter: &wgpu::Adapter, + device: &wgpu::Device, + queue: &wgpu::Queue, + view: impl Fn(usize) -> Element<'a, (), Theme, Renderer>, +) { + use iced_wgpu::graphics; + use iced_wgpu::graphics::Antialiasing; + use iced_wgpu::wgpu; + use iced_winit::core; + use iced_winit::runtime; + let format = wgpu::TextureFormat::Bgra8UnormSrgb; let mut engine = iced_wgpu::Engine::new( - &adapter, - &device, - &queue, + adapter, + device, + queue, format, Some(Antialiasing::MSAAx4), ); let mut renderer = - Renderer::new(&device, &engine, Font::DEFAULT, Pixels::from(16)); + Renderer::new(device, &engine, Font::DEFAULT, Pixels::from(16)); let viewport = graphics::Viewport::with_physical_size(Size::new(3840, 2160), 2.0); @@ -135,8 +141,8 @@ fn benchmark<'a>( renderer.present::<&str>( &mut engine, - &device, - &queue, + device, + queue, &mut encoder, Some(Color::BLACK), format, @@ -145,7 +151,7 @@ fn benchmark<'a>( &[], ); - let submission = engine.submit(&queue, encoder); + let submission = engine.submit(queue, encoder); let _ = device.poll(wgpu::Maintain::WaitForSubmissionIndex(submission)); i += 1; From fb2544021a40d029a99cadda7cf59acf5e7dc455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 9 Mar 2025 01:38:34 +0100 Subject: [PATCH 04/11] Update `wgpu` to `24` and use `cryoglyph` fork Co-authored-by: Winfried Baumann --- Cargo.lock | 118 ++++++++++++++++++++----------- Cargo.toml | 4 +- benches/wgpu.rs | 2 +- examples/integration/src/main.rs | 5 +- graphics/src/compositor.rs | 3 + wgpu/Cargo.toml | 2 +- wgpu/src/image/atlas.rs | 10 +-- wgpu/src/text.rs | 56 +++++++-------- wgpu/src/window/compositor.rs | 16 +++-- 9 files changed, 126 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25fe2b77..2ad1bd35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -620,6 +620,9 @@ name = "bitflags" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +dependencies = [ + "serde", +] [[package]] name = "bitstream-io" @@ -807,12 +810,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - [[package]] name = "cfg_aliases" version = "0.2.1" @@ -1214,6 +1211,18 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" +[[package]] +name = "cryoglyph" +version = "0.1.0" +source = "git+https://github.com/iced-rs/cryoglyph.git?rev=a886f2427e612b23788a4e36658ff8cd55ba6695#a886f2427e612b23788a4e36658ff8cd55ba6695" +dependencies = [ + "cosmic-text", + "etagere", + "lru", + "rustc-hash 2.1.1", + "wgpu", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -2054,9 +2063,9 @@ dependencies = [ [[package]] name = "glow" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483" +checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" dependencies = [ "js-sys", "slotmap", @@ -2073,18 +2082,6 @@ dependencies = [ "gl_generator", ] -[[package]] -name = "glyphon" -version = "0.5.0" -source = "git+https://github.com/hecrj/glyphon.git?rev=09712a70df7431e9a3b1ac1bbd4fb634096cb3b4#09712a70df7431e9a3b1ac1bbd4fb634096cb3b4" -dependencies = [ - "cosmic-text", - "etagere", - "lru", - "rustc-hash 2.1.1", - "wgpu", -] - [[package]] name = "gobject-sys" version = "0.18.0" @@ -2635,9 +2632,9 @@ version = "0.14.0-dev" dependencies = [ "bitflags 2.9.0", "bytemuck", + "cryoglyph", "futures", "glam", - "glyphon", "guillotiere", "iced_graphics", "log", @@ -3371,9 +3368,9 @@ dependencies = [ [[package]] name = "metal" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" +checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e" dependencies = [ "bitflags 2.9.0", "block", @@ -3476,22 +3473,23 @@ checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" [[package]] name = "naga" -version = "23.1.0" +version = "24.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364f94bc34f61332abebe8cad6f6cd82a5b65cff22c828d05d0968911462ca4f" +checksum = "e380993072e52eef724eddfcde0ed013b0c023c3f0417336ed041aa9f076994e" dependencies = [ "arrayvec", "bit-set", "bitflags 2.9.0", - "cfg_aliases 0.1.1", + "cfg_aliases", "codespan-reporting", "hexf-parse", "indexmap", "log", "rustc-hash 1.1.0", "spirv", + "strum", "termcolor", - "thiserror 1.0.69", + "thiserror 2.0.12", "unicode-xid", ] @@ -3565,7 +3563,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.9.0", "cfg-if", - "cfg_aliases 0.2.1", + "cfg_aliases", "libc", "memoffset", ] @@ -4038,6 +4036,15 @@ dependencies = [ "libredox", ] +[[package]] +name = "ordered-float" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -5390,7 +5397,7 @@ checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08" dependencies = [ "as-raw-xcb-connection", "bytemuck", - "cfg_aliases 0.2.1", + "cfg_aliases", "core-graphics 0.24.0", "drm", "fastrand 2.3.0", @@ -5466,6 +5473,28 @@ dependencies = [ "float-cmp", ] +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "styling" version = "0.1.0" @@ -6688,12 +6717,13 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "wgpu" -version = "23.0.1" +version = "24.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f70000db37c469ea9d67defdc13024ddf9a5f1b89cb2941b812ad7cde1735a" +checksum = "47f55718f85c2fa756edffa0e7f0e0a60aba463d1362b57e23123c58f035e4b6" dependencies = [ "arrayvec", - "cfg_aliases 0.1.1", + "bitflags 2.9.0", + "cfg_aliases", "document-features", "js-sys", "log", @@ -6713,14 +6743,14 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "23.0.1" +version = "24.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d63c3c478de8e7e01786479919c8769f62a22eec16788d8c2ac77ce2c132778a" +checksum = "671c25545d479b47d3f0a8e373aceb2060b67c6eb841b24ac8c32348151c7a0c" dependencies = [ "arrayvec", "bit-vec", "bitflags 2.9.0", - "cfg_aliases 0.1.1", + "cfg_aliases", "document-features", "indexmap", "log", @@ -6731,16 +6761,16 @@ dependencies = [ "raw-window-handle 0.6.2", "rustc-hash 1.1.0", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", "wgpu-hal", "wgpu-types", ] [[package]] name = "wgpu-hal" -version = "23.0.1" +version = "24.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89364b8a0b211adc7b16aeaf1bd5ad4a919c1154b44c9ce27838213ba05fd821" +checksum = "4317a17171dc20e6577bf606796794580accae0716a69edbc7388c86a3ec9f23" dependencies = [ "android_system_properties", "arrayvec", @@ -6749,7 +6779,7 @@ dependencies = [ "bitflags 2.9.0", "block", "bytemuck", - "cfg_aliases 0.1.1", + "cfg_aliases", "core-graphics-types 0.1.3", "glow", "glutin_wgl_sys", @@ -6766,6 +6796,7 @@ dependencies = [ "ndk-sys 0.5.0+25.2.9519653", "objc", "once_cell", + "ordered-float", "parking_lot", "profiling", "range-alloc", @@ -6773,7 +6804,7 @@ dependencies = [ "renderdoc-sys", "rustc-hash 1.1.0", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.12", "wasm-bindgen", "web-sys", "wgpu-types", @@ -6783,12 +6814,13 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "23.0.0" +version = "24.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610f6ff27778148c31093f3b03abc4840f9636d58d597ca2f5977433acfe0068" +checksum = "50ac044c0e76c03a0378e7786ac505d010a873665e2d51383dcff8dd227dc69c" dependencies = [ "bitflags 2.9.0", "js-sys", + "log", "web-sys", ] @@ -7206,7 +7238,7 @@ dependencies = [ "block2", "bytemuck", "calloop", - "cfg_aliases 0.2.1", + "cfg_aliases", "concurrent-queue", "core-foundation 0.9.4", "core-graphics 0.23.2", diff --git a/Cargo.toml b/Cargo.toml index f1e9babf..47fe83b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -152,7 +152,7 @@ cosmic-text = "0.12" dark-light = "2.0" futures = "0.3" glam = "0.25" -glyphon = { git = "https://github.com/hecrj/glyphon.git", rev = "09712a70df7431e9a3b1ac1bbd4fb634096cb3b4" } +cryoglyph = { git = "https://github.com/iced-rs/cryoglyph.git", rev = "a886f2427e612b23788a4e36658ff8cd55ba6695" } guillotiere = "0.6" half = "2.2" image = { version = "0.25", default-features = false } @@ -188,7 +188,7 @@ wasm-bindgen-futures = "0.4" wasmtimer = "0.4.1" web-sys = "0.3.69" web-time = "1.1" -wgpu = "23.0" +wgpu = "24.0" window_clipboard = "0.4.1" winit = { git = "https://github.com/iced-rs/winit.git", rev = "11414b6aa45699f038114e61b4ddf5102b2d3b4b" } diff --git a/benches/wgpu.rs b/benches/wgpu.rs index 033eb46d..c920a71e 100644 --- a/benches/wgpu.rs +++ b/benches/wgpu.rs @@ -18,7 +18,7 @@ pub fn wgpu_benchmark(c: &mut Criterion) { use iced_futures::futures::executor; use iced_wgpu::wgpu; - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { backends: wgpu::Backends::all(), ..Default::default() }); diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 386e0f70..7c5388ab 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -70,10 +70,9 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { ); let clipboard = Clipboard::connect(window.clone()); - let backend = - wgpu::util::backend_bits_from_env().unwrap_or_default(); + let backend = wgpu::Backends::from_env().unwrap_or_default(); - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { backends: backend, ..Default::default() }); diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs index df3d41c3..363d651d 100644 --- a/graphics/src/compositor.rs +++ b/graphics/src/compositor.rs @@ -132,6 +132,9 @@ pub enum SurfaceError { /// There is no more memory left to allocate a new frame. #[error("There is no more memory left to allocate a new frame")] OutOfMemory, + /// Acquiring a texture failed with a generic error. + #[error("Acquiring a texture failed with a generic error")] + Other, } /// Contains information about the graphics (e.g. graphics adapter, graphics backend). diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 4b6b0483..50c9f588 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -32,7 +32,7 @@ bitflags.workspace = true bytemuck.workspace = true futures.workspace = true glam.workspace = true -glyphon.workspace = true +cryoglyph.workspace = true guillotiere.workspace = true log.workspace = true rustc-hash.workspace = true diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index a1ec0d7b..3cede8b6 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -344,15 +344,15 @@ impl Atlas { }); encoder.copy_buffer_to_texture( - wgpu::ImageCopyBuffer { + wgpu::TexelCopyBufferInfo { buffer: &buffer, - layout: wgpu::ImageDataLayout { + layout: wgpu::TexelCopyBufferLayout { offset: offset as u64, bytes_per_row: Some(4 * image_width + padding), rows_per_image: Some(image_height), }, }, - wgpu::ImageCopyTexture { + wgpu::TexelCopyTextureInfo { texture: &self.texture, mip_level: 0, origin: wgpu::Origin3d { @@ -407,7 +407,7 @@ impl Atlas { } encoder.copy_texture_to_texture( - wgpu::ImageCopyTexture { + wgpu::TexelCopyTextureInfo { texture: &self.texture, mip_level: 0, origin: wgpu::Origin3d { @@ -417,7 +417,7 @@ impl Atlas { }, aspect: wgpu::TextureAspect::default(), }, - wgpu::ImageCopyTexture { + wgpu::TexelCopyTextureInfo { texture: &new_texture, mip_level: 0, origin: wgpu::Origin3d { diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 33fbd4dc..274cc4b7 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -12,10 +12,10 @@ use std::sync::{self, Arc}; pub use crate::graphics::Text; -const COLOR_MODE: glyphon::ColorMode = if color::GAMMA_CORRECTION { - glyphon::ColorMode::Accurate +const COLOR_MODE: cryoglyph::ColorMode = if color::GAMMA_CORRECTION { + cryoglyph::ColorMode::Accurate } else { - glyphon::ColorMode::Web + cryoglyph::ColorMode::Web }; pub type Batch = Vec; @@ -70,7 +70,7 @@ impl Cache { } struct Upload { - renderer: glyphon::TextRenderer, + renderer: cryoglyph::TextRenderer, buffer_cache: BufferCache, transformation: Transformation, version: usize, @@ -86,7 +86,7 @@ pub struct Storage { } struct Group { - atlas: glyphon::TextAtlas, + atlas: cryoglyph::TextAtlas, version: usize, should_trim: bool, handle: Arc<()>, // Keeps track of active uploads @@ -97,7 +97,7 @@ impl Storage { Self::default() } - fn get(&self, cache: &Cache) -> Option<(&glyphon::TextAtlas, &Upload)> { + fn get(&self, cache: &Cache) -> Option<(&cryoglyph::TextAtlas, &Upload)> { if cache.text.is_empty() { return None; } @@ -112,10 +112,10 @@ impl Storage { &mut self, device: &wgpu::Device, queue: &wgpu::Queue, - viewport: &glyphon::Viewport, + viewport: &cryoglyph::Viewport, encoder: &mut wgpu::CommandEncoder, format: wgpu::TextureFormat, - state: &glyphon::Cache, + state: &cryoglyph::Cache, cache: &Cache, new_transformation: Transformation, bounds: Rectangle, @@ -130,7 +130,7 @@ impl Storage { ); Group { - atlas: glyphon::TextAtlas::with_color_mode( + atlas: cryoglyph::TextAtlas::with_color_mode( device, queue, state, format, COLOR_MODE, ), version: 0, @@ -175,7 +175,7 @@ impl Storage { } } hash_map::Entry::Vacant(entry) => { - let mut renderer = glyphon::TextRenderer::new( + let mut renderer = cryoglyph::TextRenderer::new( &mut group.atlas, device, wgpu::MultisampleState::default(), @@ -257,13 +257,13 @@ impl Storage { } } -pub struct Viewport(glyphon::Viewport); +pub struct Viewport(cryoglyph::Viewport); impl Viewport { pub fn update(&mut self, queue: &wgpu::Queue, resolution: Size) { self.0.update( queue, - glyphon::Resolution { + cryoglyph::Resolution { width: resolution.width, height: resolution.height, }, @@ -273,10 +273,10 @@ impl Viewport { #[allow(missing_debug_implementations)] pub struct Pipeline { - state: glyphon::Cache, + state: cryoglyph::Cache, format: wgpu::TextureFormat, - atlas: glyphon::TextAtlas, - renderers: Vec, + atlas: cryoglyph::TextAtlas, + renderers: Vec, prepare_layer: usize, cache: BufferCache, } @@ -287,8 +287,8 @@ impl Pipeline { queue: &wgpu::Queue, format: wgpu::TextureFormat, ) -> Self { - let state = glyphon::Cache::new(device); - let atlas = glyphon::TextAtlas::with_color_mode( + let state = cryoglyph::Cache::new(device); + let atlas = cryoglyph::TextAtlas::with_color_mode( device, queue, &state, format, COLOR_MODE, ); @@ -320,7 +320,7 @@ impl Pipeline { text, } => { if self.renderers.len() <= self.prepare_layer { - self.renderers.push(glyphon::TextRenderer::new( + self.renderers.push(cryoglyph::TextRenderer::new( &mut self.atlas, device, wgpu::MultisampleState::default(), @@ -346,7 +346,7 @@ impl Pipeline { Ok(()) => { self.prepare_layer += 1; } - Err(glyphon::PrepareError::AtlasFull) => { + Err(cryoglyph::PrepareError::AtlasFull) => { // If the atlas cannot grow, then all bets are off. // Instead of panicking, we will just pray that the result // will be somewhat readable... @@ -417,7 +417,7 @@ impl Pipeline { } pub fn create_viewport(&self, device: &wgpu::Device) -> Viewport { - Viewport(glyphon::Viewport::new(device, &self.state)) + Viewport(cryoglyph::Viewport::new(device, &self.state)) } pub fn end_frame(&mut self) { @@ -431,15 +431,15 @@ impl Pipeline { fn prepare( device: &wgpu::Device, queue: &wgpu::Queue, - viewport: &glyphon::Viewport, + viewport: &cryoglyph::Viewport, encoder: &mut wgpu::CommandEncoder, - renderer: &mut glyphon::TextRenderer, - atlas: &mut glyphon::TextAtlas, + renderer: &mut cryoglyph::TextRenderer, + atlas: &mut cryoglyph::TextAtlas, buffer_cache: &mut BufferCache, sections: &[Text], layer_bounds: Rectangle, layer_transformation: Transformation, -) -> Result<(), glyphon::PrepareError> { +) -> Result<(), cryoglyph::PrepareError> { let mut font_system = font_system().write().expect("Write font system"); let font_system = font_system.raw(); @@ -447,7 +447,7 @@ fn prepare( Paragraph(Paragraph), Editor(Editor), Cache(text_cache::KeyHash), - Raw(Arc), + Raw(Arc), } let allocations: Vec<_> = sections @@ -618,13 +618,13 @@ fn prepare( &(clip_bounds * transformation * layer_transformation), )?; - Some(glyphon::TextArea { + Some(cryoglyph::TextArea { buffer, left, top, scale: transformation.scale_factor() * layer_transformation.scale_factor(), - bounds: glyphon::TextBounds { + bounds: cryoglyph::TextBounds { left: clip_bounds.x as i32, top: clip_bounds.y as i32, right: (clip_bounds.x + clip_bounds.width) as i32, @@ -643,6 +643,6 @@ fn prepare( atlas, viewport, text_areas, - &mut glyphon::SwashCache::new(), + &mut cryoglyph::SwashCache::new(), ) } diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 4fe689cf..bc932b44 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -54,7 +54,7 @@ impl Compositor { settings: Settings, compatible_window: Option, ) -> Result { - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { backends: settings.backends, flags: if cfg!(feature = "strict-assertions") { wgpu::InstanceFlags::debugging() @@ -81,12 +81,13 @@ impl Compositor { .and_then(|window| instance.create_surface(window).ok()); let adapter_options = wgpu::RequestAdapterOptions { - power_preference: wgpu::util::power_preference_from_env() - .unwrap_or(if settings.antialiasing.is_none() { + power_preference: wgpu::PowerPreference::from_env().unwrap_or( + if settings.antialiasing.is_none() { wgpu::PowerPreference::LowPower } else { wgpu::PowerPreference::HighPerformance - }), + }, + ), compatible_surface: compatible_surface.as_ref(), force_fallback_adapter: false, }; @@ -263,6 +264,7 @@ pub fn present>( wgpu::SurfaceError::OutOfMemory => { Err(compositor::SurfaceError::OutOfMemory) } + wgpu::SurfaceError::Other => Err(compositor::SurfaceError::Other), }, } } @@ -280,7 +282,7 @@ impl graphics::Compositor for Compositor { None | Some("wgpu") => { let mut settings = Settings::from(settings); - if let Some(backends) = wgpu::util::backend_bits_from_env() { + if let Some(backends) = wgpu::Backends::from_env() { settings.backends = backends; } @@ -451,9 +453,9 @@ pub fn screenshot>( encoder.copy_texture_to_buffer( texture.as_image_copy(), - wgpu::ImageCopyBuffer { + wgpu::TexelCopyBufferInfo { buffer: &output_buffer, - layout: wgpu::ImageDataLayout { + layout: wgpu::TexelCopyBufferLayout { offset: 0, bytes_per_row: Some(dimensions.padded_bytes_per_row as u32), rows_per_image: None, From 201245a85d9bc09844b115ca1f0d53fe578c6988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 10 Mar 2025 19:45:11 +0100 Subject: [PATCH 05/11] Update `cosmic-text` to `0.13` --- Cargo.lock | 161 ++++++++++-------- Cargo.toml | 4 +- .../todos/snapshots/creates_a_new_task.sha256 | 2 +- graphics/src/text/editor.rs | 16 +- graphics/src/text/paragraph.rs | 1 + 5 files changed, 97 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ad1bd35..4f8bbe56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -651,7 +651,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "objc2", + "objc2 0.5.2", ] [[package]] @@ -918,9 +918,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7f4aaa047ba3c3630b080bb9860894732ff23e2aee290a418909aa6d5df38f" dependencies = [ - "objc2", + "objc2 0.5.2", "objc2-app-kit", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -1097,18 +1097,18 @@ dependencies = [ [[package]] name = "cosmic-text" -version = "0.12.1" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fd57d82eb4bfe7ffa9b1cec0c05e2fd378155b47f255a67983cb4afe0e80c2" +checksum = "529a7d4dccf42dd5e93dc3d2e66c7c9121b9779ac8886d2582d0df48fdfcc407" dependencies = [ "bitflags 2.9.0", "fontdb 0.16.2", "log", "rangemap", - "rayon", "rustc-hash 1.1.0", "rustybuzz", "self_cell", + "smol_str", "swash", "sys-locale", "ttf-parser 0.21.1", @@ -1214,7 +1214,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" [[package]] name = "cryoglyph" version = "0.1.0" -source = "git+https://github.com/iced-rs/cryoglyph.git?rev=a886f2427e612b23788a4e36658ff8cd55ba6695#a886f2427e612b23788a4e36658ff8cd55ba6695" +source = "git+https://github.com/iced-rs/cryoglyph.git?rev=be2defe4a13fd7c97c6f4c81e8e085463eb578dc#be2defe4a13fd7c97c6f4c81e8e085463eb578dc" dependencies = [ "cosmic-text", "etagere", @@ -1278,8 +1278,8 @@ checksum = "18e1a09f280e29a8b00bc7e81eca5ac87dca0575639c9422a5fa25a07bb884b8" dependencies = [ "ashpd", "async-std", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "web-sys", "winreg", ] @@ -1661,9 +1661,9 @@ checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "font-types" -version = "0.7.3" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3971f9a5ca983419cdc386941ba3b9e1feba01a0ab888adf78739feb2798492" +checksum = "d868ec188a98bb014c606072edd47e52e7ab7297db943b0b28503121e1d037bd" dependencies = [ "bytemuck", ] @@ -3727,6 +3727,15 @@ dependencies = [ "objc2-encode", ] +[[package]] +name = "objc2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3531f65190d9cff863b77a99857e74c314dd16bf56c538c4b57c7cbc3f3a6e59" +dependencies = [ + "objc2-encode", +] + [[package]] name = "objc2-app-kit" version = "0.2.2" @@ -3736,10 +3745,10 @@ dependencies = [ "bitflags 2.9.0", "block2", "libc", - "objc2", + "objc2 0.5.2", "objc2-core-data", "objc2-core-image", - "objc2-foundation", + "objc2-foundation 0.2.2", "objc2-quartz-core", ] @@ -3751,9 +3760,9 @@ checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ "bitflags 2.9.0", "block2", - "objc2", + "objc2 0.5.2", "objc2-core-location", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -3763,8 +3772,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" dependencies = [ "block2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -3775,8 +3784,8 @@ checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ "bitflags 2.9.0", "block2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -3786,8 +3795,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" dependencies = [ "block2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "objc2-metal", ] @@ -3798,9 +3807,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" dependencies = [ "block2", - "objc2", + "objc2 0.5.2", "objc2-contacts", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -3819,7 +3828,17 @@ dependencies = [ "block2", "dispatch", "libc", - "objc2", + "objc2 0.5.2", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a21c6c9014b82c39515db5b396f91645182611c97d24637cf56ac01e5f8d998" +dependencies = [ + "bitflags 2.9.0", + "objc2 0.6.0", ] [[package]] @@ -3829,9 +3848,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" dependencies = [ "block2", - "objc2", + "objc2 0.5.2", "objc2-app-kit", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -3842,8 +3861,8 @@ checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ "bitflags 2.9.0", "block2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -3854,8 +3873,8 @@ checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ "bitflags 2.9.0", "block2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "objc2-metal", ] @@ -3865,8 +3884,8 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" dependencies = [ - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -3877,12 +3896,12 @@ checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ "bitflags 2.9.0", "block2", - "objc2", + "objc2 0.5.2", "objc2-cloud-kit", "objc2-core-data", "objc2-core-image", "objc2-core-location", - "objc2-foundation", + "objc2-foundation 0.2.2", "objc2-link-presentation", "objc2-quartz-core", "objc2-symbols", @@ -3897,8 +3916,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" dependencies = [ "block2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -3909,9 +3928,9 @@ checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ "bitflags 2.9.0", "block2", - "objc2", + "objc2 0.5.2", "objc2-core-location", - "objc2-foundation", + "objc2-foundation 0.2.2", ] [[package]] @@ -3934,9 +3953,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad" [[package]] name = "onig" @@ -4393,11 +4412,11 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.7.35", + "zerocopy 0.8.23", ] [[package]] @@ -4693,9 +4712,9 @@ dependencies = [ [[package]] name = "read-fonts" -version = "0.22.7" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69aacb76b5c29acfb7f90155d39759a29496aebb49395830e928a9703d2eec2f" +checksum = "f6f9e8a4f503e5c8750e4cd3b32a4e090035c46374b305a15c70bad833dca05f" dependencies = [ "bytemuck", "font-types", @@ -4926,9 +4945,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dade4812df5c384711475be5fcd8c162555352945401aed22a35bffeab61f657" +checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" dependencies = [ "bitflags 2.9.0", "errno", @@ -5110,18 +5129,18 @@ checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -5268,9 +5287,9 @@ dependencies = [ [[package]] name = "skrifa" -version = "0.22.3" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1c44ad1f6c5bdd4eefed8326711b7dbda9ea45dfd36068c427d332aa382cbe" +checksum = "8cc1aa86c26dbb1b63875a7180aa0819709b33348eb5b1491e4321fae388179d" dependencies = [ "bytemuck", "read-fonts", @@ -5405,8 +5424,8 @@ dependencies = [ "js-sys", "log", "memmap2", - "objc2", - "objc2-foundation", + "objc2 0.5.2", + "objc2-foundation 0.2.2", "objc2-quartz-core", "raw-window-handle 0.6.2", "redox_syscall 0.5.10", @@ -5533,9 +5552,9 @@ dependencies = [ [[package]] name = "swash" -version = "0.1.19" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd59f3f359ddd2c95af4758c18270eddd9c730dde98598023cdabff472c2ca2" +checksum = "13d5bbc2aa266907ed8ee977c9c9e16363cc2b001266104e13397b57f1d15f71" dependencies = [ "skrifa", "yazi", @@ -5544,9 +5563,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.99" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -5676,7 +5695,7 @@ dependencies = [ "fastrand 2.3.0", "getrandom 0.3.1", "once_cell", - "rustix 1.0.1", + "rustix 1.0.2", "windows-sys 0.59.0", ] @@ -6674,18 +6693,17 @@ dependencies = [ [[package]] name = "webbrowser" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9fe1ebb156110ff855242c1101df158b822487e4957b0556d9ffce9db0f535" +checksum = "d5df295f8451142f1856b1bd86a606dfe9587d439bc036e319c827700dbd555e" dependencies = [ - "block2", "core-foundation 0.10.0", "home", "jni", "log", "ndk-context", - "objc2", - "objc2-foundation", + "objc2 0.6.0", + "objc2-foundation 0.3.0", "url", "web-sys", ] @@ -7248,9 +7266,9 @@ dependencies = [ "libc", "memmap2", "ndk", - "objc2", + "objc2 0.5.2", "objc2-app-kit", - "objc2-foundation", + "objc2-foundation 0.2.2", "objc2-ui-kit", "orbclient", "percent-encoding", @@ -7413,9 +7431,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yazi" -version = "0.1.6" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94451ac9513335b5e23d7a8a2b61a7102398b8cca5160829d313e84c9d98be1" +checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5" [[package]] name = "yoke" @@ -7506,9 +7524,9 @@ dependencies = [ [[package]] name = "zeno" -version = "0.2.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd15f8e0dbb966fd9245e7498c7e9e5055d9e5c8b676b95bd67091cd11a1e697" +checksum = "cc0de2315dc13d00e5df3cd6b8d2124a6eaec6a2d4b6a1c5f37b7efad17fcc17" [[package]] name = "zerocopy" @@ -7516,7 +7534,6 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "byteorder", "zerocopy-derive 0.7.35", ] diff --git a/Cargo.toml b/Cargo.toml index 47fe83b0..7e8bbc34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,11 +148,11 @@ async-std = "1.0" bitflags = "2.0" bytemuck = { version = "1.0", features = ["derive"] } bytes = "1.6" -cosmic-text = "0.12" +cosmic-text = "0.13" dark-light = "2.0" futures = "0.3" glam = "0.25" -cryoglyph = { git = "https://github.com/iced-rs/cryoglyph.git", rev = "a886f2427e612b23788a4e36658ff8cd55ba6695" } +cryoglyph = { git = "https://github.com/iced-rs/cryoglyph.git", rev = "be2defe4a13fd7c97c6f4c81e8e085463eb578dc" } guillotiere = "0.6" half = "2.2" image = { version = "0.25", default-features = false } diff --git a/examples/todos/snapshots/creates_a_new_task.sha256 b/examples/todos/snapshots/creates_a_new_task.sha256 index cba60539..f62b2f69 100644 --- a/examples/todos/snapshots/creates_a_new_task.sha256 +++ b/examples/todos/snapshots/creates_a_new_task.sha256 @@ -1 +1 @@ -0ef7325a79ce31c83759529ed478c8b4848c40c2867193624ef9673b9e21ff53 \ No newline at end of file +0e355b080ad33905145e9f70a3b29e2481197c8fc8f42491acd5358238ebbd5f \ No newline at end of file diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 765de07e..ca62abcf 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -178,10 +178,8 @@ impl editor::Editor for Editor { .get(cursor.line) .expect("Cursor line should be present"); - let layout = line - .layout_opt() - .as_ref() - .expect("Line layout should be cached"); + let layout = + line.layout_opt().expect("Line layout should be cached"); let mut lines = layout.iter().enumerate(); @@ -706,11 +704,7 @@ fn highlight_line( from: usize, to: usize, ) -> impl Iterator + '_ { - let layout = line - .layout_opt() - .as_ref() - .map(Vec::as_slice) - .unwrap_or_default(); + let layout = line.layout_opt().map(Vec::as_slice).unwrap_or_default(); layout.iter().map(move |visual_line| { let start = visual_line @@ -761,9 +755,7 @@ fn visual_lines_offset(line: usize, buffer: &cosmic_text::Buffer) -> i32 { let visual_lines_offset: usize = buffer.lines[start..] .iter() .take(end - start) - .map(|line| { - line.layout_opt().as_ref().map(Vec::len).unwrap_or_default() - }) + .map(|line| line.layout_opt().map(Vec::len).unwrap_or_default()) .sum(); visual_lines_offset as i32 * if scroll.line < line { 1 } else { -1 } diff --git a/graphics/src/text/paragraph.rs b/graphics/src/text/paragraph.rs index 48c8e9e6..50afef1f 100644 --- a/graphics/src/text/paragraph.rs +++ b/graphics/src/text/paragraph.rs @@ -156,6 +156,7 @@ impl core::text::Paragraph for Paragraph { }), text::to_attributes(text.font), text::to_shaping(text.shaping), + None, ); let min_bounds = text::measure(&buffer); From 179a34d37b239204cefe7b3014f79cf1f3ba9936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 11 Mar 2025 00:43:51 +0100 Subject: [PATCH 06/11] Fix horizontal text alignment --- core/src/renderer/null.rs | 4 +-- core/src/text.rs | 2 +- core/src/text/paragraph.rs | 4 +-- core/src/widget/text.rs | 14 ++++---- graphics/src/geometry/text.rs | 3 ++ graphics/src/text.rs | 34 ++++++++++++------ graphics/src/text/cache.rs | 11 +++++- graphics/src/text/editor.rs | 5 ++- graphics/src/text/paragraph.rs | 54 +++++++++++++++++++++++++---- tiny_skia/src/geometry.rs | 2 +- tiny_skia/src/text.rs | 14 ++++---- wgpu/src/geometry.rs | 2 +- wgpu/src/lib.rs | 2 +- wgpu/src/text.rs | 12 ++++--- widget/src/checkbox.rs | 6 ++-- widget/src/overlay/menu.rs | 2 +- widget/src/pick_list.rs | 6 ++-- widget/src/radio.rs | 2 +- widget/src/text/rich.rs | 8 ++--- widget/src/text_editor.rs | 2 +- widget/src/text_input.rs | 6 ++-- widget/src/toggler.rs | 11 +++--- winit/src/program/window_manager.rs | 2 +- 23 files changed, 141 insertions(+), 67 deletions(-) diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index 5732c41b..7fc28bc0 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -87,8 +87,8 @@ impl text::Paragraph for () { text::Difference::None } - fn horizontal_alignment(&self) -> alignment::Horizontal { - alignment::Horizontal::Left + fn horizontal_alignment(&self) -> Option { + None } fn vertical_alignment(&self) -> alignment::Vertical { diff --git a/core/src/text.rs b/core/src/text.rs index a7e1f281..5cffe2b2 100644 --- a/core/src/text.rs +++ b/core/src/text.rs @@ -34,7 +34,7 @@ pub struct Text { pub font: Font, /// The horizontal alignment of the [`Text`]. - pub horizontal_alignment: alignment::Horizontal, + pub horizontal_alignment: Option, /// The vertical alignment of the [`Text`]. pub vertical_alignment: alignment::Vertical, diff --git a/core/src/text/paragraph.rs b/core/src/text/paragraph.rs index 700c2c75..99d8da20 100644 --- a/core/src/text/paragraph.rs +++ b/core/src/text/paragraph.rs @@ -24,7 +24,7 @@ pub trait Paragraph: Sized + Default { fn compare(&self, text: Text<(), Self::Font>) -> Difference; /// Returns the horizontal alignment of the [`Paragraph`]. - fn horizontal_alignment(&self) -> alignment::Horizontal; + fn horizontal_alignment(&self) -> Option; /// Returns the vertical alignment of the [`Paragraph`]. fn vertical_alignment(&self) -> alignment::Vertical; @@ -108,7 +108,7 @@ impl Plain

{ } /// Returns the horizontal alignment of the [`Paragraph`]. - pub fn horizontal_alignment(&self) -> alignment::Horizontal { + pub fn horizontal_alignment(&self) -> Option { self.raw.horizontal_alignment() } diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index 9a00fcdb..fe9a8a81 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -67,7 +67,7 @@ where line_height: LineHeight, width: Length, height: Length, - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, vertical_alignment: alignment::Vertical, font: Option, shaping: Shaping, @@ -89,7 +89,7 @@ where font: None, width: Length::Shrink, height: Length::Shrink, - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Top, shaping: Shaping::default(), wrapping: Wrapping::default(), @@ -140,7 +140,7 @@ where mut self, alignment: impl Into, ) -> Self { - self.horizontal_alignment = alignment.into(); + self.horizontal_alignment = Some(alignment.into()); self } @@ -290,7 +290,7 @@ pub fn layout( line_height: LineHeight, size: Option, font: Option, - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, vertical_alignment: alignment::Vertical, shaping: Shaping, wrapping: Wrapping, @@ -345,9 +345,9 @@ pub fn draw( let bounds = layout.bounds(); let x = match paragraph.horizontal_alignment() { - alignment::Horizontal::Left => bounds.x, - alignment::Horizontal::Center => bounds.center_x(), - alignment::Horizontal::Right => bounds.x + bounds.width, + None | Some(alignment::Horizontal::Left) => bounds.x, + Some(alignment::Horizontal::Center) => bounds.center_x(), + Some(alignment::Horizontal::Right) => bounds.x + bounds.width, }; let y = match paragraph.vertical_alignment() { diff --git a/graphics/src/geometry/text.rs b/graphics/src/geometry/text.rs index 90147f87..f8ac357d 100644 --- a/graphics/src/geometry/text.rs +++ b/graphics/src/geometry/text.rs @@ -10,11 +10,14 @@ pub struct Text { /// The contents of the text pub content: String, /// The position of the text relative to the alignment properties. + /// /// By default, this position will be relative to the top-left corner coordinate meaning that /// if the horizontal and vertical alignments are unchanged, this property will tell where the /// top-left corner of the text should be placed. + /// /// By changing the horizontal_alignment and vertical_alignment properties, you are are able to /// change what part of text is placed at this positions. + /// /// For example, when the horizontal_alignment and vertical_alignment are set to Center, the /// center of the text will be placed at the given position NOT the top-left coordinate. pub position: Point, diff --git a/graphics/src/text.rs b/graphics/src/text.rs index 7694ff1f..3731cdda 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -54,7 +54,7 @@ pub enum Text { /// The font of the text. font: Font, /// The horizontal alignment of the text. - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, /// The vertical alignment of the text. vertical_alignment: alignment::Vertical, /// The shaping strategy of the text. @@ -84,7 +84,7 @@ impl Text { Rectangle::new(*position, paragraph.min_bounds) .intersection(clip_bounds) .map(|bounds| bounds * *transformation), - Some(paragraph.horizontal_alignment), + paragraph.horizontal_alignment, Some(paragraph.vertical_alignment), ), Text::Editor { @@ -108,7 +108,7 @@ impl Text { .. } => ( bounds.intersection(clip_bounds), - Some(*horizontal_alignment), + *horizontal_alignment, Some(*vertical_alignment), ), Text::Raw { raw, .. } => (Some(raw.clip_bounds), None, None), @@ -242,15 +242,19 @@ impl PartialEq for Raw { } /// Measures the dimensions of the given [`cosmic_text::Buffer`]. -pub fn measure(buffer: &cosmic_text::Buffer) -> Size { - let (width, height) = - buffer - .layout_runs() - .fold((0.0, 0.0), |(width, height), run| { - (run.line_w.max(width), height + run.line_height) - }); +pub fn measure(buffer: &cosmic_text::Buffer) -> (Size, bool) { + let (width, height, has_rtl) = buffer.layout_runs().fold( + (0.0, 0.0, false), + |(width, height, has_rtl), run| { + ( + run.line_w.max(width), + height + run.line_height, + has_rtl || run.rtl, + ) + }, + ); - Size::new(width, height) + (Size::new(width, height), has_rtl) } /// Returns the attributes of the given [`Font`]. @@ -309,6 +313,14 @@ fn to_style(style: font::Style) -> cosmic_text::Style { } } +fn to_align(alignment: alignment::Horizontal) -> cosmic_text::Align { + match alignment { + alignment::Horizontal::Left => cosmic_text::Align::Left, + alignment::Horizontal::Center => cosmic_text::Align::Center, + alignment::Horizontal::Right => cosmic_text::Align::Right, + } +} + /// Converts some [`Shaping`] strategy to a [`cosmic_text::Shaping`] strategy. pub fn to_shaping(shaping: Shaping) -> cosmic_text::Shaping { match shaping { diff --git a/graphics/src/text/cache.rs b/graphics/src/text/cache.rs index e64d93f1..19ff9f61 100644 --- a/graphics/src/text/cache.rs +++ b/graphics/src/text/cache.rs @@ -58,7 +58,16 @@ impl Cache { text::to_shaping(key.shaping), ); - let bounds = text::measure(&buffer); + let (bounds, has_rtl) = text::measure(&buffer); + + if has_rtl { + buffer.set_size( + font_system, + Some(bounds.width), + Some(bounds.height), + ); + } + let _ = entry.insert(Entry { buffer, min_bounds: bounds, diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index ca62abcf..214701e0 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -450,7 +450,10 @@ impl editor::Editor for Editor { fn min_bounds(&self) -> Size { let internal = self.internal(); - text::measure(buffer_from_editor(&internal.editor)) + let (bounds, _has_rtl) = + text::measure(buffer_from_editor(&internal.editor)); + + bounds } fn update( diff --git a/graphics/src/text/paragraph.rs b/graphics/src/text/paragraph.rs index 50afef1f..747bec59 100644 --- a/graphics/src/text/paragraph.rs +++ b/graphics/src/text/paragraph.rs @@ -18,7 +18,7 @@ struct Internal { font: Font, shaping: Shaping, wrapping: Wrapping, - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, vertical_alignment: alignment::Vertical, bounds: Size, min_bounds: Size, @@ -89,7 +89,8 @@ impl core::text::Paragraph for Paragraph { text::to_shaping(text.shaping), ); - let min_bounds = text::measure(&buffer); + let min_bounds = + align(&mut buffer, &mut font_system, text.horizontal_alignment); Self(Arc::new(Internal { buffer, @@ -159,7 +160,8 @@ impl core::text::Paragraph for Paragraph { None, ); - let min_bounds = text::measure(&buffer); + let min_bounds = + align(&mut buffer, &mut font_system, text.horizontal_alignment); Self(Arc::new(Internal { buffer, @@ -186,8 +188,10 @@ impl core::text::Paragraph for Paragraph { Some(new_bounds.height), ); + let (min_bounds, _has_rtl) = text::measure(¶graph.buffer); + paragraph.bounds = new_bounds; - paragraph.min_bounds = text::measure(¶graph.buffer); + paragraph.min_bounds = min_bounds; } fn compare(&self, text: Text<()>) -> core::text::Difference { @@ -212,7 +216,7 @@ impl core::text::Paragraph for Paragraph { } } - fn horizontal_alignment(&self) -> alignment::Horizontal { + fn horizontal_alignment(&self) -> Option { self.internal().horizontal_alignment } @@ -354,6 +358,42 @@ impl core::text::Paragraph for Paragraph { } } +fn align( + buffer: &mut cosmic_text::Buffer, + font_system: &mut text::FontSystem, + align_x: Option, +) -> Size { + let (min_bounds, has_rtl) = text::measure(buffer); + let mut needs_relayout = has_rtl; + + if let Some(align_x) = align_x { + let has_multiple_lines = buffer.lines.len() > 1 + || buffer.lines.first().is_some_and(|line| { + line.layout_opt().is_some_and(|layout| layout.len() > 1) + }); + + if has_multiple_lines { + for line in &mut buffer.lines { + let _ = line.set_align(Some(text::to_align(align_x))); + } + + needs_relayout = true; + } + } + + if needs_relayout { + log::trace!("Relayouting paragraph..."); + + buffer.set_size( + font_system.raw(), + Some(min_bounds.width), + Some(min_bounds.height), + ); + } + + min_bounds +} + impl Default for Paragraph { fn default() -> Self { Self(Arc::new(Internal::default())) @@ -397,7 +437,7 @@ impl Default for Internal { font: Font::default(), shaping: Shaping::default(), wrapping: Wrapping::default(), - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Top, bounds: Size::ZERO, min_bounds: Size::ZERO, @@ -413,7 +453,7 @@ pub struct Weak { /// The minimum bounds of the [`Paragraph`]. pub min_bounds: Size, /// The horizontal alignment of the [`Paragraph`]. - pub horizontal_alignment: alignment::Horizontal, + pub horizontal_alignment: Option, /// The vertical alignment of the [`Paragraph`]. pub vertical_alignment: alignment::Vertical, } diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index dbdff444..5d8a20f7 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -231,7 +231,7 @@ impl geometry::frame::Backend for Frame { size, line_height: line_height.to_absolute(size), font: text.font, - horizontal_alignment: text.horizontal_alignment, + horizontal_alignment: Some(text.horizontal_alignment), vertical_alignment: text.vertical_alignment, shaping: text.shaping, clip_bounds: Rectangle::with_size(Size::INFINITY), diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 0fc3d1f7..499e7998 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -92,7 +92,7 @@ impl Pipeline { editor.buffer(), Rectangle::new(position, editor.bounds()), color, - alignment::Horizontal::Left, + None, alignment::Vertical::Top, pixels, clip_mask, @@ -108,7 +108,7 @@ impl Pipeline { size: Pixels, line_height: Pixels, font: Font, - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, vertical_alignment: alignment::Vertical, shaping: Shaping, pixels: &mut tiny_skia::PixmapMut<'_>, @@ -177,7 +177,7 @@ impl Pipeline { ), ), color, - alignment::Horizontal::Left, + None, alignment::Vertical::Top, pixels, clip_mask, @@ -197,7 +197,7 @@ fn draw( buffer: &cosmic_text::Buffer, bounds: Rectangle, color: Color, - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, vertical_alignment: alignment::Vertical, pixels: &mut tiny_skia::PixmapMut<'_>, clip_mask: Option<&tiny_skia::Mask>, @@ -206,9 +206,9 @@ fn draw( let bounds = bounds * transformation; let x = match horizontal_alignment { - alignment::Horizontal::Left => bounds.x, - alignment::Horizontal::Center => bounds.x - bounds.width / 2.0, - alignment::Horizontal::Right => bounds.x - bounds.width, + None | Some(alignment::Horizontal::Left) => bounds.x, + Some(alignment::Horizontal::Center) => bounds.x - bounds.width / 2.0, + Some(alignment::Horizontal::Right) => bounds.x - bounds.width, }; let y = match vertical_alignment { diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 8d161015..5a562bf5 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -336,7 +336,7 @@ impl geometry::frame::Backend for Frame { size, line_height: line_height.to_absolute(size), font: text.font, - horizontal_alignment: text.horizontal_alignment, + horizontal_alignment: Some(text.horizontal_alignment), vertical_alignment: text.vertical_alignment, shaping: text.shaping, clip_bounds: self.clip_bounds, diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 2ef9992c..8d77d9c8 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -417,7 +417,7 @@ impl Renderer { size: Pixels(20.0), line_height: core::text::LineHeight::default(), font: Font::MONOSPACE, - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Top, shaping: core::text::Shaping::Basic, wrapping: core::text::Wrapping::Word, diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 274cc4b7..a7227350 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -540,7 +540,7 @@ fn prepare( ( editor.buffer(), Rectangle::new(*position, editor.bounds()), - alignment::Horizontal::Left, + None, alignment::Vertical::Top, *color, *clip_bounds, @@ -591,7 +591,7 @@ fn prepare( height.unwrap_or(layer_bounds.height), ), ), - alignment::Horizontal::Left, + None, alignment::Vertical::Top, raw.color, raw.clip_bounds, @@ -603,9 +603,11 @@ fn prepare( let bounds = bounds * transformation * layer_transformation; let left = match horizontal_alignment { - alignment::Horizontal::Left => bounds.x, - alignment::Horizontal::Center => bounds.x - bounds.width / 2.0, - alignment::Horizontal::Right => bounds.x - bounds.width, + None | Some(alignment::Horizontal::Left) => bounds.x, + Some(alignment::Horizontal::Center) => { + bounds.x - bounds.width / 2.0 + } + Some(alignment::Horizontal::Right) => bounds.x - bounds.width, }; let top = match vertical_alignment { diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 3c1ef276..7247641f 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -293,7 +293,7 @@ where self.text_line_height, self.text_size, self.font, - alignment::Horizontal::Left, + None, alignment::Vertical::Top, self.text_shaping, self.text_wrapping, @@ -416,7 +416,9 @@ where size, line_height: *line_height, bounds: bounds.size(), - horizontal_alignment: alignment::Horizontal::Center, + horizontal_alignment: Some( + alignment::Horizontal::Center, + ), vertical_alignment: alignment::Vertical::Center, shaping: *shaping, wrapping: text::Wrapping::default(), diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs index 9d0539ff..91d7937f 100644 --- a/widget/src/overlay/menu.rs +++ b/widget/src/overlay/menu.rs @@ -552,7 +552,7 @@ where size: text_size, line_height: self.text_line_height, font: self.font.unwrap_or_else(|| renderer.default_font()), - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Center, shaping: self.text_shaping, wrapping: text::Wrapping::default(), diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs index b751fcc3..f608c78f 100644 --- a/widget/src/pick_list.rs +++ b/widget/src/pick_list.rs @@ -371,7 +371,7 @@ where size: text_size, line_height: self.text_line_height, font, - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Center, shaping: self.text_shaping, wrapping: text::Wrapping::default(), @@ -639,7 +639,7 @@ where bounds.width, f32::from(line_height.to_absolute(size)), ), - horizontal_alignment: alignment::Horizontal::Right, + horizontal_alignment: Some(alignment::Horizontal::Right), vertical_alignment: alignment::Vertical::Center, shaping, wrapping: text::Wrapping::default(), @@ -669,7 +669,7 @@ where bounds.width - self.padding.horizontal(), f32::from(self.text_line_height.to_absolute(text_size)), ), - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Center, shaping: self.text_shaping, wrapping: text::Wrapping::default(), diff --git a/widget/src/radio.rs b/widget/src/radio.rs index 0df4d715..3ae2eca3 100644 --- a/widget/src/radio.rs +++ b/widget/src/radio.rs @@ -314,7 +314,7 @@ where self.text_line_height, self.text_size, self.font, - alignment::Horizontal::Left, + None, alignment::Vertical::Top, self.text_shaping, self.text_wrapping, diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs index 4d4a2861..1e406136 100644 --- a/widget/src/text/rich.rs +++ b/widget/src/text/rich.rs @@ -31,7 +31,7 @@ pub struct Rich< width: Length, height: Length, font: Option, - align_x: alignment::Horizontal, + align_x: Option, align_y: alignment::Vertical, wrapping: Wrapping, class: Theme::Class<'a>, @@ -56,7 +56,7 @@ where width: Length::Shrink, height: Length::Shrink, font: None, - align_x: alignment::Horizontal::Left, + align_x: None, align_y: alignment::Vertical::Top, wrapping: Wrapping::default(), class: Theme::default(), @@ -116,7 +116,7 @@ where mut self, alignment: impl Into, ) -> Self { - self.align_x = alignment.into(); + self.align_x = Some(alignment.into()); self } @@ -476,7 +476,7 @@ fn layout( line_height: LineHeight, size: Option, font: Option, - horizontal_alignment: alignment::Horizontal, + horizontal_alignment: Option, vertical_alignment: alignment::Vertical, wrapping: Wrapping, ) -> layout::Node diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 7e40a56a..9f402a0c 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -955,7 +955,7 @@ where .unwrap_or_else(|| renderer.default_size()), line_height: self.line_height, font, - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Top, shaping: text::Shaping::Advanced, wrapping: self.wrapping, diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index 3abead5b..96295312 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -319,7 +319,7 @@ where content: self.placeholder.as_str(), bounds: Size::new(f32::INFINITY, text_bounds.height), size: text_size, - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Center, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::default(), @@ -344,7 +344,7 @@ where font: icon.font, size: icon.size.unwrap_or_else(|| renderer.default_size()), bounds: Size::new(f32::INFINITY, text_bounds.height), - horizontal_alignment: alignment::Horizontal::Center, + horizontal_alignment: Some(alignment::Horizontal::Center), vertical_alignment: alignment::Vertical::Center, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::default(), @@ -1727,7 +1727,7 @@ fn replace_paragraph( content: &value.to_string(), bounds: Size::new(f32::INFINITY, text_bounds.height), size: text_size, - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Center, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::default(), diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index b711432e..d588e897 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -93,7 +93,7 @@ pub struct Toggler< size: f32, text_size: Option, text_line_height: text::LineHeight, - text_alignment: alignment::Horizontal, + text_alignment: Option, text_shaping: text::Shaping, text_wrapping: text::Wrapping, spacing: f32, @@ -127,7 +127,7 @@ where size: Self::DEFAULT_SIZE, text_size: None, text_line_height: text::LineHeight::default(), - text_alignment: alignment::Horizontal::Left, + text_alignment: None, text_shaping: text::Shaping::default(), text_wrapping: text::Wrapping::default(), spacing: Self::DEFAULT_SIZE / 2.0, @@ -195,8 +195,11 @@ where } /// Sets the horizontal alignment of the text of the [`Toggler`] - pub fn text_alignment(mut self, alignment: alignment::Horizontal) -> Self { - self.text_alignment = alignment; + pub fn text_alignment( + mut self, + alignment: impl Into, + ) -> Self { + self.text_alignment = Some(alignment.into()); self } diff --git a/winit/src/program/window_manager.rs b/winit/src/program/window_manager.rs index 139d787a..c365d2f9 100644 --- a/winit/src/program/window_manager.rs +++ b/winit/src/program/window_manager.rs @@ -338,7 +338,7 @@ where .unwrap_or_else(|| renderer.default_size()), line_height: text::LineHeight::default(), font: renderer.default_font(), - horizontal_alignment: alignment::Horizontal::Left, + horizontal_alignment: None, vertical_alignment: alignment::Vertical::Top, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::None, From 2eb5770b1d4c8a3b5db5dc1ad04bb18bf90fadda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 11 Mar 2025 00:58:15 +0100 Subject: [PATCH 07/11] Add `TODO` to `align` function in `text::paragraph` --- graphics/src/text/paragraph.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/graphics/src/text/paragraph.rs b/graphics/src/text/paragraph.rs index 747bec59..6edb19c7 100644 --- a/graphics/src/text/paragraph.rs +++ b/graphics/src/text/paragraph.rs @@ -381,6 +381,7 @@ fn align( } } + // TODO: Avoid relayout with some changes to `cosmic-text` (?) if needs_relayout { log::trace!("Relayouting paragraph..."); From 0e4a3927312764ceb6e6474ed185f5e33bdb56e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 11 Mar 2025 02:25:44 +0100 Subject: [PATCH 08/11] Introduce `text::Alignment` with `Justified` support --- benches/wgpu.rs | 4 +- core/src/renderer/null.rs | 6 +-- core/src/text.rs | 43 ++++++++++++++++++++- core/src/text/paragraph.rs | 18 ++++----- core/src/widget/text.rs | 41 ++++++++++---------- examples/clock/src/main.rs | 8 ++-- examples/color_palette/src/main.rs | 6 +-- examples/game_of_life/src/main.rs | 4 +- examples/tour/src/main.rs | 12 +++--- examples/vectorial_text/src/main.rs | 4 +- graphics/src/geometry/text.rs | 14 +++---- graphics/src/text.rs | 50 +++++++++++++------------ graphics/src/text/paragraph.rs | 58 ++++++++++++++--------------- tiny_skia/src/engine.rs | 8 ++-- tiny_skia/src/geometry.rs | 4 +- tiny_skia/src/layer.rs | 4 +- tiny_skia/src/text.rs | 26 ++++++------- wgpu/src/geometry.rs | 4 +- wgpu/src/layer.rs | 4 +- wgpu/src/lib.rs | 4 +- wgpu/src/text.rs | 21 ++++++----- widget/src/checkbox.rs | 8 ++-- widget/src/overlay/menu.rs | 4 +- widget/src/pick_list.rs | 12 +++--- widget/src/radio.rs | 2 +- widget/src/text/rich.rs | 25 ++++++------- widget/src/text_editor.rs | 4 +- widget/src/text_input.rs | 12 +++--- widget/src/toggler.rs | 8 ++-- winit/src/program/window_manager.rs | 4 +- 30 files changed, 227 insertions(+), 195 deletions(-) diff --git a/benches/wgpu.rs b/benches/wgpu.rs index c920a71e..8d61137e 100644 --- a/benches/wgpu.rs +++ b/benches/wgpu.rs @@ -191,8 +191,8 @@ fn scene<'a, Message: 'a>(n: usize) -> Element<'a, Message, Theme, Renderer> { size: Pixels::from(16), line_height: text::LineHeight::default(), font: Font::DEFAULT, - horizontal_alignment: alignment::Horizontal::Left, - vertical_alignment: alignment::Vertical::Top, + align_x: alignment::Horizontal::Left, + align_y: alignment::Vertical::Top, shaping: text::Shaping::Basic, }); } diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index 7fc28bc0..bf474b58 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -87,11 +87,11 @@ impl text::Paragraph for () { text::Difference::None } - fn horizontal_alignment(&self) -> Option { - None + fn align_x(&self) -> text::Alignment { + text::Alignment::Default } - fn vertical_alignment(&self) -> alignment::Vertical { + fn align_y(&self) -> alignment::Vertical { alignment::Vertical::Top } diff --git a/core/src/text.rs b/core/src/text.rs index 5cffe2b2..79911b62 100644 --- a/core/src/text.rs +++ b/core/src/text.rs @@ -34,10 +34,10 @@ pub struct Text { pub font: Font, /// The horizontal alignment of the [`Text`]. - pub horizontal_alignment: Option, + pub align_x: Alignment, /// The vertical alignment of the [`Text`]. - pub vertical_alignment: alignment::Vertical, + pub align_y: alignment::Vertical, /// The [`Shaping`] strategy of the [`Text`]. pub shaping: Shaping, @@ -46,6 +46,45 @@ pub struct Text { pub wrapping: Wrapping, } +/// The alignment of some text. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] +pub enum Alignment { + /// No specific alignment. + /// + /// Left-to-right text will be aligned to the left, while + /// right-to-left text will be aligned to the right. + #[default] + Default, + /// Align text to the left. + Left, + /// Center text. + Center, + /// Align text to the right. + Right, + /// Justify text. + Justified, +} + +impl From for Alignment { + fn from(alignment: alignment::Horizontal) -> Self { + match alignment { + alignment::Horizontal::Left => Self::Left, + alignment::Horizontal::Center => Self::Center, + alignment::Horizontal::Right => Self::Right, + } + } +} + +impl From for Alignment { + fn from(alignment: crate::Alignment) -> Self { + match alignment { + crate::Alignment::Start => Self::Left, + crate::Alignment::Center => Self::Center, + crate::Alignment::End => Self::Right, + } + } +} + /// The shaping strategy of some text. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)] pub enum Shaping { diff --git a/core/src/text/paragraph.rs b/core/src/text/paragraph.rs index 99d8da20..b55ff156 100644 --- a/core/src/text/paragraph.rs +++ b/core/src/text/paragraph.rs @@ -1,6 +1,6 @@ //! Draw paragraphs. use crate::alignment; -use crate::text::{Difference, Hit, Span, Text}; +use crate::text::{Alignment, Difference, Hit, Span, Text}; use crate::{Point, Rectangle, Size}; /// A text paragraph. @@ -24,10 +24,10 @@ pub trait Paragraph: Sized + Default { fn compare(&self, text: Text<(), Self::Font>) -> Difference; /// Returns the horizontal alignment of the [`Paragraph`]. - fn horizontal_alignment(&self) -> Option; + fn align_x(&self) -> Alignment; /// Returns the vertical alignment of the [`Paragraph`]. - fn vertical_alignment(&self) -> alignment::Vertical; + fn align_y(&self) -> alignment::Vertical; /// Returns the minimum boundaries that can fit the contents of the /// [`Paragraph`]. @@ -92,8 +92,8 @@ impl Plain

{ size: text.size, line_height: text.line_height, font: text.font, - horizontal_alignment: text.horizontal_alignment, - vertical_alignment: text.vertical_alignment, + align_x: text.align_x, + align_y: text.align_y, shaping: text.shaping, wrapping: text.wrapping, }) { @@ -108,13 +108,13 @@ impl Plain

{ } /// Returns the horizontal alignment of the [`Paragraph`]. - pub fn horizontal_alignment(&self) -> Option { - self.raw.horizontal_alignment() + pub fn align_x(&self) -> Alignment { + self.raw.align_x() } /// Returns the vertical alignment of the [`Paragraph`]. - pub fn vertical_alignment(&self) -> alignment::Vertical { - self.raw.vertical_alignment() + pub fn align_y(&self) -> alignment::Vertical { + self.raw.align_y() } /// Returns the minimum boundaries that can fit the contents of the diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index fe9a8a81..ca4ac4c2 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -32,7 +32,7 @@ use crate::{ Widget, }; -pub use text::{LineHeight, Shaping, Wrapping}; +pub use text::{Alignment, LineHeight, Shaping, Wrapping}; /// A bunch of text. /// @@ -67,8 +67,8 @@ where line_height: LineHeight, width: Length, height: Length, - horizontal_alignment: Option, - vertical_alignment: alignment::Vertical, + align_x: text::Alignment, + align_y: alignment::Vertical, font: Option, shaping: Shaping, wrapping: Wrapping, @@ -89,8 +89,8 @@ where font: None, width: Length::Shrink, height: Length::Shrink, - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Top, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Top, shaping: Shaping::default(), wrapping: Wrapping::default(), class: Theme::default(), @@ -136,11 +136,8 @@ where } /// Sets the [`alignment::Horizontal`] of the [`Text`]. - pub fn align_x( - mut self, - alignment: impl Into, - ) -> Self { - self.horizontal_alignment = Some(alignment.into()); + pub fn align_x(mut self, alignment: impl Into) -> Self { + self.align_x = alignment.into(); self } @@ -149,7 +146,7 @@ where mut self, alignment: impl Into, ) -> Self { - self.vertical_alignment = alignment.into(); + self.align_y = alignment.into(); self } @@ -245,8 +242,8 @@ where self.line_height, self.size, self.font, - self.horizontal_alignment, - self.vertical_alignment, + self.align_x, + self.align_y, self.shaping, self.wrapping, ) @@ -290,8 +287,8 @@ pub fn layout( line_height: LineHeight, size: Option, font: Option, - horizontal_alignment: Option, - vertical_alignment: alignment::Vertical, + align_x: text::Alignment, + align_y: alignment::Vertical, shaping: Shaping, wrapping: Wrapping, ) -> layout::Node @@ -312,8 +309,8 @@ where size, line_height, font, - horizontal_alignment, - vertical_alignment, + align_x, + align_y, shaping, wrapping, }); @@ -344,13 +341,13 @@ pub fn draw( { let bounds = layout.bounds(); - let x = match paragraph.horizontal_alignment() { - None | Some(alignment::Horizontal::Left) => bounds.x, - Some(alignment::Horizontal::Center) => bounds.center_x(), - Some(alignment::Horizontal::Right) => bounds.x + bounds.width, + let x = match paragraph.align_x() { + Alignment::Default | Alignment::Left | Alignment::Justified => bounds.x, + Alignment::Center => bounds.center_x(), + Alignment::Right => bounds.x + bounds.width, }; - let y = match paragraph.vertical_alignment() { + let y = match paragraph.align_y() { alignment::Vertical::Top => bounds.y, alignment::Vertical::Center => bounds.center_y(), alignment::Vertical::Bottom => bounds.y + bounds.height, diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index fde0c188..1c90708f 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -150,12 +150,12 @@ impl canvas::Program for Clock { -width * 2.0, ), color: palette.secondary.strong.text, - horizontal_alignment: if rotate_factor > 0.0 { + align_x: if rotate_factor > 0.0 { alignment::Horizontal::Right } else { alignment::Horizontal::Left }, - vertical_alignment: alignment::Vertical::Bottom, + align_y: alignment::Vertical::Bottom, font: Font::MONOSPACE, ..canvas::Text::default() }); @@ -173,8 +173,8 @@ impl canvas::Program for Clock { size: (radius / 5.0).into(), position: Point::new(x * 0.82, y * 0.82), color: palette.secondary.strong.text, - horizontal_alignment: alignment::Horizontal::Center, - vertical_alignment: alignment::Vertical::Center, + align_x: alignment::Horizontal::Center, + align_y: alignment::Vertical::Center, font: Font::MONOSPACE, ..canvas::Text::default() }); diff --git a/examples/color_palette/src/main.rs b/examples/color_palette/src/main.rs index c7bc6fb8..b11c8a2b 100644 --- a/examples/color_palette/src/main.rs +++ b/examples/color_palette/src/main.rs @@ -170,8 +170,8 @@ impl Theme { }); let mut text = canvas::Text { - horizontal_alignment: alignment::Horizontal::Center, - vertical_alignment: alignment::Vertical::Top, + align_x: alignment::Horizontal::Center, + align_y: alignment::Vertical::Top, size: Pixels(15.0), color: text_color, ..canvas::Text::default() @@ -214,7 +214,7 @@ impl Theme { }); } - text.vertical_alignment = alignment::Vertical::Bottom; + text.align_y = alignment::Vertical::Bottom; let hsl = Hsl::from_color(Rgb::from(self.base)); for i in 0..self.len() { diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index d652347b..7793ba77 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -580,8 +580,8 @@ mod grid { color: Color::WHITE, size: 14.0.into(), position: Point::new(frame.width(), frame.height()), - horizontal_alignment: alignment::Horizontal::Right, - vertical_alignment: alignment::Vertical::Bottom, + align_x: alignment::Horizontal::Right, + align_y: alignment::Vertical::Bottom, ..Text::default() }; diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 2f8421d7..0a4d16cb 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -194,8 +194,8 @@ impl Tour { fn welcome(&self) -> Column { Self::container("Welcome!") .push( - "This is a simple tour meant to showcase a bunch of widgets \ - that can be easily implemented on top of Iced.", + "This is a simple tour meant to showcase a bunch of \ + widgets that can be easily implemented on top of Iced.", ) .push( "Iced is a cross-platform GUI library for Rust focused on \ @@ -211,12 +211,12 @@ impl Tour { Metal, DX11, and DX12.", ) .push( - "Additionally, this tour can also run on WebAssembly thanks \ - to dodrio, an experimental VDOM library for Rust.", + "Additionally, this tour can also run on WebAssembly \ + thanks to dodrio, an experimental VDOM library for Rust.", ) .push( - "You will need to interact with the UI in order to reach the \ - end!", + "You will need to interact with the UI in order to reach \ + the end!", ) } diff --git a/examples/vectorial_text/src/main.rs b/examples/vectorial_text/src/main.rs index ce34d826..c4ce7072 100644 --- a/examples/vectorial_text/src/main.rs +++ b/examples/vectorial_text/src/main.rs @@ -142,8 +142,8 @@ impl canvas::Program for State { } else { "Vectorial Text! 🎉" }), - horizontal_alignment: alignment::Horizontal::Center, - vertical_alignment: alignment::Vertical::Center, + align_x: alignment::Horizontal::Center, + align_y: alignment::Vertical::Center, shaping: text::Shaping::Advanced, ..canvas::Text::default() }); diff --git a/graphics/src/geometry/text.rs b/graphics/src/geometry/text.rs index f8ac357d..6e2056ac 100644 --- a/graphics/src/geometry/text.rs +++ b/graphics/src/geometry/text.rs @@ -30,9 +30,9 @@ pub struct Text { /// The font of the text pub font: Font, /// The horizontal alignment of the text - pub horizontal_alignment: alignment::Horizontal, + pub align_x: alignment::Horizontal, /// The vertical alignment of the text - pub vertical_alignment: alignment::Vertical, + pub align_y: alignment::Vertical, /// The shaping strategy of the text. pub shaping: Shaping, } @@ -60,7 +60,7 @@ impl Text { 4, ); - let translation_x = match self.horizontal_alignment { + let translation_x = match self.align_x { alignment::Horizontal::Left => self.position.x, alignment::Horizontal::Center | alignment::Horizontal::Right => { let mut line_width = 0.0f32; @@ -69,7 +69,7 @@ impl Text { line_width = line_width.max(line.w); } - if self.horizontal_alignment == alignment::Horizontal::Center { + if self.align_x == alignment::Horizontal::Center { self.position.x - line_width / 2.0 } else { self.position.x - line_width @@ -80,7 +80,7 @@ impl Text { let translation_y = { let line_height = self.line_height.to_absolute(self.size); - match self.vertical_alignment { + match self.align_y { alignment::Vertical::Top => self.position.y, alignment::Vertical::Center => { self.position.y - line_height.0 / 2.0 @@ -180,8 +180,8 @@ impl Default for Text { size: Pixels(16.0), line_height: LineHeight::Relative(1.2), font: Font::default(), - horizontal_alignment: alignment::Horizontal::Left, - vertical_alignment: alignment::Vertical::Top, + align_x: alignment::Horizontal::Left, + align_y: alignment::Vertical::Top, shaping: Shaping::Basic, } } diff --git a/graphics/src/text.rs b/graphics/src/text.rs index 3731cdda..507ef178 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -11,7 +11,7 @@ pub use cosmic_text; use crate::core::alignment; use crate::core::font::{self, Font}; -use crate::core::text::{Shaping, Wrapping}; +use crate::core::text::{Alignment, Shaping, Wrapping}; use crate::core::{Color, Pixels, Point, Rectangle, Size, Transformation}; use std::borrow::Cow; @@ -54,9 +54,9 @@ pub enum Text { /// The font of the text. font: Font, /// The horizontal alignment of the text. - horizontal_alignment: Option, + align_x: Alignment, /// The vertical alignment of the text. - vertical_alignment: alignment::Vertical, + align_y: alignment::Vertical, /// The shaping strategy of the text. shaping: Shaping, /// The clip bounds of the text. @@ -73,7 +73,7 @@ pub enum Text { impl Text { /// Returns the visible bounds of the [`Text`]. pub fn visible_bounds(&self) -> Option { - let (bounds, horizontal_alignment, vertical_alignment) = match self { + let (bounds, align_x, align_y) = match self { Text::Paragraph { position, paragraph, @@ -84,8 +84,8 @@ impl Text { Rectangle::new(*position, paragraph.min_bounds) .intersection(clip_bounds) .map(|bounds| bounds * *transformation), - paragraph.horizontal_alignment, - Some(paragraph.vertical_alignment), + paragraph.align_x, + Some(paragraph.align_y), ), Text::Editor { editor, @@ -97,38 +97,38 @@ impl Text { Rectangle::new(*position, editor.bounds) .intersection(clip_bounds) .map(|bounds| bounds * *transformation), - None, + Alignment::Default, None, ), Text::Cached { bounds, clip_bounds, - horizontal_alignment, - vertical_alignment, + align_x: horizontal_alignment, + align_y: vertical_alignment, .. } => ( bounds.intersection(clip_bounds), *horizontal_alignment, Some(*vertical_alignment), ), - Text::Raw { raw, .. } => (Some(raw.clip_bounds), None, None), + Text::Raw { raw, .. } => { + (Some(raw.clip_bounds), Alignment::Default, None) + } }; let mut bounds = bounds?; - if let Some(alignment) = horizontal_alignment { - match alignment { - alignment::Horizontal::Left => {} - alignment::Horizontal::Center => { - bounds.x -= bounds.width / 2.0; - } - alignment::Horizontal::Right => { - bounds.x -= bounds.width; - } + match align_x { + Alignment::Default | Alignment::Left | Alignment::Justified => {} + Alignment::Center => { + bounds.x -= bounds.width / 2.0; + } + Alignment::Right => { + bounds.x -= bounds.width; } } - if let Some(alignment) = vertical_alignment { + if let Some(alignment) = align_y { match alignment { alignment::Vertical::Top => {} alignment::Vertical::Center => { @@ -313,11 +313,13 @@ fn to_style(style: font::Style) -> cosmic_text::Style { } } -fn to_align(alignment: alignment::Horizontal) -> cosmic_text::Align { +fn to_align(alignment: Alignment) -> Option { match alignment { - alignment::Horizontal::Left => cosmic_text::Align::Left, - alignment::Horizontal::Center => cosmic_text::Align::Center, - alignment::Horizontal::Right => cosmic_text::Align::Right, + Alignment::Default => None, + Alignment::Left => Some(cosmic_text::Align::Left), + Alignment::Center => Some(cosmic_text::Align::Center), + Alignment::Right => Some(cosmic_text::Align::Right), + Alignment::Justified => Some(cosmic_text::Align::Justified), } } diff --git a/graphics/src/text/paragraph.rs b/graphics/src/text/paragraph.rs index 6edb19c7..fe517cf9 100644 --- a/graphics/src/text/paragraph.rs +++ b/graphics/src/text/paragraph.rs @@ -1,7 +1,7 @@ //! Draw paragraphs. use crate::core; use crate::core::alignment; -use crate::core::text::{Hit, Shaping, Span, Text, Wrapping}; +use crate::core::text::{Alignment, Hit, Shaping, Span, Text, Wrapping}; use crate::core::{Font, Point, Rectangle, Size}; use crate::text; @@ -18,8 +18,8 @@ struct Internal { font: Font, shaping: Shaping, wrapping: Wrapping, - horizontal_alignment: Option, - vertical_alignment: alignment::Vertical, + align_x: Alignment, + align_y: alignment::Vertical, bounds: Size, min_bounds: Size, version: text::Version, @@ -47,8 +47,8 @@ impl Paragraph { Weak { raw: Arc::downgrade(paragraph), min_bounds: paragraph.min_bounds, - horizontal_alignment: paragraph.horizontal_alignment, - vertical_alignment: paragraph.vertical_alignment, + align_x: paragraph.align_x, + align_y: paragraph.align_y, } } @@ -89,14 +89,13 @@ impl core::text::Paragraph for Paragraph { text::to_shaping(text.shaping), ); - let min_bounds = - align(&mut buffer, &mut font_system, text.horizontal_alignment); + let min_bounds = align(&mut buffer, &mut font_system, text.align_x); Self(Arc::new(Internal { buffer, font: text.font, - horizontal_alignment: text.horizontal_alignment, - vertical_alignment: text.vertical_alignment, + align_x: text.align_x, + align_y: text.align_y, shaping: text.shaping, wrapping: text.wrapping, bounds: text.bounds, @@ -160,14 +159,13 @@ impl core::text::Paragraph for Paragraph { None, ); - let min_bounds = - align(&mut buffer, &mut font_system, text.horizontal_alignment); + let min_bounds = align(&mut buffer, &mut font_system, text.align_x); Self(Arc::new(Internal { buffer, font: text.font, - horizontal_alignment: text.horizontal_alignment, - vertical_alignment: text.vertical_alignment, + align_x: text.align_x, + align_y: text.align_y, shaping: text.shaping, wrapping: text.wrapping, bounds: text.bounds, @@ -205,8 +203,8 @@ impl core::text::Paragraph for Paragraph { || paragraph.font != text.font || paragraph.shaping != text.shaping || paragraph.wrapping != text.wrapping - || paragraph.horizontal_alignment != text.horizontal_alignment - || paragraph.vertical_alignment != text.vertical_alignment + || paragraph.align_x != text.align_x + || paragraph.align_y != text.align_y { core::text::Difference::Shape } else if paragraph.bounds != text.bounds { @@ -216,12 +214,12 @@ impl core::text::Paragraph for Paragraph { } } - fn horizontal_alignment(&self) -> Option { - self.internal().horizontal_alignment + fn align_x(&self) -> Alignment { + self.internal().align_x } - fn vertical_alignment(&self) -> alignment::Vertical { - self.internal().vertical_alignment + fn align_y(&self) -> alignment::Vertical { + self.internal().align_y } fn min_bounds(&self) -> Size { @@ -361,12 +359,12 @@ impl core::text::Paragraph for Paragraph { fn align( buffer: &mut cosmic_text::Buffer, font_system: &mut text::FontSystem, - align_x: Option, + alignment: Alignment, ) -> Size { let (min_bounds, has_rtl) = text::measure(buffer); let mut needs_relayout = has_rtl; - if let Some(align_x) = align_x { + if let Some(align) = text::to_align(alignment) { let has_multiple_lines = buffer.lines.len() > 1 || buffer.lines.first().is_some_and(|line| { line.layout_opt().is_some_and(|layout| layout.len() > 1) @@ -374,7 +372,7 @@ fn align( if has_multiple_lines { for line in &mut buffer.lines { - let _ = line.set_align(Some(text::to_align(align_x))); + let _ = line.set_align(Some(align)); } needs_relayout = true; @@ -408,8 +406,8 @@ impl fmt::Debug for Paragraph { f.debug_struct("Paragraph") .field("font", ¶graph.font) .field("shaping", ¶graph.shaping) - .field("horizontal_alignment", ¶graph.horizontal_alignment) - .field("vertical_alignment", ¶graph.vertical_alignment) + .field("horizontal_alignment", ¶graph.align_x) + .field("vertical_alignment", ¶graph.align_y) .field("bounds", ¶graph.bounds) .field("min_bounds", ¶graph.min_bounds) .finish() @@ -420,8 +418,8 @@ impl PartialEq for Internal { fn eq(&self, other: &Self) -> bool { self.font == other.font && self.shaping == other.shaping - && self.horizontal_alignment == other.horizontal_alignment - && self.vertical_alignment == other.vertical_alignment + && self.align_x == other.align_x + && self.align_y == other.align_y && self.bounds == other.bounds && self.min_bounds == other.min_bounds && self.buffer.metrics() == other.buffer.metrics() @@ -438,8 +436,8 @@ impl Default for Internal { font: Font::default(), shaping: Shaping::default(), wrapping: Wrapping::default(), - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Top, + align_x: Alignment::Default, + align_y: alignment::Vertical::Top, bounds: Size::ZERO, min_bounds: Size::ZERO, version: text::Version::default(), @@ -454,9 +452,9 @@ pub struct Weak { /// The minimum bounds of the [`Paragraph`]. pub min_bounds: Size, /// The horizontal alignment of the [`Paragraph`]. - pub horizontal_alignment: Option, + pub align_x: Alignment, /// The vertical alignment of the [`Paragraph`]. - pub vertical_alignment: alignment::Vertical, + pub align_y: alignment::Vertical, } impl Weak { diff --git a/tiny_skia/src/engine.rs b/tiny_skia/src/engine.rs index c1c02376..2b829b0f 100644 --- a/tiny_skia/src/engine.rs +++ b/tiny_skia/src/engine.rs @@ -399,8 +399,8 @@ impl Engine { size, line_height, font, - horizontal_alignment, - vertical_alignment, + align_x, + align_y, shaping, clip_bounds: text_bounds, // TODO } => { @@ -420,8 +420,8 @@ impl Engine { *size, *line_height, *font, - *horizontal_alignment, - *vertical_alignment, + *align_x, + *align_y, *shaping, pixels, clip_mask, diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 5d8a20f7..0c2e8b1d 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -231,8 +231,8 @@ impl geometry::frame::Backend for Frame { size, line_height: line_height.to_absolute(size), font: text.font, - horizontal_alignment: Some(text.horizontal_alignment), - vertical_alignment: text.vertical_alignment, + align_x: text.align_x.into(), + align_y: text.align_y, shaping: text.shaping, clip_bounds: Rectangle::with_size(Size::INFINITY), }); diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index 444efb84..a1ad1127 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -86,8 +86,8 @@ impl Layer { line_height: text.line_height.to_absolute(text.size) * transformation.scale_factor(), font: text.font, - horizontal_alignment: text.horizontal_alignment, - vertical_alignment: text.vertical_alignment, + align_x: text.align_x, + align_y: text.align_y, shaping: text.shaping, clip_bounds: clip_bounds * transformation, }; diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 499e7998..9f55458d 100644 --- a/tiny_skia/src/text.rs +++ b/tiny_skia/src/text.rs @@ -1,5 +1,5 @@ use crate::core::alignment; -use crate::core::text::Shaping; +use crate::core::text::{Alignment, Shaping}; use crate::core::{ Color, Font, Pixels, Point, Rectangle, Size, Transformation, }; @@ -61,8 +61,8 @@ impl Pipeline { paragraph.buffer(), Rectangle::new(position, paragraph.min_bounds()), color, - paragraph.horizontal_alignment(), - paragraph.vertical_alignment(), + paragraph.align_x(), + paragraph.align_y(), pixels, clip_mask, transformation, @@ -92,7 +92,7 @@ impl Pipeline { editor.buffer(), Rectangle::new(position, editor.bounds()), color, - None, + Alignment::Default, alignment::Vertical::Top, pixels, clip_mask, @@ -108,7 +108,7 @@ impl Pipeline { size: Pixels, line_height: Pixels, font: Font, - horizontal_alignment: Option, + horizontal_alignment: Alignment, vertical_alignment: alignment::Vertical, shaping: Shaping, pixels: &mut tiny_skia::PixmapMut<'_>, @@ -177,7 +177,7 @@ impl Pipeline { ), ), color, - None, + Alignment::Default, alignment::Vertical::Top, pixels, clip_mask, @@ -197,21 +197,21 @@ fn draw( buffer: &cosmic_text::Buffer, bounds: Rectangle, color: Color, - horizontal_alignment: Option, - vertical_alignment: alignment::Vertical, + align_x: Alignment, + align_y: alignment::Vertical, pixels: &mut tiny_skia::PixmapMut<'_>, clip_mask: Option<&tiny_skia::Mask>, transformation: Transformation, ) { let bounds = bounds * transformation; - let x = match horizontal_alignment { - None | Some(alignment::Horizontal::Left) => bounds.x, - Some(alignment::Horizontal::Center) => bounds.x - bounds.width / 2.0, - Some(alignment::Horizontal::Right) => bounds.x - bounds.width, + let x = match align_x { + Alignment::Default | Alignment::Left | Alignment::Justified => bounds.x, + Alignment::Center => bounds.x - bounds.width / 2.0, + Alignment::Right => bounds.x - bounds.width, }; - let y = match vertical_alignment { + let y = match align_y { alignment::Vertical::Top => bounds.y, alignment::Vertical::Center => bounds.y - bounds.height / 2.0, alignment::Vertical::Bottom => bounds.y - bounds.height, diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 5a562bf5..881eb6be 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -336,8 +336,8 @@ impl geometry::frame::Backend for Frame { size, line_height: line_height.to_absolute(size), font: text.font, - horizontal_alignment: Some(text.horizontal_alignment), - vertical_alignment: text.vertical_alignment, + align_x: text.align_x.into(), + align_y: text.align_y, shaping: text.shaping, clip_bounds: self.clip_bounds, }); diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 2255b3f2..5e307ca7 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -103,8 +103,8 @@ impl Layer { line_height: text.line_height.to_absolute(text.size) * transformation.scale_factor(), font: text.font, - horizontal_alignment: text.horizontal_alignment, - vertical_alignment: text.vertical_alignment, + align_x: text.align_x, + align_y: text.align_y, shaping: text.shaping, clip_bounds: clip_bounds * transformation, }; diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 8d77d9c8..ac3210e2 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -417,8 +417,8 @@ impl Renderer { size: Pixels(20.0), line_height: core::text::LineHeight::default(), font: Font::MONOSPACE, - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Top, + align_x: core::text::Alignment::Default, + align_y: alignment::Vertical::Top, shaping: core::text::Shaping::Basic, wrapping: core::text::Wrapping::Word, }; diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index a7227350..d2e09e93 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -1,4 +1,5 @@ use crate::core::alignment; +use crate::core::text::Alignment; use crate::core::{Rectangle, Size, Transformation}; use crate::graphics::cache; use crate::graphics::color; @@ -517,8 +518,8 @@ fn prepare( ( paragraph.buffer(), Rectangle::new(*position, paragraph.min_bounds()), - paragraph.horizontal_alignment(), - paragraph.vertical_alignment(), + paragraph.align_x(), + paragraph.align_y(), *color, *clip_bounds, *transformation, @@ -540,7 +541,7 @@ fn prepare( ( editor.buffer(), Rectangle::new(*position, editor.bounds()), - None, + Alignment::Default, alignment::Vertical::Top, *color, *clip_bounds, @@ -549,8 +550,8 @@ fn prepare( } Text::Cached { bounds, - horizontal_alignment, - vertical_alignment, + align_x: horizontal_alignment, + align_y: vertical_alignment, color, clip_bounds, .. @@ -591,7 +592,7 @@ fn prepare( height.unwrap_or(layer_bounds.height), ), ), - None, + Alignment::Default, alignment::Vertical::Top, raw.color, raw.clip_bounds, @@ -603,11 +604,11 @@ fn prepare( let bounds = bounds * transformation * layer_transformation; let left = match horizontal_alignment { - None | Some(alignment::Horizontal::Left) => bounds.x, - Some(alignment::Horizontal::Center) => { - bounds.x - bounds.width / 2.0 + Alignment::Default | Alignment::Left | Alignment::Justified => { + bounds.x } - Some(alignment::Horizontal::Right) => bounds.x - bounds.width, + Alignment::Center => bounds.x - bounds.width / 2.0, + Alignment::Right => bounds.x - bounds.width, }; let top = match vertical_alignment { diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 7247641f..b84e083d 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -293,7 +293,7 @@ where self.text_line_height, self.text_size, self.font, - None, + text::Alignment::Default, alignment::Vertical::Top, self.text_shaping, self.text_wrapping, @@ -416,10 +416,8 @@ where size, line_height: *line_height, bounds: bounds.size(), - horizontal_alignment: Some( - alignment::Horizontal::Center, - ), - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Center, + align_y: alignment::Vertical::Center, shaping: *shaping, wrapping: text::Wrapping::default(), }, diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs index 91d7937f..3007ba89 100644 --- a/widget/src/overlay/menu.rs +++ b/widget/src/overlay/menu.rs @@ -552,8 +552,8 @@ where size: text_size, line_height: self.text_line_height, font: self.font.unwrap_or_else(|| renderer.default_font()), - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Center, shaping: self.text_shaping, wrapping: text::Wrapping::default(), }, diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs index f608c78f..653c2f04 100644 --- a/widget/src/pick_list.rs +++ b/widget/src/pick_list.rs @@ -371,8 +371,8 @@ where size: text_size, line_height: self.text_line_height, font, - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Center, shaping: self.text_shaping, wrapping: text::Wrapping::default(), }; @@ -639,8 +639,8 @@ where bounds.width, f32::from(line_height.to_absolute(size)), ), - horizontal_alignment: Some(alignment::Horizontal::Right), - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Right, + align_y: alignment::Vertical::Center, shaping, wrapping: text::Wrapping::default(), }, @@ -669,8 +669,8 @@ where bounds.width - self.padding.horizontal(), f32::from(self.text_line_height.to_absolute(text_size)), ), - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Center, shaping: self.text_shaping, wrapping: text::Wrapping::default(), }, diff --git a/widget/src/radio.rs b/widget/src/radio.rs index 3ae2eca3..fcbb358b 100644 --- a/widget/src/radio.rs +++ b/widget/src/radio.rs @@ -314,7 +314,7 @@ where self.text_line_height, self.text_size, self.font, - None, + text::Alignment::Default, alignment::Vertical::Top, self.text_shaping, self.text_wrapping, diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs index 1e406136..f1b2c75e 100644 --- a/widget/src/text/rich.rs +++ b/widget/src/text/rich.rs @@ -4,7 +4,7 @@ use crate::core::mouse; use crate::core::renderer; use crate::core::text::{Paragraph, Span}; use crate::core::widget::text::{ - self, Catalog, LineHeight, Shaping, Style, StyleFn, Wrapping, + self, Alignment, Catalog, LineHeight, Shaping, Style, StyleFn, Wrapping, }; use crate::core::widget::tree::{self, Tree}; use crate::core::{ @@ -31,7 +31,7 @@ pub struct Rich< width: Length, height: Length, font: Option, - align_x: Option, + align_x: Alignment, align_y: alignment::Vertical, wrapping: Wrapping, class: Theme::Class<'a>, @@ -56,7 +56,7 @@ where width: Length::Shrink, height: Length::Shrink, font: None, - align_x: None, + align_x: Alignment::Default, align_y: alignment::Vertical::Top, wrapping: Wrapping::default(), class: Theme::default(), @@ -112,11 +112,8 @@ where } /// Sets the [`alignment::Horizontal`] of the [`Rich`] text. - pub fn align_x( - mut self, - alignment: impl Into, - ) -> Self { - self.align_x = Some(alignment.into()); + pub fn align_x(mut self, alignment: impl Into) -> Self { + self.align_x = alignment.into(); self } @@ -476,8 +473,8 @@ fn layout( line_height: LineHeight, size: Option, font: Option, - horizontal_alignment: Option, - vertical_alignment: alignment::Vertical, + align_x: Alignment, + align_y: alignment::Vertical, wrapping: Wrapping, ) -> layout::Node where @@ -496,8 +493,8 @@ where size, line_height, font, - horizontal_alignment, - vertical_alignment, + align_x, + align_y, shaping: Shaping::Advanced, wrapping, }; @@ -513,8 +510,8 @@ where size, line_height, font, - horizontal_alignment, - vertical_alignment, + align_x, + align_y, shaping: Shaping::Advanced, wrapping, }) { diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index 9f402a0c..4c2b101f 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -955,8 +955,8 @@ where .unwrap_or_else(|| renderer.default_size()), line_height: self.line_height, font, - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Top, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Top, shaping: text::Shaping::Advanced, wrapping: self.wrapping, }, diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index 96295312..bfddabc6 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -319,8 +319,8 @@ where content: self.placeholder.as_str(), bounds: Size::new(f32::INFINITY, text_bounds.height), size: text_size, - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Center, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::default(), }; @@ -344,8 +344,8 @@ where font: icon.font, size: icon.size.unwrap_or_else(|| renderer.default_size()), bounds: Size::new(f32::INFINITY, text_bounds.height), - horizontal_alignment: Some(alignment::Horizontal::Center), - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Center, + align_y: alignment::Vertical::Center, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::default(), }; @@ -1727,8 +1727,8 @@ fn replace_paragraph( content: &value.to_string(), bounds: Size::new(f32::INFINITY, text_bounds.height), size: text_size, - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Center, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Center, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::default(), }); diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index d588e897..69678f12 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -93,7 +93,7 @@ pub struct Toggler< size: f32, text_size: Option, text_line_height: text::LineHeight, - text_alignment: Option, + text_alignment: text::Alignment, text_shaping: text::Shaping, text_wrapping: text::Wrapping, spacing: f32, @@ -127,7 +127,7 @@ where size: Self::DEFAULT_SIZE, text_size: None, text_line_height: text::LineHeight::default(), - text_alignment: None, + text_alignment: text::Alignment::Default, text_shaping: text::Shaping::default(), text_wrapping: text::Wrapping::default(), spacing: Self::DEFAULT_SIZE / 2.0, @@ -197,9 +197,9 @@ where /// Sets the horizontal alignment of the text of the [`Toggler`] pub fn text_alignment( mut self, - alignment: impl Into, + alignment: impl Into, ) -> Self { - self.text_alignment = Some(alignment.into()); + self.text_alignment = alignment.into(); self } diff --git a/winit/src/program/window_manager.rs b/winit/src/program/window_manager.rs index c365d2f9..3ad574ca 100644 --- a/winit/src/program/window_manager.rs +++ b/winit/src/program/window_manager.rs @@ -338,8 +338,8 @@ where .unwrap_or_else(|| renderer.default_size()), line_height: text::LineHeight::default(), font: renderer.default_font(), - horizontal_alignment: None, - vertical_alignment: alignment::Vertical::Top, + align_x: text::Alignment::Default, + align_y: alignment::Vertical::Top, shaping: text::Shaping::Advanced, wrapping: text::Wrapping::None, }); From 1654c178089fb24779ad334f0a4508b014e0eea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 11 Mar 2025 02:29:22 +0100 Subject: [PATCH 09/11] Shorten some variable names in `wgpu::text` --- wgpu/src/text.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index d2e09e93..9a8f5c0d 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -495,8 +495,8 @@ fn prepare( let ( buffer, bounds, - horizontal_alignment, - vertical_alignment, + align_x, + align_y, color, clip_bounds, transformation, @@ -550,8 +550,8 @@ fn prepare( } Text::Cached { bounds, - align_x: horizontal_alignment, - align_y: vertical_alignment, + align_x, + align_y, color, clip_bounds, .. @@ -566,8 +566,8 @@ fn prepare( ( &entry.buffer, Rectangle::new(bounds.position(), entry.min_bounds), - *horizontal_alignment, - *vertical_alignment, + *align_x, + *align_y, *color, *clip_bounds, Transformation::IDENTITY, @@ -603,7 +603,7 @@ fn prepare( let bounds = bounds * transformation * layer_transformation; - let left = match horizontal_alignment { + let left = match align_x { Alignment::Default | Alignment::Left | Alignment::Justified => { bounds.x } @@ -611,7 +611,7 @@ fn prepare( Alignment::Right => bounds.x - bounds.width, }; - let top = match vertical_alignment { + let top = match align_y { alignment::Vertical::Top => bounds.y, alignment::Vertical::Center => bounds.y - bounds.height / 2.0, alignment::Vertical::Bottom => bounds.y - bounds.height, From 23cff08e46abb751eaaaac3304c61fdfa9d6c506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 11 Mar 2025 02:41:45 +0100 Subject: [PATCH 10/11] Stop mentioning `dodrio` in `tour` example --- Cargo.lock | 1 + examples/tour/Cargo.toml | 2 ++ examples/tour/src/main.rs | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f8bbe56..8aebb086 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6026,6 +6026,7 @@ dependencies = [ "console_error_panic_hook", "console_log", "iced", + "open", "tracing-subscriber", ] diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml index 0666e768..959ade43 100644 --- a/examples/tour/Cargo.toml +++ b/examples/tour/Cargo.toml @@ -9,6 +9,8 @@ publish = false iced.workspace = true iced.features = ["image", "debug"] +open = "5" + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tracing-subscriber = "0.3" diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 0a4d16cb..49abd3d7 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -1,9 +1,11 @@ +use iced::border; use iced::widget::{Button, Column, Container, Slider}; use iced::widget::{ button, center_x, center_y, checkbox, column, horizontal_space, image, - radio, row, scrollable, slider, text, text_input, toggler, vertical_space, + radio, rich_text, row, scrollable, slider, span, text, text_input, toggler, + vertical_space, }; -use iced::{Center, Color, Element, Fill, Font, Pixels}; +use iced::{Center, Color, Element, Fill, Font, Pixels, Theme}; pub fn main() -> iced::Result { #[cfg(target_arch = "wasm32")] @@ -54,6 +56,7 @@ pub enum Message { ToggleTextInputIcon(bool), DebugToggled(bool), TogglerChanged(bool), + OpenTrunk, } impl Tour { @@ -130,6 +133,9 @@ impl Tour { Message::TogglerChanged(toggler) => { self.toggler = toggler; } + Message::OpenTrunk => { + let _ = open::that_in_background("https://trunkrs.dev"); + } } } @@ -210,10 +216,28 @@ impl Tour { built on top of wgpu, a graphics library supporting Vulkan, \ Metal, DX11, and DX12.", ) - .push( - "Additionally, this tour can also run on WebAssembly \ - thanks to dodrio, an experimental VDOM library for Rust.", - ) + .push({ + let theme = Theme::default(); + let palette = theme.extended_palette(); + + rich_text![ + "Additionally, this tour can also run on WebAssembly ", + "by leveraging ", + span("trunk") + .color(palette.primary.base.color) + .background(palette.background.weakest.color) + .border( + border::rounded(2) + .width(1) + .color(palette.background.weak.color) + ) + .padding([0, 2]) + .font(Font::MONOSPACE) + .link(Message::OpenTrunk), + "." + ] + .on_link_click(std::convert::identity) + }) .push( "You will need to interact with the UI in order to reach \ the end!", From 0253d9bee0db51e38d7e419671de3bf9ffad2430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 11 Mar 2025 02:51:05 +0100 Subject: [PATCH 11/11] Remove `open` dependency for `tour` on Wasm --- examples/tour/Cargo.toml | 3 +-- examples/tour/src/main.rs | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml index 959ade43..de9cc724 100644 --- a/examples/tour/Cargo.toml +++ b/examples/tour/Cargo.toml @@ -9,10 +9,9 @@ publish = false iced.workspace = true iced.features = ["image", "debug"] -open = "5" - [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tracing-subscriber = "0.3" +open = "5" [target.'cfg(target_arch = "wasm32")'.dependencies] iced.workspace = true diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 49abd3d7..060cd6d0 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -134,6 +134,7 @@ impl Tour { self.toggler = toggler; } Message::OpenTrunk => { + #[cfg(not(target_arch = "wasm32"))] let _ = open::that_in_background("https://trunkrs.dev"); } }