diff --git a/Cargo.lock b/Cargo.lock index af59ee4..054c310 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" dependencies = [ "android-properties", - "bitflags 2.13.1", + "bitflags 2.13.2", "cc", "jni", "libc", @@ -77,7 +77,7 @@ dependencies = [ "ndk-context", "ndk-sys", "num_enum", - "thiserror 2.0.19", + "thiserror 2.0.21", ] [[package]] @@ -97,9 +97,9 @@ checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" [[package]] name = "android_system_properties" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" dependencies = [ "libc", ] @@ -112,9 +112,9 @@ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "arbitrary" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" +checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" [[package]] name = "arg_enum_proc_macro" @@ -214,7 +214,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 1.1.4", + "rustix 1.1.5", "slab", "windows-sys 0.61.2", ] @@ -245,18 +245,18 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix 1.1.4", + "rustix 1.1.5", ] [[package]] name = "async-recursion" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" dependencies = [ "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -271,7 +271,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 1.1.4", + "rustix 1.1.5", "signal-hook-registry", "slab", "windows-sys 0.61.2", @@ -285,13 +285,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.91" +version = "0.1.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae36dc4177970ef04fde5178d3e2429882def40e57a451f919c098f72baa6cec" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.9", ] [[package]] @@ -321,7 +321,7 @@ dependencies = [ "num-traits", "pastey", "rayon", - "thiserror 2.0.19", + "thiserror 2.0.21", "v_frame", "y4m", ] @@ -378,9 +378,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.13.1" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] name = "bitstream-io" @@ -403,7 +403,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "objc2 0.5.2", + "objc2 0.5.3", ] [[package]] @@ -412,14 +412,14 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" dependencies = [ - "objc2 0.6.4", + "objc2 0.6.5", ] [[package]] name = "blocking" -version = "1.6.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" dependencies = [ "async-channel", "async-task", @@ -451,13 +451,13 @@ dependencies = [ [[package]] name = "bytemuck_derive" -version = "1.11.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65693059b6b9c588b9f62fed1cedbf0a8b805631457ea162d68f0de186f3de5" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] @@ -478,7 +478,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "log", "polling", "rustix 0.38.44", @@ -488,14 +488,13 @@ dependencies = [ [[package]] name = "calloop" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dbf9978365bac10f54d1d4b04f7ce4427e51f71d61f2fe15e3fed5166474df7" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "polling", - "rustix 1.1.4", - "slab", + "rustix 1.1.5", "tracing", ] @@ -517,17 +516,17 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" dependencies = [ - "calloop 0.14.4", - "rustix 1.1.4", + "calloop 0.14.5", + "rustix 1.1.5", "wayland-backend", "wayland-client", ] [[package]] name = "cc" -version = "1.4.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5add81bb678e6cb321aff7fa0dc7689ad82b112dbc032cea19f91d6b8e3582b9" +checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" dependencies = [ "find-msvc-tools", "jobserver", @@ -537,9 +536,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] name = "cfg_aliases" @@ -562,9 +561,9 @@ dependencies = [ [[package]] name = "clipboard-win" -version = "5.4.1" +version = "5.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" dependencies = [ "error-code", ] @@ -575,7 +574,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7f4aaa047ba3c3630b080bb9860894732ff23e2aee290a418909aa6d5df38f" dependencies = [ - "objc2 0.5.2", + "objc2 0.5.3", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", ] @@ -595,7 +594,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd63e33452ffdafd39924c4f05a5dd1e94db646c779c6bd59148a3d95fff5ad4" dependencies = [ - "thiserror 2.0.19", + "thiserror 2.0.21", "x11rb", ] @@ -618,9 +617,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "combine" -version = "4.6.7" +version = "4.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" dependencies = [ "bytes", "memchr", @@ -691,11 +690,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "core-foundation 0.10.1", "libc", ] +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + [[package]] name = "core_maths" version = "0.1.1" @@ -711,7 +716,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "173852283a9a57a3cbe365d86e74dc428a09c50421477d5ad6fe9d9509e37737" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "fontdb", "harfrust", "linebender_resource_handle", @@ -731,18 +736,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.5.0" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-deque" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5181e0de7b61eb03a81e347d6dd8797bae9da5146707b51077e2d71a54ec0ceb" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -750,18 +755,18 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.20" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" [[package]] name = "crunchy" @@ -809,8 +814,8 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", ] [[package]] @@ -851,17 +856,22 @@ checksum = "edf234dd1594d6dd434a8fb8cada51ddbbc593e40e4a01556a0b31c62da2775b" [[package]] name = "either" -version = "1.17.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "encoding_rs" -version = "0.8.35" +version = "0.8.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" dependencies = [ "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", ] [[package]] @@ -913,9 +923,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" [[package]] name = "errno" @@ -929,9 +939,9 @@ dependencies = [ [[package]] name = "error-code" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" [[package]] name = "etagere" @@ -981,7 +991,7 @@ dependencies = [ "bit_field", "half", "lebe", - "miniz_oxide", + "miniz_oxide 0.8.9", "num-complex", "pulp", "rayon-core", @@ -1018,18 +1028,19 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.9" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" [[package]] name = "flate2" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.9.1", + "zlib-rs", ] [[package]] @@ -1061,9 +1072,9 @@ dependencies = [ [[package]] name = "font-types" -version = "0.12.2" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a7299a780854a6d391be2ae1c8521c9368471b559dbfd6a8dbd9f407eaff100" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" dependencies = [ "bytemuck", ] @@ -1109,7 +1120,7 @@ checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.9", ] [[package]] @@ -1120,9 +1131,9 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "futures" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88cf1f829d945f548cf8fec32c61b1f202b6d93b45848602fc02af4b12ad218" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" dependencies = [ "futures-channel", "futures-core", @@ -1135,9 +1146,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -1145,15 +1156,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6754879cc9f2c66f88c6e5c35344bb0bdb0708b0352b1201815667c7eabc7458" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" dependencies = [ "futures-core", "futures-task", @@ -1162,9 +1173,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4577ecaa3c4f96589d473f679a71b596316f6641bc350038b962a5daf0085d7a" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-lite" @@ -1181,32 +1192,32 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6d3cde68c518367be28956066ddfef33813991b77a55005a69dae04bf3b10b" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", ] [[package]] name = "futures-sink" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34418ac499d6305c2fb5ad0ed2f6ac998c5f8ca209b4510f7f94242c647e307" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -1225,7 +1236,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix 1.1.4", + "rustix 1.1.5", "windows-link", ] @@ -1306,7 +1317,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45cf04b2726f02df5508c6de726acdc90cdf97ac771a9a0ffd8ba10a6e696bf9" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "gpu-alloc-types", ] @@ -1316,7 +1327,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2bbed164dd10ed526c2e4fe3e721ca4a71c61730e5aafac6844b417b3227058" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", ] [[package]] @@ -1337,7 +1348,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "gpu-descriptor-types", "hashbrown 0.15.5", ] @@ -1348,7 +1359,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", ] [[package]] @@ -1379,7 +1390,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92c020db12c71d8a12a3fe7607873cade3a01a6287e29d540c8723276221b9d8" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "bytemuck", "core_maths", "read-fonts 0.35.0", @@ -1418,9 +1429,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" [[package]] name = "hex" @@ -1472,7 +1483,7 @@ dependencies = [ "iced_widget", "iced_winit", "image", - "thiserror 2.0.19", + "thiserror 2.0.21", ] [[package]] @@ -1497,7 +1508,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ab1937d699403e7e69252ae743a902bcee9f4ab2052cc4c9a46fcf34729d85" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "bytes", "glam", "lilt", @@ -1505,7 +1516,7 @@ dependencies = [ "num-traits", "rustc-hash 2.1.3", "smol_str", - "thiserror 2.0.19", + "thiserror 2.0.21", "web-time", ] @@ -1522,9 +1533,9 @@ dependencies = [ [[package]] name = "iced_drop" -version = "0.2.41" +version = "0.2.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d65ae3343a07d9e5211df26552b1e2a16e1ff74a9744cb0e9045e6079b899ab" +checksum = "2a83a84bafcdc9b7db7419734babd0e48397c0e307e375ded755cf746c7e6f21" dependencies = [ "iced", "iced_core", @@ -1576,7 +1587,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234ca1c2cec4155055f68fa5fad1b5242c496ac8238d80a259bca382fb44a102" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "bytemuck", "cosmic-text", "half", @@ -1588,7 +1599,7 @@ dependencies = [ "lyon_path", "raw-window-handle", "rustc-hash 2.1.3", - "thiserror 2.0.19", + "thiserror 2.0.21", "unicode-segmentation", ] @@ -1612,7 +1623,7 @@ dependencies = [ "iced_tiny_skia", "iced_wgpu", "log", - "thiserror 2.0.19", + "thiserror 2.0.21", ] [[package]] @@ -1625,14 +1636,14 @@ dependencies = [ "iced_core", "iced_futures", "raw-window-handle", - "thiserror 2.0.19", + "thiserror 2.0.21", ] [[package]] name = "iced_tiny_skia" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0acf8b75a3bc914aff5f2329fdffc1b36eeaea29dda0e4bd232f1c62e9cc3d" +checksum = "c267596d742714b1853cc10c3983a367762816fc4836bd3b79f76ce76787d6f8" dependencies = [ "bytemuck", "cosmic-text", @@ -1651,7 +1662,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff144a999b0ca0f8a10257934500060240825c42e950ec0ebee9c8ae30561c13" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "bytemuck", "cryoglyph", "futures", @@ -1662,7 +1673,7 @@ dependencies = [ "log", "lyon", "rustc-hash 2.1.3", - "thiserror 2.0.19", + "thiserror 2.0.21", "wgpu", ] @@ -1677,22 +1688,22 @@ dependencies = [ "num-traits", "ouroboros", "rustc-hash 2.1.3", - "thiserror 2.0.19", + "thiserror 2.0.21", "unicode-segmentation", ] [[package]] name = "iced_winit" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7dbedc47562d1de3b9707d939f678b88c382004b7ab5a18f7a7dd723162d75" +checksum = "7589888c8e951899cc688247a69933bb7a0511f0b4b2e122ac3fcd5dacb37f72" dependencies = [ "iced_debug", "iced_program", "log", "mundy", "rustc-hash 2.1.3", - "thiserror 2.0.19", + "thiserror 2.0.21", "tracing", "wasm-bindgen-futures", "web-sys", @@ -1736,15 +1747,15 @@ dependencies = [ [[package]] name = "imgref" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89194689a993ab15268672e99e7b0e19da2da3268ac682e8f02d29d4d1434cd7" +checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f" [[package]] name = "indexmap" -version = "2.14.0" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown 0.17.1", @@ -1788,7 +1799,7 @@ dependencies = [ "jni-sys 0.4.1", "log", "simd_cesu8", - "thiserror 2.0.19", + "thiserror 2.0.21", "walkdir", "windows-link", ] @@ -1846,9 +1857,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.103" +version = "0.3.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" dependencies = [ "cfg-if", "futures-util", @@ -1893,9 +1904,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" [[package]] name = "lebe" @@ -1905,9 +1916,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" [[package]] name = "libc" -version = "0.2.189" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "libfuzzer-sys" @@ -1937,14 +1948,14 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.19" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2026a5056764a10b2bf5d56488cba40da507f5493a6a429340e2004d9ed085fa" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "libc", "plain", - "redox_syscall 0.9.1", + "redox_syscall 0.9.5", ] [[package]] @@ -1976,9 +1987,9 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litrs" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" [[package]] name = "lock_api" @@ -1991,9 +2002,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "loop9" @@ -2022,9 +2033,9 @@ dependencies = [ [[package]] name = "lyon_algorithms" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8575c0d003ae459399623c4def180c63b77f343b1a7fee64f249b349e7699a31" +checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" dependencies = [ "lyon_path", "num-traits", @@ -2032,9 +2043,9 @@ dependencies = [ [[package]] name = "lyon_geom" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4336502e29e32af93cf2dad2214ed6003c17ceb5bd499df77b1de663b9042b92" +checksum = "d82dd26aa4dc0b5b70b9115de59824842bcb43cf4a28e1b1e6d0ad148c93f93e" dependencies = [ "arrayvec", "euclid", @@ -2053,9 +2064,9 @@ dependencies = [ [[package]] name = "lyon_tessellation" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e43b7e44161571868f5c931d12583592c223c5583eef86b08aa02b7048a3552" +checksum = "fd4872650e70dc907dd4f7ebc449d7d657a0d2658e423b2e724970870bbbf75b" dependencies = [ "float_next_after", "lyon_path", @@ -2073,7 +2084,7 @@ dependencies = [ [[package]] name = "maolan-widgets" -version = "0.0.43" +version = "0.0.44" dependencies = [ "iced", "iced_aw", @@ -2101,9 +2112,9 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memmap2" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" dependencies = [ "libc", ] @@ -2123,7 +2134,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00c15a6f673ff72ddcc22394663290f870fb224c1bfce55734a75c414150e605" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block", "core-graphics-types 0.2.0", "foreign-types", @@ -2142,6 +2153,16 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + [[package]] name = "moxcms" version = "0.8.1" @@ -2152,6 +2173,12 @@ dependencies = [ "pxfm", ] +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + [[package]] name = "mundy" version = "0.2.3" @@ -2166,7 +2193,7 @@ dependencies = [ "futures-lite", "jni", "ndk-context", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "pin-project-lite", @@ -2191,7 +2218,7 @@ checksum = "066cf25f0e8b11ee0df221219010f213ad429855f57c494f995590c861a9a7d8" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.13.1", + "bitflags 2.13.2", "cfg-if", "cfg_aliases", "codespan-reporting", @@ -2205,7 +2232,7 @@ dependencies = [ "once_cell", "rustc-hash 1.1.0", "spirv", - "thiserror 2.0.19", + "thiserror 2.0.21", "unicode-ident", ] @@ -2215,7 +2242,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "jni-sys 0.3.1", "log", "ndk-sys", @@ -2312,9 +2339,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.46" +version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" dependencies = [ "num-traits", ] @@ -2379,9 +2406,9 @@ checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" [[package]] name = "objc2" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" dependencies = [ "objc-sys", "objc2-encode", @@ -2389,9 +2416,9 @@ dependencies = [ [[package]] name = "objc2" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" dependencies = [ "objc2-encode", ] @@ -2402,10 +2429,10 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", "libc", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-core-data 0.2.2", "objc2-core-image 0.2.2", "objc2-foundation 0.2.2", @@ -2418,10 +2445,10 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.6.2", "libc", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-cloud-kit 0.3.2", "objc2-core-data 0.3.2", "objc2-core-foundation", @@ -2439,9 +2466,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-core-location", "objc2-foundation 0.2.2", ] @@ -2452,8 +2479,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -2464,7 +2491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -2474,9 +2501,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -2486,8 +2513,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -2497,9 +2524,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "dispatch2", - "objc2 0.6.4", + "objc2 0.6.5", ] [[package]] @@ -2508,9 +2535,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "dispatch2", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-io-surface", ] @@ -2522,7 +2549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", "objc2-metal", ] @@ -2533,7 +2560,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" dependencies = [ - "objc2 0.6.4", + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -2544,7 +2571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-contacts", "objc2-foundation 0.2.2", ] @@ -2555,8 +2582,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", ] @@ -2567,8 +2594,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", "objc2-io-surface", @@ -2586,11 +2613,11 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", "dispatch", "libc", - "objc2 0.5.2", + "objc2 0.5.3", ] [[package]] @@ -2599,10 +2626,10 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.6.2", "libc", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", ] @@ -2612,8 +2639,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", ] @@ -2624,7 +2651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", ] @@ -2635,9 +2662,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -2647,9 +2674,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", "objc2-metal", ] @@ -2660,8 +2687,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" dependencies = [ - "bitflags 2.13.1", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", "objc2-foundation 0.3.2", ] @@ -2672,7 +2699,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" dependencies = [ - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -2682,9 +2709,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-cloud-kit 0.2.2", "objc2-core-data 0.2.2", "objc2-core-image 0.2.2", @@ -2704,7 +2731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -2714,9 +2741,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-core-location", "objc2-foundation 0.2.2", ] @@ -2739,9 +2766,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "5.3.0" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7d950ca161dc355eaf28f82b11345ed76c6e1f6eb1f4f4479e0323b9e2fbd0e" +checksum = "8c7c9e0d9b23589f26070720bac724174bfec1083e82f7854cdd0267518343c0" dependencies = [ "num-traits", ] @@ -2864,9 +2891,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pin-utils" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113" [[package]] name = "piper" @@ -2881,9 +2908,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "plain" @@ -2897,11 +2924,11 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide", + "miniz_oxide 0.8.9", ] [[package]] @@ -2914,21 +2941,21 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 1.1.4", + "rustix 1.1.5", "windows-sys 0.61.2", ] [[package]] name = "portable-atomic" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" [[package]] name = "portable-atomic-util" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" dependencies = [ "portable-atomic", ] @@ -3109,9 +3136,9 @@ checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" [[package]] name = "rangemap" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "973443cf09a9c8656b574a866ab68dfa19f0867d0340648c7d2f6a71b8a8ea68" +checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" [[package]] name = "rav1e" @@ -3143,7 +3170,7 @@ dependencies = [ "rand", "rand_chacha", "simd_helpers", - "thiserror 2.0.19", + "thiserror 2.0.21", "v_frame", "wasm-bindgen", ] @@ -3169,7 +3196,7 @@ version = "11.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", ] [[package]] @@ -3216,7 +3243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" dependencies = [ "bytemuck", - "font-types 0.12.2", + "font-types 0.12.7", "once_cell", ] @@ -3241,16 +3268,16 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", ] [[package]] name = "redox_syscall" -version = "0.9.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07507be7b4a5f9f26eeb41eeaebb1f5a7ff29dfb29739facc21d35bf8b11c21e" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", ] [[package]] @@ -3298,7 +3325,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.4.15", @@ -3307,11 +3334,11 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.12.1", @@ -3397,7 +3424,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.9", ] [[package]] @@ -3408,7 +3435,7 @@ checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.9", ] [[package]] @@ -3495,9 +3522,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.15.2" +version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" [[package]] name = "smithay-client-toolkit" @@ -3505,7 +3532,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "calloop 0.13.0", "calloop-wayland-source 0.3.0", "cursor-icon", @@ -3530,15 +3557,15 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" dependencies = [ - "bitflags 2.13.1", - "calloop 0.14.4", + "bitflags 2.13.2", + "calloop 0.14.5", "calloop-wayland-source 0.4.1", "cursor-icon", "libc", "log", "memmap2", - "rustix 1.1.4", - "thiserror 2.0.19", + "rustix 1.1.5", + "thiserror 2.0.21", "wayland-backend", "wayland-client", "wayland-csd-frame", @@ -3583,14 +3610,14 @@ dependencies = [ "js-sys", "memmap2", "ndk", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", "raw-window-handle", "redox_syscall 0.5.18", - "rustix 1.1.4", + "rustix 1.1.5", "tiny-xlib", "tracing", "wasm-bindgen", @@ -3608,7 +3635,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.13.1", + "bitflags 2.13.2", ] [[package]] @@ -3792,9 +3819,9 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.3" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" dependencies = [ "proc-macro2", "quote", @@ -3819,7 +3846,7 @@ dependencies = [ "fastrand", "getrandom 0.4.3", "once_cell", - "rustix 1.1.4", + "rustix 1.1.5", "windows-sys 0.61.2", ] @@ -3843,11 +3870,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.19" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" dependencies = [ - "thiserror-impl 2.0.19", + "thiserror-impl 2.0.21", ] [[package]] @@ -3863,13 +3890,13 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.19" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn 3.0.3", + "syn 3.0.9", ] [[package]] @@ -3926,42 +3953,33 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" [[package]] name = "tokio" -version = "1.53.1" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ "pin-project-lite", ] [[package]] name = "toml_datetime" -version = "1.1.1+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" dependencies = [ "serde_core", ] [[package]] name = "toml_edit" -version = "0.25.13+spec-1.1.0" +version = "0.25.17+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" +checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" dependencies = [ "indexmap", "toml_datetime", @@ -3971,9 +3989,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.1.3+spec-1.1.0" +version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" dependencies = [ "winnow", ] @@ -4038,9 +4056,9 @@ checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" -version = "1.0.24" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] name = "unicode-linebreak" @@ -4068,9 +4086,9 @@ checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "uuid" -version = "1.24.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3923a6f5c4c6382e0b653c4117f48d631ea17f38ed86e2a828e6f7412f5239" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" dependencies = [ "js-sys", "serde_core", @@ -4115,9 +4133,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" dependencies = [ "cfg-if", "once_cell", @@ -4128,19 +4146,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.76" +version = "0.4.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" dependencies = [ "js-sys", + "tokio", "wasm-bindgen", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4148,22 +4167,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" dependencies = [ "unicode-ident", ] @@ -4184,13 +4203,13 @@ dependencies = [ [[package]] name = "wayland-backend" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016ccf01d1c58b6f8999612813e17c9b2390f7d70671428869913310f83f54b8" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" dependencies = [ "cc", "downcast-rs", - "rustix 1.1.4", + "rustix 1.1.5", "scoped-tls", "smallvec", "wayland-sys", @@ -4202,8 +4221,8 @@ version = "0.31.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" dependencies = [ - "bitflags 2.13.1", - "rustix 1.1.4", + "bitflags 2.13.2", + "rustix 1.1.5", "wayland-backend", "wayland-scanner", ] @@ -4214,7 +4233,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "cursor-icon", "wayland-backend", ] @@ -4225,7 +4244,7 @@ version = "0.31.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" dependencies = [ - "rustix 1.1.4", + "rustix 1.1.5", "wayland-client", "xcursor", ] @@ -4236,7 +4255,7 @@ version = "0.32.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-scanner", @@ -4248,7 +4267,7 @@ version = "20250721.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-protocols", @@ -4261,7 +4280,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-protocols", @@ -4274,7 +4293,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-protocols", @@ -4287,7 +4306,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-protocols", @@ -4319,9 +4338,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.103" +version = "0.3.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" dependencies = [ "js-sys", "wasm-bindgen", @@ -4350,7 +4369,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfe68bac7cde125de7a731c3400723cadaaf1703795ad3f4805f187459cd7a77" dependencies = [ "arrayvec", - "bitflags 2.13.1", + "bitflags 2.13.2", "cfg-if", "cfg_aliases", "document-features", @@ -4381,7 +4400,7 @@ dependencies = [ "arrayvec", "bit-set", "bit-vec", - "bitflags 2.13.1", + "bitflags 2.13.2", "bytemuck", "cfg_aliases", "document-features", @@ -4396,7 +4415,7 @@ dependencies = [ "raw-window-handle", "rustc-hash 1.1.0", "smallvec", - "thiserror 2.0.19", + "thiserror 2.0.21", "wgpu-core-deps-apple", "wgpu-core-deps-emscripten", "wgpu-core-deps-windows-linux-android", @@ -4441,7 +4460,7 @@ dependencies = [ "arrayvec", "ash", "bit-set", - "bitflags 2.13.1", + "bitflags 2.13.2", "block", "bytemuck", "cfg-if", @@ -4472,7 +4491,7 @@ dependencies = [ "raw-window-handle", "renderdoc-sys", "smallvec", - "thiserror 2.0.19", + "thiserror 2.0.21", "wasm-bindgen", "web-sys", "wgpu-types", @@ -4486,11 +4505,11 @@ version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afdcf84c395990db737f2dd91628706cb31e86d72e53482320d368e52b5da5eb" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "bytemuck", "js-sys", "log", - "thiserror 2.0.19", + "thiserror 2.0.21", "web-sys", ] @@ -4514,7 +4533,7 @@ dependencies = [ "clipboard_wayland", "clipboard_x11", "raw-window-handle", - "thiserror 2.0.19", + "thiserror 2.0.21", ] [[package]] @@ -4791,7 +4810,7 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.13.1", + "bitflags 2.13.2", "block2 0.5.1", "bytemuck", "calloop 0.13.0", @@ -4805,7 +4824,7 @@ dependencies = [ "libc", "memmap2", "ndk", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", "objc2-ui-kit", @@ -4871,7 +4890,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix 1.1.4", + "rustix 1.1.5", "x11rb-protocol", ] @@ -4893,7 +4912,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.13.1", + "bitflags 2.13.2", "dlib", "log", "once_cell", @@ -4908,9 +4927,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xml-rs" -version = "0.8.28" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" [[package]] name = "y4m" @@ -4932,9 +4951,9 @@ checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5" [[package]] name = "zbus" -version = "5.18.0" +version = "5.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe18fb60dc696039e738717b76eaea21e7a4489bbb1885020b43c94236d7e98a" +checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907" dependencies = [ "async-broadcast", "async-executor", @@ -4952,7 +4971,7 @@ dependencies = [ "hex", "libc", "ordered-stream", - "rustix 1.1.4", + "rustix 1.1.5", "serde", "serde_repr", "tracing", @@ -4967,14 +4986,14 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "5.18.0" +version = "5.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe96480bed92df2b442a1a30df364e12d08eed03aeb061f2b8dc6afb2be91119" +checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", "zbus_names", "zvariant", "zvariant_utils", @@ -4982,15 +5001,24 @@ dependencies = [ [[package]] name = "zbus_names" -version = "4.3.4" +version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bf88b4a3ff53e883001e0e0115b297a9d53c31b9c1edd2bfdd853e3428624e" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" dependencies = [ "serde", "winnow", "zvariant", ] +[[package]] +name = "zcheapstr" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1afec51604565183aeb5c54c20aeab286120d4e4460f7f76e3e8bb8c0d99473" +dependencies = [ + "serde", +] + [[package]] name = "zeno" version = "0.3.3" @@ -4999,29 +5027,35 @@ checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" [[package]] name = "zerocopy" -version = "0.8.55" +version = "0.8.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a105cd7b140f6eeec8acff2ea38135d3cab283ada58540f629fe51e46696eb" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.55" +version = "0.8.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe976fb70c78cd64cccfe3a6fc142244e8a77b70959b30faf9d0ac37ee228eb" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" dependencies = [ "proc-macro2", "quote", "syn 2.0.119", ] +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + [[package]] name = "zune-core" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" [[package]] name = "zune-inflate" @@ -5043,40 +5077,41 @@ dependencies = [ [[package]] name = "zvariant" -version = "5.13.1" +version = "5.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee2a0bcd2a907786a456fff45aaaaf54c9ba5f50b71ae9ec1a4edd200c94911" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" dependencies = [ "endi", "enumflags2", "serde", "winnow", + "zcheapstr", "zvariant_derive", "zvariant_utils", ] [[package]] name = "zvariant_derive" -version = "5.13.1" +version = "5.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a708216a18780796770bfe3f4739c7c83a3e8f789b755534bbbc06e4e23e12" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.9", "zvariant_utils", ] [[package]] name = "zvariant_utils" -version = "3.5.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90cb9383f9b45290407a1258b202d3f8f01db719eb60b4e4055c6375af4fc7c7" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.119", + "syn 3.0.9", "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index 9d1af3b..0e9da2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "maolan-widgets" -version = "0.0.43" +version = "0.0.44" edition = "2024" description = "Widgets used for Maolan DAW" license = "BSD-2-Clause" @@ -13,7 +13,7 @@ categories = ["multimedia::audio"] [dependencies] iced = { version = "0.14.0", features = ["advanced", "canvas", "image", "lazy", "tokio"] } -iced_aw = "0.14.1" +iced_aw = { version = "0.14.1", features = ["wrap"] } iced_drop = { version = "0.2.16", features = ["helpers"] } iced_fonts = { version = "0.3.0", features = ["lucide"] } serde = { version = "1.0.229", features = ["derive"] } diff --git a/src/arch_range_slider.rs b/src/arch_range_slider.rs new file mode 100644 index 0000000..603d027 --- /dev/null +++ b/src/arch_range_slider.rs @@ -0,0 +1,684 @@ +use crate::consts::DOUBLE_CLICK; +use iced::advanced::Shell; +use iced::advanced::graphics::geometry; +use iced::advanced::layout::{self, Layout}; +use iced::advanced::renderer; +use iced::advanced::widget::{self, Tree, Widget}; +use iced::widget::canvas::path::Arc as PathArc; +use iced::widget::canvas::{Frame, Path, Stroke}; +use iced::{Color, Element, Event, Length, Point, Radians, Rectangle, Size, Vector}; +use iced::{keyboard, mouse}; +use std::cell::Cell; +use std::f32::consts::PI; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::time::Instant; + +const START_ANGLE: f32 = 3.0 * PI / 4.0; +const SWEEP_ANGLE: f32 = 3.0 * PI / 2.0; +const END_ANGLE: f32 = START_ANGLE + SWEEP_ANGLE; +static NEXT_OWNER_ID: AtomicU64 = AtomicU64::new(1); + +thread_local! { + static ACTIVE_DRAG_OWNER: Cell> = const { Cell::new(None) }; +} + +/// A knob-style arch slider with two handles editing a `low..=high` value +/// pair. Dragging moves the high handle, Shift+dragging moves the low handle, +/// and the handles cannot cross. Double-click resets the pair to the full +/// range. +pub struct ArchRangeSlider<'a, Message> { + range: std::ops::RangeInclusive, + low: f32, + high: f32, + on_change: Box Message + 'a>, + width: Length, + height: Length, + handle_radius: f32, + track_width: f32, + step: Option, + filled_color: Color, + handle_color: Color, + on_release: Option, + on_right_click: Option, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum DraggedHandle { + Low, + High, +} + +impl<'a, Message> ArchRangeSlider<'a, Message> { + pub fn new(range: std::ops::RangeInclusive, low: f32, high: f32, on_change: F) -> Self + where + F: Fn(f32, f32) -> Message + 'a, + { + Self { + range, + low, + high, + on_change: Box::new(on_change), + width: Length::Fixed(64.0), + height: Length::Fixed(64.0), + handle_radius: 4.0, + track_width: 6.0, + step: None, + filled_color: Color::from_rgb( + 0x29 as f32 / 255.0, + 0x66 as f32 / 255.0, + 0xA3 as f32 / 255.0, + ), + handle_color: Color::from_rgb( + 0x75 as f32 / 255.0, + 0xC2 as f32 / 255.0, + 0xFF as f32 / 255.0, + ), + on_release: None, + on_right_click: None, + } + } + + pub fn width(mut self, width: Length) -> Self { + self.width = width; + self + } + + pub fn height(mut self, height: Length) -> Self { + self.height = height; + self + } + + pub fn track_width(mut self, track_width: f32) -> Self { + self.track_width = track_width.max(1.0); + self + } + + pub fn handle_radius(mut self, handle_radius: f32) -> Self { + self.handle_radius = handle_radius.max(0.5); + self + } + + pub fn step(mut self, step: f32) -> Self { + self.step = Some(step.abs()).filter(|step| *step > 0.0); + self + } + + pub fn filled_color(mut self, color: Color) -> Self { + self.filled_color = color; + self + } + + pub fn handle_color(mut self, color: Color) -> Self { + self.handle_color = color; + self + } + + pub fn on_release(mut self, message: Message) -> Self { + self.on_release = Some(message); + self + } + + pub fn on_right_click(mut self, message: Message) -> Self { + self.on_right_click = Some(message); + self + } +} + +pub fn arch_range_slider<'a, Message, F>( + range: std::ops::RangeInclusive, + low: f32, + high: f32, + on_change: F, +) -> ArchRangeSlider<'a, Message> +where + F: Fn(f32, f32) -> Message + 'a, +{ + ArchRangeSlider::new(range, low, high, on_change) +} + +fn value_angle(value: f32, start: f32, end: f32) -> f32 { + let normalized = if end > start { + (value - start) / (end - start) + } else { + 0.0 + }; + normalized.clamp(0.0, 1.0) * SWEEP_ANGLE +} + +fn drag_value(start_value: f32, delta_y: f32, range_size: f32) -> f32 { + start_value + (delta_y / 200.0) * range_size +} + +fn clamp_to_step(value: f32, start: f32, end: f32, step: Option) -> f32 { + let clamped = value.clamp(start, end); + let Some(step) = step else { + return clamped; + }; + let steps = ((clamped - start) / step).round(); + (start + steps * step).clamp(start, end) +} + +fn clamp_pair( + dragged: f32, + other: f32, + handle: DraggedHandle, + start: f32, + end: f32, + step: Option, +) -> (f32, f32) { + match handle { + DraggedHandle::Low => { + let low = clamp_to_step(dragged.min(other), start, end, step); + (low, clamp_to_step(other, start, end, step).max(low)) + } + DraggedHandle::High => { + let high = clamp_to_step(dragged.max(other), start, end, step); + (clamp_to_step(other, start, end, step).min(high), high) + } + } +} + +struct State { + owner_id: u64, + dragging: Option, + last_click_at: Option, + modifiers: keyboard::Modifiers, + drag_start_y: f32, + drag_start_low: f32, + drag_start_high: f32, +} + +impl Default for State { + fn default() -> Self { + Self { + owner_id: NEXT_OWNER_ID.fetch_add(1, Ordering::Relaxed), + dragging: None, + last_click_at: None, + modifiers: keyboard::Modifiers::default(), + drag_start_y: 0.0, + drag_start_low: 0.0, + drag_start_high: 0.0, + } + } +} + +impl<'a, Message, Theme, Renderer> Widget for ArchRangeSlider<'a, Message> +where + Renderer: geometry::Renderer, + Message: Clone, +{ + fn size(&self) -> Size { + Size { + width: self.width, + height: self.height, + } + } + + fn layout( + &mut self, + _tree: &mut Tree, + _renderer: &Renderer, + limits: &layout::Limits, + ) -> layout::Node { + let size = limits.width(self.width).height(self.height).resolve( + self.width, + self.height, + Size::ZERO, + ); + layout::Node::new(size) + } + + fn draw( + &self, + _tree: &Tree, + renderer: &mut Renderer, + _theme: &Theme, + _style: &renderer::Style, + layout: Layout<'_>, + _cursor: mouse::Cursor, + _viewport: &Rectangle, + ) { + let bounds = layout.bounds(); + let center = Point::new(bounds.width / 2.0, bounds.height / 2.0); + let radius = (center.x.min(center.y) - self.handle_radius - 2.0).max(1.0); + + let low_angle = value_angle(self.low, *self.range.start(), *self.range.end()); + let high_angle = value_angle(self.high, *self.range.start(), *self.range.end()); + + let back_color = Color::from_rgb( + 0x42 as f32 / 255.0, + 0x46 as f32 / 255.0, + 0x4D as f32 / 255.0, + ); + let border_color = Color::from_rgb( + 0x30 as f32 / 255.0, + 0x33 as f32 / 255.0, + 0x3C as f32 / 255.0, + ); + + renderer.with_translation(Vector::new(bounds.x, bounds.y), |renderer| { + let mut frame = Frame::new(renderer, bounds.size()); + + let border_path = Path::new(|builder| { + builder.arc(PathArc { + center: Point::new(center.x, center.y), + radius, + start_angle: Radians(START_ANGLE), + end_angle: Radians(END_ANGLE), + }); + }); + frame.stroke( + &border_path, + Stroke::default() + .with_width(self.track_width + 2.0) + .with_color(border_color), + ); + + let track_path = Path::new(|builder| { + builder.arc(PathArc { + center: Point::new(center.x, center.y), + radius, + start_angle: Radians(START_ANGLE), + end_angle: Radians(END_ANGLE), + }); + }); + frame.stroke( + &track_path, + Stroke::default() + .with_width(self.track_width) + .with_color(back_color), + ); + + if high_angle > low_angle { + let filled_path = Path::new(|builder| { + builder.arc(PathArc { + center: Point::new(center.x, center.y), + radius, + start_angle: Radians(START_ANGLE + low_angle), + end_angle: Radians(START_ANGLE + high_angle), + }); + }); + frame.stroke( + &filled_path, + Stroke::default() + .with_width(self.track_width) + .with_color(self.filled_color), + ); + } + + for angle in [low_angle, high_angle] { + let current_angle = START_ANGLE + angle; + let handle_x = center.x + current_angle.cos() * radius; + let handle_y = center.y + current_angle.sin() * radius; + let handle_path = Path::circle(Point::new(handle_x, handle_y), self.handle_radius); + frame.fill(&handle_path, self.handle_color); + } + + renderer.draw_geometry(frame.into_geometry()); + }); + } + + fn tag(&self) -> widget::tree::Tag { + widget::tree::Tag::of::() + } + + fn state(&self) -> widget::tree::State { + widget::tree::State::new(State::default()) + } + + fn update( + &mut self, + tree: &mut Tree, + event: &Event, + layout: Layout<'_>, + cursor: mouse::Cursor, + _renderer: &Renderer, + _clipboard: &mut dyn iced::advanced::Clipboard, + shell: &mut Shell<'_, Message>, + _viewport: &Rectangle, + ) { + let state = tree.state.downcast_mut::(); + let bounds = layout.bounds(); + + match event { + Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { + state.modifiers = *modifiers; + } + Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => { + if !cursor.is_over(bounds) { + if state.dragging.is_some() { + state.dragging = None; + ACTIVE_DRAG_OWNER.with(|owner| { + if owner.get() == Some(state.owner_id) { + owner.set(None); + } + }); + } + return; + } + + ACTIVE_DRAG_OWNER.with(|owner| owner.set(Some(state.owner_id))); + let now = Instant::now(); + let is_double_click = state + .last_click_at + .is_some_and(|last| now.duration_since(last) <= DOUBLE_CLICK); + state.last_click_at = Some(now); + if is_double_click { + shell.publish((self.on_change)(*self.range.start(), *self.range.end())); + } else if let Some(cursor_position) = cursor.position() { + state.dragging = Some(if state.modifiers.shift() { + DraggedHandle::Low + } else { + DraggedHandle::High + }); + state.drag_start_y = cursor_position.y; + state.drag_start_low = self.low; + state.drag_start_high = self.high; + } + } + Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Right)) => { + if !cursor.is_over(bounds) { + return; + } + if let Some(message) = self.on_right_click.as_ref() { + shell.publish(message.clone()); + } + } + Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) + if state.dragging.is_some() => + { + state.dragging = None; + ACTIVE_DRAG_OWNER.with(|owner| { + if owner.get() == Some(state.owner_id) { + owner.set(None); + } + }); + if let Some(message) = self.on_release.as_ref() { + shell.publish(message.clone()); + } + } + Event::Mouse(mouse::Event::CursorMoved { .. }) => { + if state.dragging.is_none() { + return; + } + let is_owner = ACTIVE_DRAG_OWNER.with(|owner| owner.get() == Some(state.owner_id)); + if !is_owner { + state.dragging = None; + return; + } + if let (Some(handle), Some(cursor_position)) = (state.dragging, cursor.position()) { + let delta_y = state.drag_start_y - cursor_position.y; + let range_size = self.range.end() - self.range.start(); + let start_value = match handle { + DraggedHandle::Low => state.drag_start_low, + DraggedHandle::High => state.drag_start_high, + }; + let other = match handle { + DraggedHandle::Low => state.drag_start_high, + DraggedHandle::High => state.drag_start_low, + }; + let dragged = drag_value(start_value, delta_y, range_size); + let (low, high) = clamp_pair( + dragged, + other, + handle, + *self.range.start(), + *self.range.end(), + self.step, + ); + shell.publish((self.on_change)(low, high)); + } + } + _ => {} + } + } +} + +impl<'a, Message, Theme, Renderer> From> + for Element<'a, Message, Theme, Renderer> +where + Message: 'a + Clone, + Theme: 'a, + Renderer: 'a + geometry::Renderer, +{ + fn from(slider: ArchRangeSlider<'a, Message>) -> Self { + Self::new(slider) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use iced::Event; + use iced::advanced::{ + Layout, Shell, clipboard, layout, + widget::{self, Tree, Widget}, + }; + use std::time::Instant; + + fn test_tree_with_state(state: State) -> Tree { + Tree { + tag: widget::tree::Tag::of::(), + state: widget::tree::State::new(state), + children: Vec::new(), + } + } + + fn handle_position(value: f32, bounds_size: f32) -> Point { + let radius = (bounds_size / 2.0 - 4.0 - 2.0).max(1.0); + let angle = START_ANGLE + value_angle(value, 0.0, 1.0); + Point::new( + bounds_size / 2.0 + angle.cos() * radius, + bounds_size / 2.0 + angle.sin() * radius, + ) + } + + #[test] + fn value_angle_maps_range_onto_sweep() { + assert_eq!(value_angle(0.0, 0.0, 1.0), 0.0); + assert!((value_angle(0.5, 0.0, 1.0) - SWEEP_ANGLE / 2.0).abs() < 1e-6); + assert!((value_angle(1.0, 0.0, 1.0) - SWEEP_ANGLE).abs() < 1e-6); + assert_eq!(value_angle(-1.0, 0.0, 1.0), 0.0); + assert!((value_angle(2.0, 0.0, 1.0) - SWEEP_ANGLE).abs() < 1e-6); + } + + #[test] + fn clamp_pair_prevents_handles_crossing() { + let (low, high) = clamp_pair(0.8, 0.6, DraggedHandle::Low, 0.0, 1.0, None); + assert_eq!((low, high), (0.6, 0.6)); + let (low, high) = clamp_pair(0.2, 0.4, DraggedHandle::High, 0.0, 1.0, None); + assert_eq!((low, high), (0.4, 0.4)); + } + + #[cfg(debug_assertions)] + #[test] + fn update_drag_low_handle_publishes_pair() { + let mut slider = ArchRangeSlider::new(0.0..=1.0, 0.2, 0.8, |low, high| (low, high)) + .width(Length::Fixed(100.0)) + .height(Length::Fixed(100.0)); + let mut tree = test_tree_with_state(State::default()); + let node = layout::Node::new(Size::new(100.0, 100.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(100.0, 100.0)); + let press_at = handle_position(0.2, 100.0); + + { + let mut shell = Shell::new(&mut messages); + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)), + layout, + mouse::Cursor::Available(press_at), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + } + assert!(messages.is_empty()); + + { + let mut shell = Shell::new(&mut messages); + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::CursorMoved { + position: Point::new(press_at.x, press_at.y - 50.0), + }), + layout, + mouse::Cursor::Available(Point::new(press_at.x, press_at.y - 50.0)), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + } + + assert_eq!(messages.len(), 1); + let (low, high) = messages[0]; + assert_eq!(low, 0.2); + assert!( + high > 0.8, + "plain drag should move high toward the range end: {high}" + ); + } + + #[cfg(debug_assertions)] + #[test] + fn update_shift_drag_moves_low_handle() { + let mut slider = ArchRangeSlider::new(0.0..=1.0, 0.2, 0.8, |low, high| (low, high)) + .width(Length::Fixed(100.0)) + .height(Length::Fixed(100.0)); + let mut tree = test_tree_with_state(State { + modifiers: keyboard::Modifiers::SHIFT, + ..State::default() + }); + let node = layout::Node::new(Size::new(100.0, 100.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(100.0, 100.0)); + let press_at = handle_position(0.8, 100.0); + + { + let mut shell = Shell::new(&mut messages); + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)), + layout, + mouse::Cursor::Available(press_at), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + } + assert!(messages.is_empty()); + + { + let mut shell = Shell::new(&mut messages); + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::CursorMoved { + position: Point::new(press_at.x, press_at.y - 50.0), + }), + layout, + mouse::Cursor::Available(Point::new(press_at.x, press_at.y - 50.0)), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + } + + assert_eq!(messages.len(), 1); + let (low, high) = messages[0]; + assert!( + low > 0.2 && low < 0.8, + "shift drag should move low toward high: {low}" + ); + assert_eq!(high, 0.8); + } + + #[cfg(debug_assertions)] + #[test] + fn update_double_click_resets_to_full_range() { + let mut slider = ArchRangeSlider::new(0.0..=127.0, 20.0, 100.0, |low, high| (low, high)) + .width(Length::Fixed(100.0)) + .height(Length::Fixed(100.0)); + let mut tree = test_tree_with_state(State { + dragging: None, + last_click_at: Some(Instant::now()), + drag_start_y: 0.0, + drag_start_low: 0.0, + drag_start_high: 0.0, + ..State::default() + }); + let node = layout::Node::new(Size::new(100.0, 100.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let mut shell = Shell::new(&mut messages); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(100.0, 100.0)); + + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)), + layout, + mouse::Cursor::Available(Point::new(50.0, 50.0)), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + + assert_eq!(messages, vec![(0.0, 127.0)]); + } + + #[cfg(debug_assertions)] + #[test] + fn update_publishes_release_message() { + let mut slider = ArchRangeSlider::new(0.0..=1.0, 0.2, 0.8, |low, high| (low, high)) + .width(Length::Fixed(100.0)) + .height(Length::Fixed(100.0)) + .on_release((0.0, 0.0)); + let mut tree = test_tree_with_state(State { + dragging: Some(DraggedHandle::Low), + last_click_at: None, + drag_start_y: 0.0, + drag_start_low: 0.2, + drag_start_high: 0.8, + ..State::default() + }); + let node = layout::Node::new(Size::new(100.0, 100.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let mut shell = Shell::new(&mut messages); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(100.0, 100.0)); + + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)), + layout, + mouse::Cursor::Unavailable, + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + + assert_eq!(messages, vec![(0.0, 0.0)]); + } +} diff --git a/src/arch_slider.rs b/src/arch_slider.rs index 602ccde..cb22beb 100644 --- a/src/arch_slider.rs +++ b/src/arch_slider.rs @@ -86,6 +86,16 @@ impl<'a, Message> ArchSlider<'a, Message> { self } + pub fn track_width(mut self, track_width: f32) -> Self { + self.track_width = track_width.max(1.0); + self + } + + pub fn handle_radius(mut self, handle_radius: f32) -> Self { + self.handle_radius = handle_radius.max(0.5); + self + } + pub fn step(mut self, step: f32) -> Self { self.step = Some(step.abs()).filter(|step| *step > 0.0); self diff --git a/src/lib.rs b/src/lib.rs index 356d80f..9d9c049 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub mod adsr; +pub mod arch_range_slider; pub mod arch_slider; pub mod audio; pub mod audio_setup; @@ -18,6 +19,7 @@ pub mod note_area; pub mod numeric_input; pub mod piano; pub mod piano_roll; +pub mod range_slider; pub mod slider; pub mod ticks; pub mod vertical_scrollbar; diff --git a/src/multi_toggler.rs b/src/multi_toggler.rs index cf94c34..570dbe3 100644 --- a/src/multi_toggler.rs +++ b/src/multi_toggler.rs @@ -13,11 +13,26 @@ pub enum Orientation { Vertical, } +/// Where the selected-option label is drawn relative to the option track. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +pub enum LabelPosition { + /// Label above the track (default). + #[default] + Above, + /// Label below the track. + Below, + /// Label left of the track. + Left, + /// Label right of the track. + Right, +} + pub struct MultiToggler<'a, Message> { labels: Vec, selected: usize, on_change: Box Message + 'a>, orientation: Orientation, + label_position: LabelPosition, width: Length, height: Length, text_size: Pixels, @@ -38,11 +53,16 @@ impl<'a, Message> MultiToggler<'a, Message> { L: IntoIterator, S: Into, { + let label_position = match orientation { + Orientation::Horizontal => LabelPosition::Above, + Orientation::Vertical => LabelPosition::Right, + }; Self { labels: labels.into_iter().map(Into::into).collect(), selected, on_change: Box::new(on_change), orientation, + label_position, width: Length::Shrink, height: Length::Shrink, text_size: Pixels(12.0), @@ -73,6 +93,11 @@ impl<'a, Message> MultiToggler<'a, Message> { } } + pub fn label_position(mut self, label_position: LabelPosition) -> Self { + self.label_position = label_position; + self + } + pub fn width(mut self, width: Length) -> Self { self.width = width; self @@ -140,21 +165,28 @@ impl<'a, Message> MultiToggler<'a, Message> { self.text_size.0 * 1.4 } - fn track_bounds(&self, bounds: Rectangle) -> Rectangle { + fn track_size(&self) -> Size { let count = self.option_count() as f32; match self.orientation { - Orientation::Horizontal => Rectangle { - x: bounds.x, - y: bounds.y, - width: self.size * count, - height: self.size, - }, - Orientation::Vertical => Rectangle { - x: bounds.x, - y: bounds.y, - width: self.size, - height: self.size * count, - }, + Orientation::Horizontal => Size::new(self.size * count, self.size), + Orientation::Vertical => Size::new(self.size, self.size * count), + } + } + + fn track_bounds(&self, bounds: Rectangle) -> Rectangle { + let track = self.track_size(); + let label_height = self.label_height(); + let (offset_x, offset_y) = match self.label_position { + LabelPosition::Above => (0.0, label_height + self.spacing), + LabelPosition::Below => (0.0, 0.0), + LabelPosition::Left => (self.label_extent + self.spacing, 0.0), + LabelPosition::Right => (0.0, 0.0), + }; + Rectangle { + x: bounds.x + offset_x, + y: bounds.y + offset_y, + width: track.width, + height: track.height, } } @@ -174,22 +206,31 @@ impl<'a, Message> MultiToggler<'a, Message> { fn label_bounds(&self, bounds: Rectangle) -> Rectangle { let track = self.track_bounds(bounds); let label_height = self.label_height(); - match self.orientation { - Orientation::Horizontal => Rectangle { + match self.label_position { + LabelPosition::Above => Rectangle { + x: track.x, + y: bounds.y, + width: self.label_extent, + height: label_height, + }, + LabelPosition::Below => Rectangle { x: track.x, y: track.y + track.height + self.spacing, width: self.label_extent, height: label_height, }, - Orientation::Vertical => { - let center = self.option_center(track, self.selected()); - Rectangle { - x: track.x + track.width + self.spacing, - y: center.y - label_height * 0.5, - width: self.label_extent, - height: label_height, - } - } + LabelPosition::Left => Rectangle { + x: bounds.x, + y: track.center_y() - label_height * 0.5, + width: self.label_extent, + height: label_height, + }, + LabelPosition::Right => Rectangle { + x: track.x + track.width + self.spacing, + y: track.center_y() - label_height * 0.5, + width: self.label_extent, + height: label_height, + }, } } @@ -268,15 +309,16 @@ where _renderer: &Renderer, limits: &layout::Limits, ) -> layout::Node { - let option_count = self.option_count() as f32; - let default_size = match self.orientation { - Orientation::Horizontal => Size::new( - (self.size * option_count).max(self.label_extent), - self.size + self.spacing + self.label_height(), + let track = self.track_size(); + let label_height = self.label_height(); + let default_size = match self.label_position { + LabelPosition::Above | LabelPosition::Below => Size::new( + track.width.max(self.label_extent), + label_height + self.spacing + track.height, ), - Orientation::Vertical => Size::new( - self.size + self.spacing + self.label_extent, - self.size * option_count, + LabelPosition::Left | LabelPosition::Right => Size::new( + track.width + self.spacing + self.label_extent, + track.height.max(label_height), ), }; let size = limits.width(self.width).height(self.height).resolve( @@ -462,7 +504,8 @@ mod tests { #[test] fn horizontal_index_at_uses_segments() { - let toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index); + let toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index) + .label_position(LabelPosition::Below); let bounds = Rectangle { x: 10.0, y: 20.0, @@ -477,7 +520,7 @@ mod tests { } #[test] - fn horizontal_track_and_label_are_left_aligned() { + fn horizontal_label_above_track_by_default() { let toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index); let bounds = Rectangle { x: 10.0, @@ -489,10 +532,70 @@ mod tests { let track = toggler.track_bounds(bounds); assert_eq!(track.x, bounds.x); assert_eq!(track.width, 48.0); + assert_eq!(track.y, bounds.y + toggler.label_height() + toggler.spacing); let label = toggler.label_bounds(bounds); assert_eq!(label.x, track.x); assert_eq!(label.width, 72.0); + assert!(label.y < track.y, "label should sit above the track"); + } + + #[test] + fn horizontal_label_below_places_track_at_top() { + let toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index) + .label_position(LabelPosition::Below); + let bounds = Rectangle { + x: 10.0, + y: 20.0, + width: 90.0, + height: 48.0, + }; + + let track = toggler.track_bounds(bounds); + assert_eq!(track.y, bounds.y); + + let label = toggler.label_bounds(bounds); + assert!(label.y > track.y, "label should sit below the track"); + assert_eq!(label.x, track.x); + } + + #[test] + fn label_left_pushes_track_right_and_centers_label() { + let toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index) + .label_position(LabelPosition::Left); + let bounds = Rectangle { + x: 10.0, + y: 20.0, + width: 160.0, + height: 24.0, + }; + + let track = toggler.track_bounds(bounds); + assert_eq!(track.x, bounds.x + toggler.label_extent + toggler.spacing); + assert_eq!(track.y, bounds.y); + + let label = toggler.label_bounds(bounds); + assert_eq!(label.x, bounds.x); + assert!((label.center_y() - track.center_y()).abs() < 1e-6); + } + + #[test] + fn label_right_places_label_beside_track() { + let toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index) + .label_position(LabelPosition::Right); + let bounds = Rectangle { + x: 10.0, + y: 20.0, + width: 160.0, + height: 24.0, + }; + + let track = toggler.track_bounds(bounds); + assert_eq!(track.x, bounds.x); + + let label = toggler.label_bounds(bounds); + assert_eq!(label.x, track.x + track.width + toggler.spacing); + assert!((label.center_y() - track.center_y()).abs() < 1e-6); } #[test] @@ -513,7 +616,8 @@ mod tests { #[cfg(debug_assertions)] #[test] fn click_publishes_selected_index() { - let mut toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index); + let mut toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index) + .label_position(LabelPosition::Below); let mut tree = test_tree(); let layout = test_layout(90.0, 24.0); let mut messages = Vec::new(); @@ -540,7 +644,8 @@ mod tests { #[cfg(debug_assertions)] #[test] fn drag_can_publish_return_to_starting_index() { - let mut toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index); + let mut toggler = horizontal_multi_toggler(["A", "B", "C"], 0, |index| index) + .label_position(LabelPosition::Below); let mut tree = test_tree(); let layout = test_layout(90.0, 24.0); let renderer = (); @@ -586,7 +691,8 @@ mod tests { #[cfg(debug_assertions)] #[test] fn click_on_current_index_does_not_publish() { - let mut toggler = horizontal_multi_toggler(["A", "B", "C"], 1, |index| index); + let mut toggler = horizontal_multi_toggler(["A", "B", "C"], 1, |index| index) + .label_position(LabelPosition::Below); let mut tree = test_tree(); let layout = test_layout(90.0, 24.0); let mut messages = Vec::new(); diff --git a/src/piano.rs b/src/piano.rs index 2b75550..77b3722 100644 --- a/src/piano.rs +++ b/src/piano.rs @@ -79,8 +79,16 @@ pub enum Orientation { /// wide, so white keys are exactly twice as wide as black keys. const BLACK_KEY_DEPTH_RATIO: f32 = 0.5; -/// Ratio of a white key's length that a black key occupies along the note axis. -const BLACK_KEY_LENGTH_RATIO: f32 = 0.6; +// White-key fronts meet at the center of an intervening black-key column. +// Adjacent white keys (E/F and B/C) meet at the semitone boundary. +fn white_key_end(note: u8, note_count: u8) -> f32 { + let next = note + 1; + if next < note_count && is_black_key(next) { + f32::from(next) + 0.5 + } else { + f32::from(next) + } +} fn velocity_from_v(v: f32, depth: f32) -> u8 { let normalized = (v / depth).clamp(0.0, 1.0); @@ -101,131 +109,28 @@ pub fn note_at_in_range( if note_count == 0 { return None; } - if orientation == Orientation::Degree270 { - return note_at_in_range_degree270(cursor, bounds, note_count); - } let natural_cursor = to_natural_cursor(orientation, bounds, cursor); let natural = natural_bounds(orientation, bounds); let height = natural.height; let width = natural.width; - let white_notes: &[u8] = if note_count >= 12 { - &[0, 2, 4, 5, 7, 9, 11] - } else { - &[0, 2, 4, 5, 7] - }; - let white_key_count = white_notes.iter().take_while(|&n| *n < note_count).count() as f32; - if white_key_count == 0.0 { - return None; - } - let white_key_size = height / white_key_count; + let note_size = height / f32::from(note_count); let black_key_width = width * BLACK_KEY_DEPTH_RATIO; - let black_key_length = white_key_size * BLACK_KEY_LENGTH_RATIO; let u = natural_cursor.x.clamp(0.0, height); let v = natural_cursor.y; - - let (black_offsets, black_notes): (&[u8], &[u8]) = if note_count >= 12 { - (&[1, 2, 4, 5, 6], &[1, 3, 6, 8, 10]) - } else { - (&[1, 2, 4], &[1, 3, 6]) - }; - if v <= black_key_width { - for (idx, ¬e_id) in black_notes - .iter() - .enumerate() - .take_while(|&(_, n)| *n < note_count) - { - let center = black_offsets[idx] as f32 * white_key_size; - if (u - center).abs() <= black_key_length * 0.5 { - let velocity = velocity_from_v(v, black_key_width); - return Some((note_id, velocity)); - } + let note_id = (u / note_size).floor().min(f32::from(note_count - 1)) as u8; + if is_black_key(note_id) { + return Some((note_id, velocity_from_v(v, black_key_width))); } } + let note_id = (0..note_count) + .filter(|¬e| !is_black_key(note)) + .find(|¬e| u <= white_key_end(note, note_count) * note_size)?; - let index = (u / white_key_size) - .clamp(0.0, white_key_count - 1.0) - .floor() as usize; - let note_id = white_notes.get(index).copied()?; let velocity = velocity_from_v(v, width); Some((note_id, velocity)) } -fn note_at_in_range_degree270( - cursor: Point, - bounds: Rectangle, - note_count: u8, -) -> Option<(u8, u8)> { - if note_count < NOTES_PER_OCTAVE as u8 { - let white_note_ids = [0_u8, 2, 4, 5, 7]; - let black_key_offsets = [1_u8, 2, 4]; - let black_note_ids = [1_u8, 3, 6]; - let white_key_height = bounds.height / white_note_ids.len() as f32; - let black_key_width = bounds.width * BLACK_KEY_DEPTH_RATIO; - let black_key_height = white_key_height * BLACK_KEY_LENGTH_RATIO; - - if cursor.x <= black_key_width { - for (idx, offset) in black_key_offsets.iter().enumerate() { - let note_id = black_note_ids[idx]; - if note_id >= note_count { - continue; - } - let y_pos_black = bounds.height - - (f32::from(*offset) * white_key_height) - - (black_key_height * 0.5); - if cursor.y >= y_pos_black && cursor.y <= y_pos_black + black_key_height { - let velocity = velocity_from_v(cursor.x, black_key_width); - return Some((note_id, velocity)); - } - } - } - - for (i, note_id) in white_note_ids.iter().enumerate() { - let y_pos = bounds.height - ((i + 1) as f32 * white_key_height); - if cursor.y >= y_pos && cursor.y <= y_pos + white_key_height { - let velocity = velocity_from_v(cursor.x, bounds.width); - return Some((*note_id, velocity)); - } - } - return None; - } - let white_key_height = bounds.height / 7.0; - let black_key_offsets = [1, 2, 4, 5, 6]; - let black_note_ids = [1, 3, 6, 8, 10]; - let black_key_width = bounds.width * BLACK_KEY_DEPTH_RATIO; - let black_key_height = white_key_height * BLACK_KEY_LENGTH_RATIO; - - if cursor.x <= black_key_width { - for (idx, offset) in black_key_offsets.iter().enumerate() { - let y_pos_black = - bounds.height - (*offset as f32 * white_key_height) - (black_key_height * 0.5); - if cursor.y >= y_pos_black && cursor.y <= y_pos_black + black_key_height { - let velocity = velocity_from_v(cursor.x, black_key_width); - return Some((black_note_ids[idx], velocity)); - } - } - } - - for i in 0..7 { - let note_id = match i { - 0 => 0, - 1 => 2, - 2 => 4, - 3 => 5, - 4 => 7, - 5 => 9, - 6 => 11, - _ => 0, - }; - let y_pos = bounds.height - ((i + 1) as f32 * white_key_height); - if cursor.y >= y_pos && cursor.y <= y_pos + white_key_height { - let velocity = velocity_from_v(cursor.x, bounds.width); - return Some((note_id, velocity)); - } - } - None -} - /// Map a point from the keyboard's natural coordinate system to canvas space. /// /// In the natural coordinate system `u` runs along the note axis from the @@ -337,28 +242,15 @@ fn draw_keyboard_range_into( let natural = natural_bounds(orientation, bounds); let height = natural.height; let width = natural.width; - let white_notes: &[u8] = if note_count >= 12 { - &[0, 2, 4, 5, 7, 9, 11] - } else { - &[0, 2, 4, 5, 7] - }; - let white_key_count = white_notes.iter().take_while(|&&n| n < note_count).count() as f32; - if white_key_count == 0.0 { - return; - } - let white_key_size = height / white_key_count; + let note_size = height / f32::from(note_count); let black_key_width = width * BLACK_KEY_DEPTH_RATIO; - let black_key_length = white_key_size * BLACK_KEY_LENGTH_RATIO; let stroke = canvas::Stroke::default().with_width(1.0); let h_align = text_align_x(orientation); let v_align = text_align_y(orientation); // White keys, drawn full depth; black keys are overlaid on the back half. - for (i, ¬e_id) in white_notes - .iter() - .enumerate() - .take_while(|&(_, n)| *n < note_count) - { + let mut u_low = 0.0; + for note_id in (0..note_count).filter(|¬e| !is_black_key(note)) { let midi_note = octave * 12 + note_id; let is_pressed = pressed_notes.contains(¬e_id); let color = if is_pressed { @@ -366,8 +258,7 @@ fn draw_keyboard_range_into( } else { Color::WHITE }; - let u_low = i as f32 * white_key_size; - let u_high = u_low + white_key_size - 1.0; + let u_high = white_key_end(note_id, note_count) * note_size; let (origin, size) = map_rect(orientation, bounds, u_low, u_high, 0.0, width); let rect = Path::rectangle(origin, size); @@ -387,31 +278,21 @@ fn draw_keyboard_range_into( ..Text::default() }); } + u_low = u_high; } - let (black_offsets, black_notes): (&[u8], &[u8]) = if note_count >= 12 { - (&[1, 2, 4, 5, 6], &[1, 3, 6, 8, 10]) - } else { - (&[1, 2, 4], &[1, 3, 6]) - }; - - for (idx, ¬e_id) in black_notes - .iter() - .enumerate() - .take_while(|&(_, n)| *n < note_count) - { + for note_id in (0..note_count).filter(|¬e| is_black_key(note)) { let is_pressed = pressed_notes.contains(¬e_id); let color = if is_pressed { Color::from_rgb(0.0, 0.4, 0.8) } else { Color::BLACK }; - let center = black_offsets[idx] as f32 * white_key_size; let (origin, size) = map_rect( orientation, bounds, - center - black_key_length * 0.5, - center + black_key_length * 0.5, + f32::from(note_id) * note_size, + f32::from(note_id + 1) * note_size, 0.0, black_key_width, ); @@ -458,155 +339,6 @@ pub fn draw_partial_octave_into( ); } -fn draw_octave_degree270( - renderer: &Renderer, - bounds: Rectangle, - pressed_notes: &HashSet, - octave: u8, - midnam_note_names: &HashMap, -) -> Vec { - let mut frame = Frame::new(renderer, bounds.size()); - let white_key_height = bounds.height / 7.0; - - for i in 0..7 { - let note_id = match i { - 0 => 0, - 1 => 2, - 2 => 4, - 3 => 5, - 4 => 7, - 5 => 9, - 6 => 11, - _ => 0, - }; - let midi_note = octave * 12 + note_id; - let is_pressed = pressed_notes.contains(¬e_id); - let y_pos = bounds.height - ((i + 1) as f32 * white_key_height); - let rect = Path::rectangle( - Point::new(0.0, y_pos), - Size::new(bounds.width, white_key_height - 1.0), - ); - - frame.fill( - &rect, - if is_pressed { - Color::from_rgb(0.0, 0.5, 1.0) - } else { - Color::WHITE - }, - ); - frame.stroke(&rect, canvas::Stroke::default().with_width(1.0)); - - if let Some(note_name) = midnam_note_names.get(&midi_note) { - use iced::widget::canvas::Text; - frame.fill_text(Text { - content: note_name.clone(), - position: Point::new(bounds.width - 25.0, y_pos + white_key_height * 0.5 - 6.0), - color: Color::BLACK, - size: 10.0.into(), - ..Text::default() - }); - } - } - - let black_key_offsets = [1, 2, 4, 5, 6]; - let black_note_ids = [1, 3, 6, 8, 10]; - let black_key_width = bounds.width * BLACK_KEY_DEPTH_RATIO; - let black_key_height = white_key_height * BLACK_KEY_LENGTH_RATIO; - - for (idx, offset) in black_key_offsets.iter().enumerate() { - let note_id = black_note_ids[idx]; - let is_pressed = pressed_notes.contains(¬e_id); - let y_pos_black = - bounds.height - (*offset as f32 * white_key_height) - (black_key_height * 0.5); - let rect = Path::rectangle( - Point::new(0.0, y_pos_black), - Size::new(black_key_width, black_key_height), - ); - - frame.fill( - &rect, - if is_pressed { - Color::from_rgb(0.0, 0.4, 0.8) - } else { - Color::BLACK - }, - ); - } - - vec![frame.into_geometry()] -} - -fn draw_partial_octave_degree270( - renderer: &Renderer, - bounds: Rectangle, - pressed_notes: &HashSet, - octave: u8, - midnam_note_names: &HashMap, - note_count: u8, -) -> Vec { - let mut frame = Frame::new(renderer, bounds.size()); - let white_note_ids = [0_u8, 2, 4, 5, 7]; - let black_key_offsets = [1_u8, 2, 4]; - let black_note_ids = [1_u8, 3, 6]; - let white_key_height = bounds.height / white_note_ids.len() as f32; - let black_key_height = white_key_height * BLACK_KEY_LENGTH_RATIO; - let black_key_width = bounds.width * BLACK_KEY_DEPTH_RATIO; - - for (i, note_id) in white_note_ids.iter().enumerate() { - let midi_note = octave * 12 + *note_id; - let is_pressed = pressed_notes.contains(note_id); - let y_pos = bounds.height - ((i + 1) as f32 * white_key_height); - let rect = Path::rectangle( - Point::new(0.0, y_pos), - Size::new(bounds.width, white_key_height - 1.0), - ); - frame.fill( - &rect, - if is_pressed { - Color::from_rgb(0.0, 0.5, 1.0) - } else { - Color::WHITE - }, - ); - frame.stroke(&rect, canvas::Stroke::default().with_width(1.0)); - if let Some(note_name) = midnam_note_names.get(&midi_note) { - use iced::widget::canvas::Text; - frame.fill_text(Text { - content: note_name.clone(), - position: Point::new(bounds.width - 25.0, y_pos + white_key_height * 0.5 - 6.0), - color: Color::BLACK, - size: 10.0.into(), - ..Text::default() - }); - } - } - - for (idx, offset) in black_key_offsets.iter().enumerate() { - let note_id = black_note_ids[idx]; - if note_id >= note_count { - continue; - } - let is_pressed = pressed_notes.contains(¬e_id); - let y_pos_black = - bounds.height - (f32::from(*offset) * white_key_height) - (black_key_height * 0.5); - let rect = Path::rectangle( - Point::new(0.0, y_pos_black), - Size::new(black_key_width, black_key_height), - ); - frame.fill( - &rect, - if is_pressed { - Color::from_rgb(0.0, 0.4, 0.8) - } else { - Color::BLACK - }, - ); - } - - vec![frame.into_geometry()] -} - pub fn draw_octave( renderer: &Renderer, bounds: Rectangle, @@ -615,9 +347,6 @@ pub fn draw_octave( midnam_note_names: &HashMap, orientation: Orientation, ) -> Vec { - if orientation == Orientation::Degree270 { - return draw_octave_degree270(renderer, bounds, pressed_notes, octave, midnam_note_names); - } let mut frame = Frame::new(renderer, bounds.size()); let local_bounds = Rectangle { x: 0.0, @@ -644,16 +373,6 @@ pub fn draw_partial_octave( midnam_note_names: &HashMap, orientation: Orientation, ) -> Vec { - if orientation == Orientation::Degree270 { - return draw_partial_octave_degree270( - renderer, - bounds, - pressed_notes, - octave, - midnam_note_names, - octave_note_count(octave), - ); - } let mut frame = Frame::new(renderer, bounds.size()); let local_bounds = Rectangle { x: 0.0, @@ -824,6 +543,40 @@ mod tests { (message, status) } + #[test] + fn keyboard_hits_match_semitone_columns() { + for note_count in [8, 12] { + for orientation in [ + Orientation::Degree0, + Orientation::Degree90, + Orientation::Degree180, + Orientation::Degree270, + ] { + let length = f32::from(note_count) * 24.0; + let size = match orientation { + Orientation::Degree0 | Orientation::Degree180 => Size::new(length, 48.0), + _ => Size::new(48.0, length), + }; + let bounds = Rectangle::new(Point::ORIGIN, size); + for note in 0..note_count { + for fraction in [0.01, 0.5, 0.99] { + let cursor = map_point( + orientation, + bounds, + (f32::from(note) + fraction) * 24.0, + 12.0, + ); + assert_eq!( + note_at_in_range(cursor, bounds, orientation, note_count) + .map(|(note, _)| note), + Some(note) + ); + } + } + } + } + } + #[test] fn octave_keyboard_update_publishes_pressed_and_released_notes() { let keyboard = OctaveKeyboard::new( diff --git a/src/range_slider.rs b/src/range_slider.rs new file mode 100644 index 0000000..fcaeb53 --- /dev/null +++ b/src/range_slider.rs @@ -0,0 +1,747 @@ +use crate::consts::DOUBLE_CLICK; +#[cfg(test)] +use iced::Point; +use iced::advanced::Shell; +use iced::advanced::layout::{self, Layout}; +use iced::advanced::renderer; +use iced::advanced::widget::{self, Tree, Widget}; +use iced::{Border, Color, Element, Event, Length, Rectangle, Size}; +use iced::{keyboard, mouse}; +use std::time::Instant; + +#[derive(Clone, Copy, Debug, Default, PartialEq)] +enum Orientation { + #[default] + Vertical, + Horizontal, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum DraggedHandle { + Low, + High, +} + +/// A slider with two handles editing a `low..=high` value pair (for example +/// velocity or key ranges). Defaults to a vertical orientation; call +/// [`RangeSlider::horizontal`] for a horizontal layout. Dragging moves the +/// high handle, Shift+dragging moves the low handle, and the handles cannot +/// cross. Double-click resets the pair to the full range. +pub struct RangeSlider<'a, Message> { + range: std::ops::RangeInclusive, + low: f32, + high: f32, + on_change: Box Message + 'a>, + width: Length, + height: Length, + handle_size: f32, + step: Option, + orientation: Orientation, +} + +impl<'a, Message> RangeSlider<'a, Message> { + pub fn new(range: std::ops::RangeInclusive, low: f32, high: f32, on_change: F) -> Self + where + F: Fn(f32, f32) -> Message + 'a, + { + Self { + range, + low, + high, + on_change: Box::new(on_change), + width: Length::Fixed(14.0), + height: Length::Fixed(300.0), + handle_size: 4.0, + step: None, + orientation: Orientation::Vertical, + } + } + + pub fn width(mut self, width: Length) -> Self { + self.width = width; + self + } + + pub fn height(mut self, height: Length) -> Self { + self.height = height; + self + } + + pub fn handle_size(mut self, handle_size: f32) -> Self { + self.handle_size = handle_size.max(1.0); + self + } + + pub fn step(mut self, step: f32) -> Self { + self.step = Some(step.abs()).filter(|step| *step > 0.0); + self + } + + pub fn horizontal(mut self) -> Self { + self.orientation = Orientation::Horizontal; + self + } + + fn handle_position(&self, value: f32, bounds: Rectangle) -> f32 { + let (inner_origin, inner_length) = self.inner_track(bounds); + handle_position( + value, + *self.range.start(), + *self.range.end(), + inner_origin, + inner_length, + self.orientation, + ) + } + + fn inner_track(&self, bounds: Rectangle) -> (f32, f32) { + match self.orientation { + Orientation::Vertical => ( + bounds.y + self.handle_size / 2.0, + (bounds.height - self.handle_size).max(1.0), + ), + Orientation::Horizontal => ( + bounds.x + self.handle_size / 2.0, + (bounds.width - self.handle_size).max(1.0), + ), + } + } +} + +pub fn range_slider<'a, Message, F>( + range: std::ops::RangeInclusive, + low: f32, + high: f32, + on_change: F, +) -> RangeSlider<'a, Message> +where + F: Fn(f32, f32) -> Message + 'a, +{ + RangeSlider::new(range, low, high, on_change) +} + +fn handle_position( + value: f32, + start: f32, + end: f32, + inner_origin: f32, + inner_length: f32, + orientation: Orientation, +) -> f32 { + let normalized = if end > start { + (value - start) / (end - start) + } else { + 0.0 + } + .clamp(0.0, 1.0); + match orientation { + Orientation::Horizontal => inner_origin + normalized * inner_length, + Orientation::Vertical => inner_origin + (1.0 - normalized) * inner_length, + } +} + +fn drag_value( + start_value: f32, + start_position: f32, + cursor_position: f32, + inner_length: f32, + range_size: f32, + orientation: Orientation, +) -> f32 { + let delta = match orientation { + Orientation::Horizontal => cursor_position - start_position, + Orientation::Vertical => start_position - cursor_position, + }; + start_value + (delta / inner_length.max(1.0)) * range_size +} + +fn clamp_to_step(value: f32, start: f32, end: f32, step: Option) -> f32 { + let clamped = value.clamp(start, end); + let Some(step) = step else { + return clamped; + }; + let steps = ((clamped - start) / step).round(); + (start + steps * step).clamp(start, end) +} + +fn clamp_pair( + dragged: f32, + other: f32, + handle: DraggedHandle, + start: f32, + end: f32, + step: Option, +) -> (f32, f32) { + match handle { + DraggedHandle::Low => { + let low = clamp_to_step(dragged.min(other), start, end, step); + (low, clamp_to_step(other, start, end, step).max(low)) + } + DraggedHandle::High => { + let high = clamp_to_step(dragged.max(other), start, end, step); + (clamp_to_step(other, start, end, step).min(high), high) + } + } +} + +#[derive(Default)] +struct State { + dragging: Option, + last_click_at: Option, + modifiers: keyboard::Modifiers, + drag_start_x: f32, + drag_start_y: f32, + drag_start_low: f32, + drag_start_high: f32, +} + +impl<'a, Message, Theme, Renderer> Widget for RangeSlider<'a, Message> +where + Renderer: renderer::Renderer, + Message: Clone, +{ + fn size(&self) -> Size { + Size { + width: self.width, + height: self.height, + } + } + + fn layout( + &mut self, + _tree: &mut Tree, + _renderer: &Renderer, + limits: &layout::Limits, + ) -> layout::Node { + let size = limits.width(self.width).height(self.height).resolve( + self.width, + self.height, + Size::ZERO, + ); + + layout::Node::new(size) + } + + fn draw( + &self, + _tree: &Tree, + renderer: &mut Renderer, + _theme: &Theme, + _style: &renderer::Style, + layout: Layout<'_>, + _cursor: mouse::Cursor, + _viewport: &Rectangle, + ) { + let bounds = layout.bounds(); + let border_width = 1.0; + + let back_color = Color::from_rgb( + 0x42 as f32 / 255.0, + 0x46 as f32 / 255.0, + 0x4D as f32 / 255.0, + ); + let border_color = Color::from_rgb( + 0x30 as f32 / 255.0, + 0x33 as f32 / 255.0, + 0x3C as f32 / 255.0, + ); + let filled_color = Color::from_rgb( + 0x29 as f32 / 255.0, + 0x66 as f32 / 255.0, + 0xA3 as f32 / 255.0, + ); + let handle_color = Color::from_rgb( + 0x75 as f32 / 255.0, + 0xC2 as f32 / 255.0, + 0xFF as f32 / 255.0, + ); + + let border_radius = 2.0; + + renderer.fill_quad( + renderer::Quad { + bounds: Rectangle { + x: bounds.x, + y: bounds.y, + width: bounds.width, + height: bounds.height, + }, + border: Border { + radius: border_radius.into(), + width: border_width, + color: border_color, + }, + ..Default::default() + }, + back_color, + ); + + let low_position = self.handle_position(self.low, bounds); + let high_position = self.handle_position(self.high, bounds); + + match self.orientation { + Orientation::Vertical => { + let band_top = low_position.min(high_position); + let band_height = (high_position - low_position).abs(); + if band_height > 0.0 { + renderer.fill_quad( + renderer::Quad { + bounds: Rectangle { + x: bounds.x, + y: band_top, + width: bounds.width, + height: band_height, + }, + border: Border { + radius: border_radius.into(), + width: border_width, + color: Color::TRANSPARENT, + }, + ..Default::default() + }, + filled_color, + ); + } + for position in [low_position, high_position] { + renderer.fill_quad( + renderer::Quad { + bounds: Rectangle { + x: bounds.x, + y: position - self.handle_size / 2.0 - border_width, + width: bounds.width, + height: self.handle_size + border_width * 2.0, + }, + border: Border { + radius: border_radius.into(), + width: border_width, + color: Color::TRANSPARENT, + }, + ..Default::default() + }, + handle_color, + ); + } + } + Orientation::Horizontal => { + let band_left = low_position.min(high_position); + let band_width = (high_position - low_position).abs(); + if band_width > 0.0 { + renderer.fill_quad( + renderer::Quad { + bounds: Rectangle { + x: band_left, + y: bounds.y, + width: band_width, + height: bounds.height, + }, + border: Border { + radius: border_radius.into(), + width: border_width, + color: Color::TRANSPARENT, + }, + ..Default::default() + }, + filled_color, + ); + } + for position in [low_position, high_position] { + renderer.fill_quad( + renderer::Quad { + bounds: Rectangle { + x: position - self.handle_size / 2.0 - border_width, + y: bounds.y, + width: self.handle_size + border_width * 2.0, + height: bounds.height, + }, + border: Border { + radius: border_radius.into(), + width: border_width, + color: Color::TRANSPARENT, + }, + ..Default::default() + }, + handle_color, + ); + } + } + } + } + + fn tag(&self) -> widget::tree::Tag { + widget::tree::Tag::of::() + } + + fn state(&self) -> widget::tree::State { + widget::tree::State::new(State::default()) + } + + fn update( + &mut self, + tree: &mut Tree, + event: &Event, + layout: Layout<'_>, + cursor: mouse::Cursor, + _renderer: &Renderer, + _clipboard: &mut dyn iced::advanced::Clipboard, + shell: &mut Shell<'_, Message>, + _viewport: &Rectangle, + ) { + let state = tree.state.downcast_mut::(); + let bounds = layout.bounds(); + + match event { + Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { + state.modifiers = *modifiers; + } + Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) + if cursor.is_over(bounds) => + { + let now = Instant::now(); + let is_double_click = state + .last_click_at + .is_some_and(|last| now.duration_since(last) <= DOUBLE_CLICK); + state.last_click_at = Some(now); + if is_double_click { + shell.publish((self.on_change)(*self.range.start(), *self.range.end())); + shell.capture_event(); + } else if let Some(cursor_position) = cursor.position() { + state.dragging = Some(if state.modifiers.shift() { + DraggedHandle::Low + } else { + DraggedHandle::High + }); + state.drag_start_x = cursor_position.x; + state.drag_start_y = cursor_position.y; + state.drag_start_low = self.low; + state.drag_start_high = self.high; + } + } + Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) + if state.dragging.is_some() => + { + state.dragging = None; + } + Event::Mouse(mouse::Event::CursorMoved { .. }) => { + if let Some(handle) = state.dragging + && let Some(cursor_position) = cursor.position() + { + let (_, inner_length) = self.inner_track(bounds); + let range_size = self.range.end() - self.range.start(); + let start_position = match self.orientation { + Orientation::Horizontal => state.drag_start_x, + Orientation::Vertical => state.drag_start_y, + }; + let start_value = match handle { + DraggedHandle::Low => state.drag_start_low, + DraggedHandle::High => state.drag_start_high, + }; + let cursor_position = match self.orientation { + Orientation::Horizontal => cursor_position.x, + Orientation::Vertical => cursor_position.y, + }; + let dragged = drag_value( + start_value, + start_position, + cursor_position, + inner_length, + range_size, + self.orientation, + ); + let other = match handle { + DraggedHandle::Low => state.drag_start_high, + DraggedHandle::High => state.drag_start_low, + }; + let (low, high) = clamp_pair( + dragged, + other, + handle, + *self.range.start(), + *self.range.end(), + self.step, + ); + shell.publish((self.on_change)(low, high)); + } + } + _ => {} + } + } +} + +impl<'a, Message, Theme, Renderer> From> + for Element<'a, Message, Theme, Renderer> +where + Message: 'a + Clone, + Theme: 'a, + Renderer: renderer::Renderer + 'a, +{ + fn from(slider: RangeSlider<'a, Message>) -> Self { + Self::new(slider) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use iced::Event; + use iced::advanced::{ + Layout, Shell, clipboard, layout, + widget::{self, Tree, Widget}, + }; + use std::time::Instant; + + fn test_tree_with_state(state: State) -> Tree { + Tree { + tag: widget::tree::Tag::of::(), + state: widget::tree::State::new(state), + children: Vec::new(), + } + } + + #[test] + fn handle_position_maps_range_to_inner_track() { + assert_eq!( + handle_position(0.0, 0.0, 1.0, 10.0, 80.0, Orientation::Horizontal), + 10.0 + ); + assert_eq!( + handle_position(1.0, 0.0, 1.0, 10.0, 80.0, Orientation::Horizontal), + 90.0 + ); + assert_eq!( + handle_position(0.5, 0.0, 1.0, 10.0, 80.0, Orientation::Horizontal), + 50.0 + ); + assert_eq!( + handle_position(0.0, 0.0, 1.0, 10.0, 80.0, Orientation::Vertical), + 90.0 + ); + assert_eq!( + handle_position(1.0, 0.0, 1.0, 10.0, 80.0, Orientation::Vertical), + 10.0 + ); + } + + #[test] + fn handle_position_clamps_out_of_range_values() { + assert_eq!( + handle_position(2.0, 0.0, 1.0, 0.0, 100.0, Orientation::Horizontal), + 100.0 + ); + assert_eq!( + handle_position(-1.0, 0.0, 1.0, 0.0, 100.0, Orientation::Horizontal), + 0.0 + ); + } + + #[test] + fn drag_value_scales_cursor_delta_to_range() { + assert_eq!( + drag_value(0.5, 50.0, 60.0, 100.0, 1.0, Orientation::Horizontal), + 0.6 + ); + assert_eq!( + drag_value(0.5, 50.0, 40.0, 100.0, 1.0, Orientation::Horizontal), + 0.4 + ); + assert_eq!( + drag_value(0.5, 50.0, 40.0, 100.0, 1.0, Orientation::Vertical), + 0.6 + ); + assert_eq!( + drag_value(0.5, 50.0, 60.0, 100.0, 1.0, Orientation::Vertical), + 0.4 + ); + } + + #[test] + fn clamp_pair_prevents_handles_crossing() { + let (low, high) = clamp_pair(0.8, 0.6, DraggedHandle::Low, 0.0, 1.0, None); + assert_eq!((low, high), (0.6, 0.6)); + let (low, high) = clamp_pair(0.2, 0.4, DraggedHandle::High, 0.0, 1.0, None); + assert_eq!((low, high), (0.4, 0.4)); + } + + #[test] + fn clamp_pair_snaps_to_step() { + let (low, high) = clamp_pair(0.26, 0.74, DraggedHandle::Low, 0.0, 1.0, Some(0.1)); + assert_eq!((low, high), (0.3, 0.7)); + } + + #[test] + fn clamp_pair_clamps_to_range() { + let (low, high) = clamp_pair(1.4, 0.5, DraggedHandle::High, 0.0, 1.0, None); + assert_eq!((low, high), (0.5, 1.0)); + } + + #[cfg(debug_assertions)] + fn press(slider: &mut RangeSlider<'_, (f32, f32)>, tree: &mut Tree, at: Point) { + let node = layout::Node::new(Size::new(150.0, 11.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let mut shell = Shell::new(&mut messages); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(150.0, 11.0)); + as Widget<(f32, f32), iced::Theme, ()>>::update( + slider, + tree, + &Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)), + layout, + mouse::Cursor::Available(at), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + assert!(messages.is_empty()); + } + + #[cfg(debug_assertions)] + fn drag_to( + slider: &mut RangeSlider<'_, (f32, f32)>, + tree: &mut Tree, + from: Point, + to: Point, + ) -> Vec<(f32, f32)> { + press(slider, tree, from); + let node = layout::Node::new(Size::new(150.0, 11.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(150.0, 11.0)); + { + let mut shell = Shell::new(&mut messages); + as Widget<(f32, f32), iced::Theme, ()>>::update( + slider, + tree, + &Event::Mouse(mouse::Event::CursorMoved { position: to }), + layout, + mouse::Cursor::Available(to), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + } + messages + } + + #[cfg(debug_assertions)] + #[test] + fn shift_drag_low_handle_stops_at_high_handle() { + let mut slider = RangeSlider::new(0.0..=1.0, 0.2, 0.8, |low, high| (low, high)) + .horizontal() + .width(Length::Fixed(150.0)) + .height(Length::Fixed(11.0)); + let mut tree = test_tree_with_state(State { + modifiers: keyboard::Modifiers::SHIFT, + ..State::default() + }); + + let messages = drag_to( + &mut slider, + &mut tree, + Point::new(45.0, 5.0), + Point::new(150.0, 5.0), + ); + + assert_eq!(messages.len(), 1); + let (low, high) = messages[0]; + assert_eq!( + (low, high), + (0.8, 0.8), + "low should clamp at high instead of crossing: {low}" + ); + } + + #[cfg(debug_assertions)] + #[test] + fn plain_drag_moves_high_handle_even_near_low_handle() { + let mut slider = RangeSlider::new(0.0..=1.0, 0.2, 0.8, |low, high| (low, high)) + .horizontal() + .width(Length::Fixed(150.0)) + .height(Length::Fixed(11.0)); + let mut tree = test_tree_with_state(State::default()); + + // Press near the low handle (x=45); a plain drag must still move high. + let messages = drag_to( + &mut slider, + &mut tree, + Point::new(45.0, 5.0), + Point::new(75.0, 5.0), + ); + + assert_eq!(messages.len(), 1); + let (low, high) = messages[0]; + assert_eq!(low, 0.2); + assert!( + high > 0.8, + "plain drag should move high toward the range end: {high}" + ); + } + + #[cfg(debug_assertions)] + #[test] + fn shift_drag_moves_low_handle() { + let mut slider = RangeSlider::new(0.0..=1.0, 0.2, 0.8, |low, high| (low, high)) + .horizontal() + .width(Length::Fixed(150.0)) + .height(Length::Fixed(11.0)); + let mut tree = test_tree_with_state(State { + modifiers: keyboard::Modifiers::SHIFT, + ..State::default() + }); + + // Press near the high handle (x=120); shift+drag must move low. + let messages = drag_to( + &mut slider, + &mut tree, + Point::new(120.0, 5.0), + Point::new(90.0, 5.0), + ); + + assert_eq!(messages.len(), 1); + let (low, high) = messages[0]; + assert!( + low < 0.2, + "shift drag should move low toward the range start: {low}" + ); + assert_eq!(high, 0.8); + } + + #[cfg(debug_assertions)] + #[test] + fn double_click_resets_to_full_range() { + let mut slider = RangeSlider::new(0.0..=127.0, 20.0, 100.0, |low, high| (low, high)) + .horizontal() + .width(Length::Fixed(150.0)) + .height(Length::Fixed(11.0)); + let mut tree = test_tree_with_state(State { + dragging: None, + last_click_at: Some(Instant::now()), + ..State::default() + }); + let node = layout::Node::new(Size::new(150.0, 11.0)); + let layout = Layout::new(&node); + let mut messages = Vec::new(); + let mut shell = Shell::new(&mut messages); + let renderer = (); + let mut clipboard = clipboard::Null; + let viewport = Rectangle::new(Point::ORIGIN, Size::new(150.0, 11.0)); + + as Widget<(f32, f32), iced::Theme, ()>>::update( + &mut slider, + &mut tree, + &Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)), + layout, + mouse::Cursor::Available(Point::new(75.0, 5.0)), + &renderer, + &mut clipboard, + &mut shell, + &viewport, + ); + + assert_eq!(messages, vec![(0.0, 127.0)]); + } +} diff --git a/src/waveform.rs b/src/waveform.rs index 46515b9..e0cf741 100644 --- a/src/waveform.rs +++ b/src/waveform.rs @@ -1,5 +1,5 @@ use iced::{ - Color, Element, Event, Length, Point, Rectangle, Renderer, Theme, mouse, + Color, Element, Event, Length, Point, Rectangle, Renderer, Theme, keyboard, mouse, widget::{ canvas, canvas::{Action as CanvasAction, Frame, Geometry, Path, Program, Stroke}, @@ -9,21 +9,32 @@ use std::time::Instant; use crate::consts::DOUBLE_CLICK; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SelectionEdge { + Start, + End, +} + +type RatioMessageFn<'a, Message> = Box Message + 'a>; +type RatioPairMessageFn<'a, Message> = Box Message + 'a>; + pub struct SampleWaveform<'a, Message> { channels: Vec<&'a [f32]>, peak: f32, empty_label: &'static str, playhead_ratio: Option, selection_ratio: Option<(f32, f32)>, + xfade_ratio: Option<(f32, f32)>, markers: Vec<(usize, String)>, - on_click: Option Message + 'a>>, - on_double_click: Option Message + 'a>>, - on_selection_start: Option Message + 'a>>, - on_selection_drag: Option Message + 'a>>, - on_selection_finish: Option Message + 'a>>, - on_right_click: Option Message + 'a>>, - on_middle_click: Option Message + 'a>>, - on_middle_click_away: Option Message + 'a>>, + on_click: Option>, + on_double_click: Option>, + on_selection_start: Option>, + on_selection_drag: Option>, + on_selection_finish: Option>, + on_xfade: Option>, + on_right_click: Option>, + on_middle_click: Option>, + on_middle_click_away: Option>, } impl<'a, Message> SampleWaveform<'a, Message> { @@ -34,12 +45,14 @@ impl<'a, Message> SampleWaveform<'a, Message> { empty_label: "No sample loaded", playhead_ratio: None, selection_ratio: None, + xfade_ratio: None, markers: Vec::new(), on_click: None, on_double_click: None, on_selection_start: None, on_selection_drag: None, on_selection_finish: None, + on_xfade: None, on_right_click: None, on_middle_click: None, on_middle_click_away: None, @@ -60,6 +73,20 @@ impl<'a, Message> SampleWaveform<'a, Message> { self } + pub fn xfade_ratio(mut self, xfade_ratio: Option<(f32, f32)>) -> Self { + self.xfade_ratio = xfade_ratio.map(|(start, end)| { + let start = start.clamp(0.0, 1.0); + let end = end.clamp(0.0, 1.0); + (start.min(end), start.max(end)) + }); + self + } + + pub fn on_xfade(mut self, on_xfade: impl Fn((f32, f32)) -> Message + 'a) -> Self { + self.on_xfade = Some(Box::new(on_xfade)); + self + } + pub fn on_selection_start(mut self, on_selection_start: impl Fn(f32) -> Message + 'a) -> Self { self.on_selection_start = Some(Box::new(on_selection_start)); self @@ -147,6 +174,57 @@ impl<'a, Message> SampleWaveform<'a, Message> { .map(|marker_x| (marker_x - x).abs()) .any(|distance| distance <= 8.0) } + + fn selection_edge_at(&self, ratio: f32, width: f32) -> Option { + let (start, end) = self.selection_ratio?; + let x = width * ratio; + let start_distance = (width * start - x).abs(); + let end_distance = (width * end - x).abs(); + const EDGE_TOLERANCE: f32 = 6.0; + match ( + start_distance <= EDGE_TOLERANCE, + end_distance <= EDGE_TOLERANCE, + ) { + (true, true) => { + if start_distance <= end_distance { + Some(SelectionEdge::Start) + } else { + Some(SelectionEdge::End) + } + } + (true, false) => Some(SelectionEdge::Start), + (false, true) => Some(SelectionEdge::End), + (false, false) => None, + } + } + + fn publish_xfade(&self, edge: SelectionEdge, ratio: f32) -> Option> { + let selection = self.selection_ratio?; + let region = xfade_inner_region(selection, edge, ratio); + self.on_xfade + .as_ref() + .map(|message| CanvasAction::publish(message(region)).and_capture()) + } +} + +/// Computes the symmetric inner ("xfade") region for a ctrl+drag starting at +/// one edge of the selection: the distance from the selection start to the +/// inner start always equals the distance from the inner end to the +/// selection end. +fn xfade_inner_region(selection: (f32, f32), edge: SelectionEdge, ratio: f32) -> (f32, f32) { + let (sel_start, sel_end) = selection; + let (inner_start, inner_end) = match edge { + SelectionEdge::Start => (ratio, sel_end - (ratio - sel_start)), + SelectionEdge::End => (sel_start + (sel_end - ratio), ratio), + }; + let inner_start = inner_start.clamp(sel_start, sel_end); + let inner_end = inner_end.clamp(sel_start, sel_end); + if inner_start > inner_end { + let mid = (sel_start + sel_end) / 2.0; + (mid, mid) + } else { + (inner_start, inner_end) + } } #[derive(Debug, Default)] @@ -154,6 +232,8 @@ pub struct SampleWaveformState { selecting: bool, drag_start: Option, last_click_at: Option, + modifiers: keyboard::Modifiers, + xfade_edge: Option, } impl Program for SampleWaveform<'_, Message> { @@ -167,6 +247,10 @@ impl Program for SampleWaveform<'_, Message> { cursor: mouse::Cursor, ) -> Option> { match event { + Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { + state.modifiers = *modifiers; + None + } Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => { let ratio = cursor_ratio(cursor, bounds)?; let position = cursor.position_in(bounds)?; @@ -179,18 +263,33 @@ impl Program for SampleWaveform<'_, Message> { if is_double_click { state.drag_start = None; state.selecting = false; + state.xfade_edge = None; return self .on_double_click .as_ref() .map(|message| CanvasAction::publish(message(ratio)).and_capture()); } + if state.modifiers.control() + && let Some(edge) = self.selection_edge_at(ratio, bounds.width) + { + state.drag_start = None; + state.selecting = false; + state.xfade_edge = Some(edge); + return self.publish_xfade(edge, ratio); + } + state.drag_start = Some(position); state.selecting = false; + state.xfade_edge = None; None } Event::Mouse(mouse::Event::CursorMoved { .. }) => { let position = cursor.position_in(bounds)?; + if let Some(edge) = state.xfade_edge { + let ratio = cursor_ratio(cursor, bounds)?; + return self.publish_xfade(edge, ratio); + } if let Some(drag_start) = state.drag_start && !state.selecting && (position.x - drag_start.x).abs() > 2.0 @@ -213,6 +312,9 @@ impl Program for SampleWaveform<'_, Message> { } Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => { let ratio = cursor_ratio(cursor, bounds)?; + if let Some(edge) = state.xfade_edge.take() { + return self.publish_xfade(edge, ratio); + } if state.selecting { state.selecting = false; state.drag_start = None; @@ -274,6 +376,9 @@ impl Program for SampleWaveform<'_, Message> { if let Some(selection) = self.selection_ratio { draw_selection(&mut frame, bounds, selection); } + if let Some(xfade) = self.xfade_ratio { + draw_xfade(&mut frame, bounds, xfade); + } if let Some(ratio) = self.playhead_ratio { draw_playhead(&mut frame, bounds, ratio); } @@ -398,6 +503,22 @@ fn draw_selection(frame: &mut Frame, bounds: Rectangle, selection: (f32, f32)) { ); } +fn draw_xfade(frame: &mut Frame, bounds: Rectangle, region: (f32, f32)) { + let x0 = bounds.width * region.0.clamp(0.0, 1.0); + let x1 = bounds.width * region.1.clamp(0.0, 1.0); + if x1 - x0 < 1.0 { + return; + } + let path = Path::rectangle(Point::new(x0, 0.0), iced::Size::new(x1 - x0, bounds.height)); + frame.fill(&path, Color::from_rgba(0.35, 0.85, 0.55, 0.16)); + frame.stroke( + &path, + Stroke::default() + .with_color(Color::from_rgba(0.35, 0.85, 0.55, 0.65)) + .with_width(1.0), + ); +} + fn draw_markers(frame: &mut Frame, bounds: Rectangle, frames: usize, markers: &[(usize, String)]) { if frames == 0 || markers.is_empty() { return; @@ -462,3 +583,39 @@ fn draw_markers(frame: &mut Frame, bounds: Rectangle, frames: usize, markers: &[ } } } + +#[cfg(test)] +mod tests { + use super::{SelectionEdge, xfade_inner_region}; + + #[test] + fn xfade_inner_region_from_start_edge_is_symmetric() { + let (start, end) = xfade_inner_region((0.2, 0.8), SelectionEdge::Start, 0.3); + assert!((start - 0.3).abs() < 1e-6); + assert!((end - 0.7).abs() < 1e-6); + } + + #[test] + fn xfade_inner_region_from_end_edge_is_symmetric() { + let (start, end) = xfade_inner_region((0.2, 0.8), SelectionEdge::End, 0.7); + assert!((start - 0.3).abs() < 1e-6); + assert!((end - 0.7).abs() < 1e-6); + } + + #[test] + fn xfade_inner_region_clamps_inside_selection() { + let (start, end) = xfade_inner_region((0.2, 0.8), SelectionEdge::Start, 0.05); + assert!((start - 0.2).abs() < 1e-6); + assert!((end - 0.8).abs() < 1e-6); + let (start, end) = xfade_inner_region((0.2, 0.8), SelectionEdge::End, 0.95); + assert!((start - 0.2).abs() < 1e-6); + assert!((end - 0.8).abs() < 1e-6); + } + + #[test] + fn xfade_inner_region_collapses_to_middle_when_edges_cross() { + let (start, end) = xfade_inner_region((0.2, 0.8), SelectionEdge::Start, 0.6); + assert!((start - 0.5).abs() < 1e-6); + assert!((end - 0.5).abs() < 1e-6); + } +}