diff --git a/Cargo.lock b/Cargo.lock index edc4c63..59f745e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,12 +31,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.3.4", + "getrandom", "once_cell", "version_check", "zerocopy", ] +[[package]] +name = "aligned" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923" +dependencies = [ + "as-slice", +] + [[package]] name = "aligned-vec" version = "0.6.4" @@ -110,7 +119,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.60.2", + "windows-sys 0.59.0", "wl-clipboard-rs", "x11rb", ] @@ -144,6 +153,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "ash" version = "0.38.0+1.3.281" @@ -165,6 +183,26 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "av-scenechange" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394" +dependencies = [ + "aligned", + "anyhow", + "arg_enum_proc_macro", + "arrayvec", + "log", + "num-rational", + "num-traits", + "pastey", + "rayon", + "thiserror 2.0.17", + "v_frame", + "y4m", +] + [[package]] name = "av1-grain" version = "0.2.5" @@ -174,7 +212,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom 8.0.0", + "nom", "num-rational", "v_frame", ] @@ -223,9 +261,12 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bitstream-io" -version = "2.6.0" +version = "4.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" +checksum = "60d4bd9d1db2c6bdf285e223a7fa369d5ce98ec767dec949c6ca62863ce61757" +dependencies = [ + "core2", +] [[package]] name = "block" @@ -244,9 +285,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" +checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" [[package]] name = "bumpalo" @@ -288,9 +329,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "calloop" @@ -320,9 +361,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.45" +version = "1.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" +checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" dependencies = [ "find-msvc-tools", "jobserver", @@ -336,16 +377,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -[[package]] -name = "cfg-expr" -version = "0.15.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" -dependencies = [ - "smallvec", - "target-lexicon", -] - [[package]] name = "cfg-if" version = "1.0.4" @@ -464,6 +495,15 @@ dependencies = [ "libc", ] +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "core_maths" version = "0.1.1" @@ -689,15 +729,15 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "fixedbitset" -version = "0.4.2" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" @@ -799,17 +839,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "getrandom" version = "0.3.4" @@ -824,9 +853,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.13.3" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b" +checksum = "f5df2ba84018d80c213569363bdcd0c64e6933c67fe4c1d60ecf822971a3c35e" dependencies = [ "color_quant", "weezl", @@ -951,19 +980,13 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "foldhash 0.2.0", ] -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - [[package]] name = "hermit-abi" version = "0.5.2" @@ -978,9 +1001,9 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" [[package]] name = "image" -version = "0.25.8" +version = "0.25.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7" +checksum = "e6506c6c10786659413faa717ceebcb8f70731c0a60cbae39795fdf114519c1a" dependencies = [ "bytemuck", "byteorder-lite", @@ -996,8 +1019,8 @@ dependencies = [ "rayon", "rgb", "tiff", - "zune-core", - "zune-jpeg", + "zune-core 0.5.0", + "zune-jpeg 0.5.6", ] [[package]] @@ -1018,12 +1041,12 @@ checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8" [[package]] name = "indexmap" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", ] [[package]] @@ -1042,21 +1065,41 @@ name = "iris" version = "0.1.0" dependencies = [ "arboard", - "bytemuck", "cosmic-text", - "fxhash", "image", + "iris-core", + "iris-macro", "pollster", "unicode-segmentation", "wgpu", "winit", ] +[[package]] +name = "iris-core" +version = "0.1.0" +dependencies = [ + "bytemuck", + "cosmic-text", + "fxhash", + "image", + "wgpu", + "winit", +] + +[[package]] +name = "iris-macro" +version = "0.1.0" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "itertools" -version = "0.12.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] @@ -1089,15 +1132,15 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ - "getrandom 0.3.4", + "getrandom", "libc", ] [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" dependencies = [ "once_cell", "wasm-bindgen", @@ -1128,9 +1171,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" [[package]] name = "libc" -version = "0.2.177" +version = "0.2.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" [[package]] name = "libfuzzer-sys" @@ -1204,9 +1247,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "loop9" @@ -1266,12 +1309,6 @@ dependencies = [ "paste", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -1284,9 +1321,9 @@ dependencies = [ [[package]] name = "moxcms" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6" +checksum = "80986bbbcf925ebd3be54c26613d861255284584501595cf418320c078945608" dependencies = [ "num-traits", "pxfm", @@ -1305,7 +1342,7 @@ dependencies = [ "cfg_aliases", "codespan-reporting", "half", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "hexf-parse", "indexmap", "libm", @@ -1354,16 +1391,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "nom" version = "8.0.0" @@ -1803,6 +1830,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "pastey" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" + [[package]] name = "percent-encoding" version = "2.3.2" @@ -1811,11 +1844,12 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "petgraph" -version = "0.6.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" dependencies = [ "fixedbitset", + "hashbrown 0.15.5", "indexmap", ] @@ -1920,7 +1954,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit 0.23.7", + "toml_edit", ] [[package]] @@ -1953,9 +1987,9 @@ dependencies = [ [[package]] name = "pxfm" -version = "0.1.25" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84" +checksum = "7186d3822593aa4393561d186d1393b3923e9d6163d3fbfd6e825e3e6cf3e6a8" dependencies = [ "num-traits", ] @@ -2001,20 +2035,19 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rand" -version = "0.8.5" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ - "libc", "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" -version = "0.3.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", "rand_core", @@ -2022,11 +2055,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.2.16", + "getrandom", ] [[package]] @@ -2037,19 +2070,21 @@ checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde" [[package]] name = "rangemap" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7e49bb0bf967717f7bd674458b3d6b0c5f48ec7e3038166026a69fc22223" +checksum = "acbbbbea733ec66275512d0b9694f34102e7d5406fdbe2ad8d21b28dce92887c" [[package]] name = "rav1e" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b" dependencies = [ + "aligned-vec", "arbitrary", "arg_enum_proc_macro", "arrayvec", + "av-scenechange", "av1-grain", "bitstream-io", "built", @@ -2064,23 +2099,21 @@ dependencies = [ "noop_proc_macro", "num-derive", "num-traits", - "once_cell", "paste", "profiling", "rand", "rand_chacha", "simd_helpers", - "system-deps", - "thiserror 1.0.69", + "thiserror 2.0.17", "v_frame", "wasm-bindgen", ] [[package]] name = "ravif" -version = "0.11.20" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b" +checksum = "ef69c1990ceef18a116855938e74793a5f7496ee907562bd0857b6ac734ab285" dependencies = [ "avif-serialize", "imgref", @@ -2272,15 +2305,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - [[package]] name = "shlex" version = "1.3.0" @@ -2289,9 +2313,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "simd-adler32" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "simd_helpers" @@ -2320,9 +2344,9 @@ checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "slotmap" -version = "1.0.7" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" dependencies = [ "version_check", ] @@ -2376,6 +2400,12 @@ dependencies = [ "bitflags 2.10.0", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2401,9 +2431,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.110" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -2419,25 +2449,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-deps" -version = "6.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" -dependencies = [ - "cfg-expr", - "heck", - "pkg-config", - "toml", - "version-compare", -] - -[[package]] -name = "target-lexicon" -version = "0.12.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" - [[package]] name = "tempfile" version = "3.23.0" @@ -2445,7 +2456,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom", "once_cell", "rustix 1.1.2", "windows-sys 0.61.2", @@ -2511,7 +2522,7 @@ dependencies = [ "half", "quick-error", "weezl", - "zune-jpeg", + "zune-jpeg 0.4.21", ] [[package]] @@ -2554,27 +2565,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime 0.6.11", - "toml_edit 0.22.27", -] - -[[package]] -name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "0.7.3" @@ -2586,25 +2576,12 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.27" +version = "0.23.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +checksum = "5d7cbc3b4b49633d57a0509303158ca50de80ae32c265093b24c414705807832" dependencies = [ "indexmap", - "serde", - "serde_spanned", - "toml_datetime 0.6.11", - "winnow", -] - -[[package]] -name = "toml_edit" -version = "0.23.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" -dependencies = [ - "indexmap", - "toml_datetime 0.7.3", + "toml_datetime", "toml_parser", "winnow", ] @@ -2620,9 +2597,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "pin-project-lite", "tracing-core", @@ -2630,19 +2607,18 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" [[package]] name = "tree_magic_mini" -version = "3.2.0" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f943391d896cdfe8eec03a04d7110332d445be7df856db382dd96a730667562c" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" dependencies = [ "memchr", - "nom 7.1.3", - "once_cell", + "nom", "petgraph", ] @@ -2675,9 +2651,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-script" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb421b350c9aff471779e262955939f565ec18b86c15364e6bdf0d662ca7c1f" +checksum = "383ad40bb927465ec0ce7720e033cb4ca06912855fc35db31b5755d0de75b1ee" [[package]] name = "unicode-segmentation" @@ -2702,12 +2678,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "version-compare" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" - [[package]] name = "version_check" version = "0.9.5" @@ -2724,12 +2694,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -2741,9 +2705,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" dependencies = [ "cfg-if", "once_cell", @@ -2754,9 +2718,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.55" +version = "0.4.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" dependencies = [ "cfg-if", "js-sys", @@ -2767,9 +2731,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2777,9 +2741,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" dependencies = [ "bumpalo", "proc-macro2", @@ -2790,9 +2754,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" dependencies = [ "unicode-ident", ] @@ -2908,9 +2872,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.82" +version = "0.3.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" dependencies = [ "js-sys", "wasm-bindgen", @@ -2943,7 +2907,7 @@ dependencies = [ "cfg-if", "cfg_aliases", "document-features", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "js-sys", "log", "naga", @@ -2974,7 +2938,7 @@ dependencies = [ "bytemuck", "cfg_aliases", "document-features", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "indexmap", "log", "naga", @@ -3041,7 +3005,7 @@ dependencies = [ "gpu-alloc", "gpu-allocator", "gpu-descriptor", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "js-sys", "khronos-egl", "libc", @@ -3189,15 +3153,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", -] - [[package]] name = "windows-sys" version = "0.61.2" @@ -3231,30 +3186,13 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", + "windows_i686_gnullvm", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -3267,12 +3205,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -3285,12 +3217,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -3303,24 +3229,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -3333,12 +3247,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -3351,12 +3259,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -3369,12 +3271,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -3387,12 +3283,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winit" version = "0.30.12" @@ -3447,9 +3337,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ "memchr", ] @@ -3542,6 +3432,12 @@ version = "0.8.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" +[[package]] +name = "y4m" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" + [[package]] name = "yazi" version = "0.2.1" @@ -3556,18 +3452,18 @@ checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", @@ -3580,6 +3476,12 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" +[[package]] +name = "zune-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111f7d9820f05fd715df3144e254d6fc02ee4088b0644c0ffd0efc9e6d9d2773" + [[package]] name = "zune-inflate" version = "0.2.54" @@ -3595,5 +3497,14 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ce2c8a9384ad323cf564b67da86e21d3cfdff87908bc1223ed5c99bc792713" dependencies = [ - "zune-core", + "zune-core 0.4.12", +] + +[[package]] +name = "zune-jpeg" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f520eebad972262a1dde0ec455bce4f8b298b1e5154513de58c114c4c54303e8" +dependencies = [ + "zune-core 0.5.0", ] diff --git a/Cargo.toml b/Cargo.toml index cdf93bf..14186b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,30 @@ [package] name = "iris" -version = "0.1.0" -edition = "2024" default-run = "test" +version.workspace = true +edition.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +iris-core = { workspace = true } +iris-macro = { workspace = true } +cosmic-text = { workspace = true } +unicode-segmentation = { workspace = true } +winit = { workspace = true } +arboard = { workspace = true, features = ["wayland-data-control"] } +pollster = { workspace = true } +wgpu = { workspace = true } +image = { workspace = true } + +[workspace] +members = ["core", "macro"] + +[workspace.package] +version = "0.1.0" +edition = "2024" + +[workspace.dependencies] pollster = "0.4.0" winit = "0.30.12" wgpu = "27.0.1" @@ -15,5 +33,6 @@ image = "0.25.6" cosmic-text = "0.15.0" unicode-segmentation = "1.12.0" fxhash = "0.2.1" -arboard = { version = "3.6.1", features = ["wayland-data-control"] } - +arboard = "3.6.1" +iris-core = { path = "core" } +iris-macro = { path = "macro" } diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 0000000..37b7960 --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "iris-core" +version.workspace = true +edition.workspace = true + +[dependencies] +winit = { workspace = true } +wgpu = { workspace = true } +bytemuck ={ workspace = true } +image = { workspace = true } +cosmic-text = { workspace = true } +fxhash = { workspace = true } + diff --git a/src/layout/attr.rs b/core/src/layout/attr.rs similarity index 89% rename from src/layout/attr.rs rename to core/src/layout/attr.rs index c10866c..5f9095d 100644 --- a/src/layout/attr.rs +++ b/core/src/layout/attr.rs @@ -1,4 +1,4 @@ -use crate::layout::{Ui, WidgetRef, WidgetIdFn, WidgetLike}; +use crate::layout::{Ui, WidgetIdFn, WidgetLike, WidgetRef}; pub trait WidgetAttr { type Input; diff --git a/src/layout/event.rs b/core/src/layout/event.rs similarity index 64% rename from src/layout/event.rs rename to core/src/layout/event.rs index c6a4f01..509e34f 100644 --- a/src/layout/event.rs +++ b/core/src/layout/event.rs @@ -33,92 +33,6 @@ impl) + 'static, Ctx, Data, W: ?Sized> WidgetEven { } -// TODO: naming in here is a bit weird like eventable -#[macro_export] -macro_rules! event_ctx { - ($ty: ty) => { - mod local_event_trait { - use super::*; - use std::marker::Sized; - #[allow(unused_imports)] - use $crate::prelude::*; - - #[allow(unused)] - pub trait EventableCtx { - fn on( - self, - event: E, - f: impl WidgetEventFn, - ) -> impl WidgetIdFn + EventableCtx; - } - - impl, Tag> EventableCtx for WL { - fn on( - self, - event: E, - f: impl WidgetEventFn<$ty, E::Data, WL::Widget>, - ) -> impl WidgetIdFn + EventableCtx { - eventable::Eventable::on(self, event, f) - } - } - - #[allow(unused)] - pub trait EventableCtxUi - where - WidgetRef: EventableCtx, - { - fn on( - &mut self, - widget: &WidgetRef, - event: E, - f: impl WidgetEventFn, - ); - } - - impl EventableCtxUi for Ui - where - WidgetRef: EventableCtx, - { - fn on( - &mut self, - widget: &WidgetRef, - event: E, - f: impl WidgetEventFn<$ty, E::Data, W>, - ) { - self.register_widget_event(&widget, event, f); - } - } - } - use local_event_trait::*; - }; -} -pub use event_ctx; - -pub mod eventable { - use super::*; - - pub trait Eventable { - fn on( - self, - event: E, - f: impl WidgetEventFn, - ) -> impl WidgetIdFn + Eventable; - } - - impl, Tag> Eventable for WL { - fn on( - self, - event: E, - f: impl WidgetEventFn, - ) -> impl WidgetIdFn { - move |ui| { - let id = self.add(ui); - ui.register_widget_event(&id, event, f); - id - } - } - } -} impl Ui { pub fn register_event( diff --git a/src/layout/mod.rs b/core/src/layout/mod.rs similarity index 63% rename from src/layout/mod.rs rename to core/src/layout/mod.rs index 89ba84c..b9a535b 100644 --- a/src/layout/mod.rs +++ b/core/src/layout/mod.rs @@ -1,34 +1,24 @@ mod attr; -mod color; mod event; -mod layer; mod module; mod num; mod orientation; mod painter; -mod text; -mod texture; +mod primitive; mod ui; mod view; mod widget; -mod widget_ref; -mod widgets; pub use attr::*; -pub use color::*; pub use event::*; -pub use layer::*; pub use module::*; pub use num::*; pub use orientation::*; pub use painter::*; -pub use text::*; -pub use texture::*; +pub use primitive::*; pub use ui::*; pub use view::*; pub use widget::*; -pub use widget_ref::*; -pub use widgets::*; pub use crate::util::Vec2; pub type UiColor = Color; diff --git a/src/layout/module.rs b/core/src/layout/module.rs similarity index 100% rename from src/layout/module.rs rename to core/src/layout/module.rs diff --git a/src/layout/num.rs b/core/src/layout/num.rs similarity index 99% rename from src/layout/num.rs rename to core/src/layout/num.rs index ef238c0..fa0b921 100644 --- a/src/layout/num.rs +++ b/core/src/layout/num.rs @@ -1,6 +1,5 @@ -use std::marker::Destruct; - use crate::util::Vec2; +use std::marker::Destruct; pub const trait UiNum { fn to_f32(self) -> f32; diff --git a/src/layout/orientation/align.rs b/core/src/layout/orientation/align.rs similarity index 100% rename from src/layout/orientation/align.rs rename to core/src/layout/orientation/align.rs diff --git a/src/layout/orientation/axis.rs b/core/src/layout/orientation/axis.rs similarity index 98% rename from src/layout/orientation/axis.rs rename to core/src/layout/orientation/axis.rs index 5b58a7e..d5c913a 100644 --- a/src/layout/orientation/axis.rs +++ b/core/src/layout/orientation/axis.rs @@ -6,6 +6,9 @@ pub enum Axis { Y, } +pub trait Axis_ { +} + impl std::ops::Not for Axis { type Output = Self; diff --git a/src/layout/orientation/len.rs b/core/src/layout/orientation/len.rs similarity index 100% rename from src/layout/orientation/len.rs rename to core/src/layout/orientation/len.rs diff --git a/src/layout/orientation/mod.rs b/core/src/layout/orientation/mod.rs similarity index 100% rename from src/layout/orientation/mod.rs rename to core/src/layout/orientation/mod.rs diff --git a/src/layout/orientation/pos.rs b/core/src/layout/orientation/pos.rs similarity index 100% rename from src/layout/orientation/pos.rs rename to core/src/layout/orientation/pos.rs diff --git a/src/layout/painter.rs b/core/src/layout/painter.rs similarity index 100% rename from src/layout/painter.rs rename to core/src/layout/painter.rs diff --git a/src/layout/color.rs b/core/src/layout/primitive/color.rs similarity index 100% rename from src/layout/color.rs rename to core/src/layout/primitive/color.rs diff --git a/src/layout/layer.rs b/core/src/layout/primitive/layer.rs similarity index 100% rename from src/layout/layer.rs rename to core/src/layout/primitive/layer.rs diff --git a/src/layout/mask.rs b/core/src/layout/primitive/mask.rs similarity index 100% rename from src/layout/mask.rs rename to core/src/layout/primitive/mask.rs diff --git a/core/src/layout/primitive/mod.rs b/core/src/layout/primitive/mod.rs new file mode 100644 index 0000000..8284a05 --- /dev/null +++ b/core/src/layout/primitive/mod.rs @@ -0,0 +1,9 @@ +mod color; +mod layer; +mod text; +mod texture; + +pub use color::*; +pub use layer::*; +pub use text::*; +pub use texture::*; diff --git a/src/layout/text.rs b/core/src/layout/primitive/text.rs similarity index 100% rename from src/layout/text.rs rename to core/src/layout/primitive/text.rs diff --git a/src/layout/texture.rs b/core/src/layout/primitive/texture.rs similarity index 100% rename from src/layout/texture.rs rename to core/src/layout/primitive/texture.rs diff --git a/src/layout/ui.rs b/core/src/layout/ui.rs similarity index 92% rename from src/layout/ui.rs rename to core/src/layout/ui.rs index 52c23dc..e2c3219 100644 --- a/src/layout/ui.rs +++ b/core/src/layout/ui.rs @@ -2,15 +2,14 @@ use image::DynamicImage; use crate::{ layout::{ - Event, EventFn, EventModule, IdLike, PainterData, PixelRegion, TextureHandle, Vec2, Widget, - WidgetEventFn, WidgetInstance, WidgetLike, WidgetRef, WidgetUpdate, + IdLike, PainterData, PixelRegion, TextureHandle, Vec2, Widget, WidgetInstance, WidgetLike, + WidgetRef, WidgetUpdate, }, util::{HashSet, Id}, }; use std::sync::mpsc::{Receiver, channel}; pub struct Ui { - // TODO: make this at least pub(super) pub(crate) data: PainterData, root: Option, updates: HashSet, @@ -30,7 +29,7 @@ impl Ui { } pub fn set_root(&mut self, w: impl WidgetLike) { - self.root = Some(w.add(self).any()); + self.root = Some(w.add(self)); self.full_redraw = true; } @@ -142,6 +141,14 @@ impl Ui { } }) } + + pub fn data(&self) -> &PainterData { + &self.data + } + + pub fn data_mut(&mut self) -> &mut PainterData { + &mut self.data + } } impl Default for Ui { diff --git a/src/layout/view.rs b/core/src/layout/view.rs similarity index 100% rename from src/layout/view.rs rename to core/src/layout/view.rs diff --git a/src/layout/widget_ref.rs b/core/src/layout/widget/handle.rs similarity index 93% rename from src/layout/widget_ref.rs rename to core/src/layout/widget/handle.rs index 738d09f..067669e 100644 --- a/src/layout/widget_ref.rs +++ b/core/src/layout/widget/handle.rs @@ -1,12 +1,12 @@ use std::{ cell::{Ref, RefMut}, marker::Unsize, - rc::Rc, + ops::CoerceUnsized, sync::mpsc::Sender, }; use crate::{ - layout::{Ui, Widget, WidgetLike}, + layout::{IdFnTag, IdTag, Ui, Widget, WidgetLike}, util::{Handle, Id, WeakHandle}, }; @@ -128,10 +128,7 @@ impl Drop for Inner { } } -pub struct IdTag; -pub struct IdFnTag; - -pub trait WidgetIdFn: FnOnce(&mut Ui) -> WidgetRef {} +pub trait WidgetIdFn: FnOnce(&mut Ui) -> WidgetRef {} impl WidgetRef> WidgetIdFn for F {} pub trait WidgetRet: FnOnce(&mut Ui) -> WidgetRef {} @@ -162,3 +159,5 @@ impl IdLike for WidgetRef { self.id() } } + +impl, U: ?Sized> CoerceUnsized> for WidgetRef {} diff --git a/src/layout/widget.rs b/core/src/layout/widget/like.rs similarity index 51% rename from src/layout/widget.rs rename to core/src/layout/widget/like.rs index cdd04d7..076ae9e 100644 --- a/src/layout/widget.rs +++ b/core/src/layout/widget/like.rs @@ -1,28 +1,5 @@ -use crate::{ - core::WidgetPtr, - layout::{Len, Painter, SizeCtx, Ui, WidgetIdFn, WidgetRef}, -}; - -use std::{any::Any, marker::Unsize}; - -pub trait Widget: Any { - fn draw(&mut self, painter: &mut Painter); - fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len; - fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len; -} - -impl Widget for () { - fn draw(&mut self, _: &mut Painter) {} - fn desired_width(&mut self, _: &mut SizeCtx) -> Len { - Len::ZERO - } - fn desired_height(&mut self, _: &mut SizeCtx) -> Len { - Len::ZERO - } -} - -pub struct WidgetTag; -pub struct FnTag; +use super::*; +use std::marker::Unsize; pub trait WidgetLike { type Widget: Widget + ?Sized + Unsize + 'static; @@ -48,34 +25,6 @@ pub trait WidgetLike { { ui.set_root(self); } - - fn set_ptr(self, ptr: &WidgetRef, ui: &mut Ui) - where - Self: Sized, - Self::Widget: Widget, - { - ptr.get_mut().inner = Some(self.add(ui).any()); - } -} - -/// A function that returns a widget given a UI. -/// Useful for defining trait functions on widgets that create a parent widget so that the children -/// don't need to be IDs yet -pub trait WidgetFn: FnOnce(&mut Ui) -> W {} -impl W> WidgetFn for F {} - -impl W> WidgetLike for F { - type Widget = W; - fn add(self, ui: &mut Ui) -> WidgetRef { - self(ui).add(ui) - } -} - -impl WidgetLike for W { - type Widget = W; - fn add(self, ui: &mut Ui) -> WidgetRef { - ui.add_widget(self) - } } pub struct WidgetArr { @@ -88,7 +37,6 @@ impl WidgetArr { } } -pub struct ArrTag; pub trait WidgetArrLike { fn ui(self, ui: &mut Ui) -> WidgetArr; } @@ -110,7 +58,7 @@ macro_rules! impl_widget_arr { #[allow(non_snake_case)] let ($($W,)*) = self; WidgetArr::new( - [$($W.add(ui).any(),)*], + [$($W.add(ui),)*], ) } } @@ -129,19 +77,3 @@ impl_widget_arr!(9;A B C D E F G H I); impl_widget_arr!(10;A B C D E F G H I J); impl_widget_arr!(11;A B C D E F G H I J K); impl_widget_arr!(12;A B C D E F G H I J K L); - -pub trait WidgetOption { - fn get(self, ui: &mut Ui) -> Option; -} - -impl WidgetOption for () { - fn get(self, _: &mut Ui) -> Option { - None - } -} - -impl Option> WidgetOption for F { - fn get(self, ui: &mut Ui) -> Option { - self(ui) - } -} diff --git a/core/src/layout/widget/mod.rs b/core/src/layout/widget/mod.rs new file mode 100644 index 0000000..20b2239 --- /dev/null +++ b/core/src/layout/widget/mod.rs @@ -0,0 +1,63 @@ +mod handle; +mod like; +mod tag; +mod widgets; + +pub use handle::*; +pub use like::*; +pub use tag::*; +pub use widgets::*; + +use crate::layout::{Len, Painter, SizeCtx, Ui}; + +pub trait Widget: 'static { + fn draw(&mut self, painter: &mut Painter); + fn desired_width(&mut self, ctx: &mut SizeCtx) -> Len; + fn desired_height(&mut self, ctx: &mut SizeCtx) -> Len; +} + +impl Widget for () { + fn draw(&mut self, _: &mut Painter) {} + fn desired_width(&mut self, _: &mut SizeCtx) -> Len { + Len::ZERO + } + fn desired_height(&mut self, _: &mut SizeCtx) -> Len { + Len::ZERO + } +} + +/// A function that returns a widget given a UI. +/// Useful for defining trait functions on widgets that create a parent widget so that the children +/// don't need to be IDs yet +pub trait WidgetFn: FnOnce(&mut Ui) -> W {} +impl W> WidgetFn for F {} + +impl W> WidgetLike for F { + type Widget = W; + fn add(self, ui: &mut Ui) -> WidgetRef { + self(ui).add(ui) + } +} + +impl WidgetLike for W { + type Widget = W; + fn add(self, ui: &mut Ui) -> WidgetRef { + ui.add_widget(self) + } +} + +pub trait WidgetOption { + fn get(self, ui: &mut Ui) -> Option; +} + +impl WidgetOption for () { + fn get(self, _: &mut Ui) -> Option { + None + } +} + +impl Option> WidgetOption for F { + fn get(self, ui: &mut Ui) -> Option { + self(ui) + } +} diff --git a/core/src/layout/widget/tag.rs b/core/src/layout/widget/tag.rs new file mode 100644 index 0000000..7f52a21 --- /dev/null +++ b/core/src/layout/widget/tag.rs @@ -0,0 +1,5 @@ +pub struct WidgetTag; +pub struct FnTag; +pub struct IdTag; +pub struct IdFnTag; +pub struct ArrTag; diff --git a/src/layout/widgets.rs b/core/src/layout/widget/widgets.rs similarity index 100% rename from src/layout/widgets.rs rename to core/src/layout/widget/widgets.rs diff --git a/core/src/lib.rs b/core/src/lib.rs new file mode 100644 index 0000000..f2ad881 --- /dev/null +++ b/core/src/lib.rs @@ -0,0 +1,19 @@ +#![feature(macro_metavar_expr_concat)] +#![feature(const_ops)] +#![feature(const_trait_impl)] +#![feature(const_convert)] +#![feature(map_try_insert)] +#![feature(unboxed_closures)] +#![feature(fn_traits)] +#![feature(const_cmp)] +#![feature(const_destruct)] +#![feature(portable_simd)] +#![feature(associated_type_defaults)] +#![feature(unsize)] +#![feature(coerce_unsized)] + +pub mod layout; +pub mod render; +pub mod util; + +pub use image; diff --git a/src/render/data.rs b/core/src/render/data.rs similarity index 100% rename from src/render/data.rs rename to core/src/render/data.rs diff --git a/src/render/mod.rs b/core/src/render/mod.rs similarity index 100% rename from src/render/mod.rs rename to core/src/render/mod.rs diff --git a/src/render/primitive.rs b/core/src/render/primitive.rs similarity index 100% rename from src/render/primitive.rs rename to core/src/render/primitive.rs diff --git a/src/render/shader.wgsl b/core/src/render/shader.wgsl similarity index 100% rename from src/render/shader.wgsl rename to core/src/render/shader.wgsl diff --git a/src/render/texture.rs b/core/src/render/texture.rs similarity index 100% rename from src/render/texture.rs rename to core/src/render/texture.rs diff --git a/src/render/util/mod.rs b/core/src/render/util/mod.rs similarity index 100% rename from src/render/util/mod.rs rename to core/src/render/util/mod.rs diff --git a/src/util/arena.rs b/core/src/util/arena.rs similarity index 100% rename from src/util/arena.rs rename to core/src/util/arena.rs diff --git a/src/util/change.rs b/core/src/util/change.rs similarity index 100% rename from src/util/change.rs rename to core/src/util/change.rs diff --git a/src/util/handle.rs b/core/src/util/handle.rs similarity index 93% rename from src/util/handle.rs rename to core/src/util/handle.rs index 7c4c604..4b208ea 100644 --- a/src/util/handle.rs +++ b/core/src/util/handle.rs @@ -9,7 +9,7 @@ pub struct Handle(Rc>); pub struct WeakHandle(Weak>); impl Handle { - pub fn get(&self) -> Ref { + pub fn get(&self) -> Ref<'_, T> { self.0.borrow() } @@ -44,7 +44,7 @@ impl Clone for WeakHandle { } } -impl Default for Handle { +impl Default for Handle { fn default() -> Self { Self(Default::default()) } diff --git a/src/util/id.rs b/core/src/util/id.rs similarity index 100% rename from src/util/id.rs rename to core/src/util/id.rs diff --git a/src/util/math.rs b/core/src/util/math.rs similarity index 100% rename from src/util/math.rs rename to core/src/util/math.rs diff --git a/src/util/mod.rs b/core/src/util/mod.rs similarity index 69% rename from src/util/mod.rs rename to core/src/util/mod.rs index 95bc474..a9e65a7 100644 --- a/src/util/mod.rs +++ b/core/src/util/mod.rs @@ -1,18 +1,18 @@ mod arena; mod change; +mod handle; mod id; mod math; mod refcount; mod vec2; -mod handle; -pub(crate) use arena::*; +pub use arena::*; pub use change::*; -pub(crate) use id::*; -pub(crate) use math::*; -pub(crate) use refcount::*; -pub use vec2::*; pub use handle::*; +pub use id::*; +pub use math::*; +pub use refcount::*; +pub use vec2::*; pub type HashMap = fxhash::FxHashMap; pub type HashSet = fxhash::FxHashSet; diff --git a/src/util/refcount.rs b/core/src/util/refcount.rs similarity index 100% rename from src/util/refcount.rs rename to core/src/util/refcount.rs diff --git a/src/util/vec2.rs b/core/src/util/vec2.rs similarity index 100% rename from src/util/vec2.rs rename to core/src/util/vec2.rs diff --git a/examples/minimal.rs b/examples/minimal.rs index 60af299..3377458 100644 --- a/examples/minimal.rs +++ b/examples/minimal.rs @@ -1,4 +1,4 @@ -use iris::{prelude::*, winit::*}; +use iris::{prelude::*}; fn main() { DefaultApp::::run(); diff --git a/macro/Cargo.toml b/macro/Cargo.toml new file mode 100644 index 0000000..88997fa --- /dev/null +++ b/macro/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "iris-macro" +version.workspace = true +edition.workspace = true + +[dependencies] +quote = "1.0.42" +syn = { version = "2.0.111", features = ["full"] } + +[lib] +proc-macro = true diff --git a/macro/src/lib.rs b/macro/src/lib.rs new file mode 100644 index 0000000..90a6c71 --- /dev/null +++ b/macro/src/lib.rs @@ -0,0 +1,72 @@ +extern crate proc_macro; +use proc_macro::TokenStream; +use quote::quote; +use syn::{ + Block, Ident, Signature, Token, Visibility, + parse::{Parse, ParseStream, Result}, + parse_macro_input, +}; + +struct Input { + vis: Visibility, + name: Ident, + fns: Vec, +} + +struct InputFn { + sig: Signature, + body: Block, +} + +impl Parse for Input { + fn parse(input: ParseStream) -> Result { + let vis = input.parse()?; + let name = input.parse()?; + input.parse::()?; + let mut fns = Vec::new(); + while !input.is_empty() { + let sig = input.parse()?; + let body = input.parse()?; + fns.push(InputFn { sig, body }) + } + if !input.is_empty() { + input.error("function expected"); + } + Ok(Input { vis, name, fns }) + } +} + +// pub trait $name, Tag> { +// $( +// fn $fn $(<$($T $(: $TT $(+ $TL)?)?,)*>)?($self $(, $arg: $ty)*) -> $ret; +// )* +// } +// +// impl, Tag> $name for W { +// $( +// fn $fn $(<$($T $(: $TT $(+ $TL)?)?,)*>)?($self $(, $arg: $ty)*) -> $ret { +// $code +// } +// )* +// } + +#[proc_macro] +pub fn widget_trait(input: TokenStream) -> TokenStream { + let Input { vis, name, fns } = parse_macro_input!(input as Input); + + let sigs: Vec<_> = fns.iter().map(|f| f.sig.clone()).collect(); + let impls: Vec<_> = fns + .iter() + .map(|InputFn { sig, body }| quote! { #sig #body }) + .collect(); + + TokenStream::from(quote! { + #vis trait #name, Tag> { + #(#sigs;)* + } + + impl, Tag> #name for WL { + #(#impls)* + } + }) +} diff --git a/readme.md b/readme.md index 91b3d16..383aa94 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # iris -my take on a rust ui library (also my first ui library) +my fisrt attempt at a rust ui library it's called iris because it's the structure around what you actually want to display and colorful diff --git a/src/bin/test/main.rs b/src/bin/test/main.rs index a13e41d..be4c76c 100644 --- a/src/bin/test/main.rs +++ b/src/bin/test/main.rs @@ -56,10 +56,9 @@ impl DefaultAppState for Client { let add_button = rect(Color::LIME) .radius(30) .on(CursorSense::click(), move |ctx| { - let child = ctx - .ui - .add(image(include_bytes!("assets/sungals.png")).center()) - .any(); + let child = image(include_bytes!("assets/sungals.png")) + .center() + .add(ctx.ui); span_add_.get_mut().children.push(child); }) .sized((150, 150)) @@ -106,7 +105,7 @@ impl DefaultAppState for Client { .text_align(Align::LEFT) .size(30) .attr::(()) - .on(iris::winit::Submit, move |ctx| { + .on(Submit, move |ctx| { let content = ctx.widget.get_mut().take(); let text = wtext(content) .editable(false) @@ -115,7 +114,7 @@ impl DefaultAppState for Client { .wrap(true) .attr::(()); let msg_box = text.background(rect(Color::WHITE.darker(0.5))).add(ctx.ui); - texts.get_mut().children.push(msg_box.any()); + texts.get_mut().children.push(msg_box); }) .add(ui); let text_edit_scroll = ( @@ -163,13 +162,13 @@ impl DefaultAppState for Client { }; let tabs = ( - switch_button(Color::RED, pad_test.any(), "pad"), - switch_button(Color::GREEN, span_test.any(), "span"), - switch_button(Color::BLUE, span_add_test.any(), "image span"), - switch_button(Color::MAGENTA, text_test.any(), "text layout"), + switch_button(Color::RED, pad_test, "pad"), + switch_button(Color::GREEN, span_test, "span"), + switch_button(Color::BLUE, span_add_test, "image span"), + switch_button(Color::MAGENTA, text_test, "text layout"), switch_button( Color::YELLOW.mul_rgb(0.5), - text_edit_scroll.any(), + text_edit_scroll, "text edit scroll", ), ) diff --git a/src/winit/app.rs b/src/default/app.rs similarity index 100% rename from src/winit/app.rs rename to src/default/app.rs diff --git a/src/winit/attr.rs b/src/default/attr.rs similarity index 97% rename from src/winit/attr.rs rename to src/default/attr.rs index ab8b2aa..298953a 100644 --- a/src/winit/attr.rs +++ b/src/default/attr.rs @@ -1,4 +1,4 @@ -use crate::{prelude::*, winit::UiState}; +use crate::{prelude::*, default::UiState}; use std::time::{Duration, Instant}; use winit::dpi::{LogicalPosition, LogicalSize}; diff --git a/src/winit/event.rs b/src/default/event.rs similarity index 100% rename from src/winit/event.rs rename to src/default/event.rs diff --git a/src/winit/input.rs b/src/default/input.rs similarity index 97% rename from src/winit/input.rs rename to src/default/input.rs index 811653f..1a6604f 100644 --- a/src/winit/input.rs +++ b/src/default/input.rs @@ -1,7 +1,7 @@ use crate::{ - core::{CursorState, Modifiers}, + widget::{CursorState, Modifiers}, layout::Vec2, - winit::UiState, + default::UiState, }; use winit::{ event::{MouseButton, MouseScrollDelta, WindowEvent}, diff --git a/src/winit/mod.rs b/src/default/mod.rs similarity index 100% rename from src/winit/mod.rs rename to src/default/mod.rs diff --git a/src/winit/render.rs b/src/default/render.rs similarity index 100% rename from src/winit/render.rs rename to src/default/render.rs diff --git a/src/lib.rs b/src/lib.rs index f80ef24..d484399 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,28 +1,23 @@ -#![feature(macro_metavar_expr_concat)] -#![feature(const_ops)] -#![feature(const_trait_impl)] -#![feature(const_convert)] -#![feature(map_try_insert)] #![feature(unboxed_closures)] #![feature(fn_traits)] -#![feature(const_cmp)] -#![feature(const_destruct)] -#![feature(portable_simd)] #![feature(gen_blocks)] #![feature(associated_type_defaults)] -#![feature(unsize)] -#![feature(coerce_unsized)] -pub mod core; -pub mod layout; -pub mod render; -pub mod util; -pub mod winit; +mod default; +mod traits; +mod widget; + +pub use iris_core::*; +pub use iris_macro::*; pub mod prelude { - pub use crate::core::*; - pub use crate::layout::*; - pub use crate::render::*; - pub use crate::util::Handle; - pub use crate::winit::*; + pub use super::default::*; + pub use super::traits::*; + pub use super::widget::*; + + pub use iris_core::layout::*; + pub use iris_core::render::*; + pub use iris_core::util::Handle; + + pub use iris_macro::*; } diff --git a/src/traits.rs b/src/traits.rs new file mode 100644 index 0000000..b5bb34e --- /dev/null +++ b/src/traits.rs @@ -0,0 +1,82 @@ +use crate::prelude::*; +use iris_macro::widget_trait; + +// TODO: naming in here is a bit weird like eventable +#[macro_export] +macro_rules! event_ctx { + ($ty: ty) => { + mod local_event_trait { + use super::*; + use std::marker::Sized; + #[allow(unused_imports)] + use $crate::prelude::*; + + #[allow(unused)] + pub trait EventableCtx { + fn on( + self, + event: E, + f: impl WidgetEventFn, + ) -> impl WidgetIdFn + EventableCtx; + } + + impl, Tag> EventableCtx for WL { + fn on( + self, + event: E, + f: impl WidgetEventFn<$ty, E::Data, WL::Widget>, + ) -> impl WidgetIdFn + EventableCtx { + eventable::Eventable::on(self, event, f) + } + } + + #[allow(unused)] + pub trait EventableCtxUi + where + WidgetRef: EventableCtx, + { + fn on( + &mut self, + widget: &WidgetRef, + event: E, + f: impl WidgetEventFn, + ); + } + + impl EventableCtxUi for Ui + where + WidgetRef: EventableCtx, + { + fn on( + &mut self, + widget: &WidgetRef, + event: E, + f: impl WidgetEventFn<$ty, E::Data, W>, + ) { + self.register_widget_event(&widget, event, f); + } + } + } + use local_event_trait::*; + }; +} +pub use event_ctx; + +pub mod eventable { + use super::*; + + widget_trait!( + pub Eventable; + fn on( + self, + event: E, + f: impl WidgetEventFn, + ) -> impl WidgetIdFn { + move |ui| { + let id = self.add(ui); + ui.register_widget_event(&id, event, f); + id + } + } + ); +} diff --git a/src/core/event.rs b/src/widget/event.rs similarity index 100% rename from src/core/event.rs rename to src/widget/event.rs diff --git a/src/core/image.rs b/src/widget/image.rs similarity index 100% rename from src/core/image.rs rename to src/widget/image.rs index a2b58b9..83feb97 100644 --- a/src/core/image.rs +++ b/src/widget/image.rs @@ -1,5 +1,5 @@ -use crate::prelude::*; use image::DynamicImage; +use crate::prelude::*; pub struct Image { handle: TextureHandle, diff --git a/src/core/mask.rs b/src/widget/mask.rs similarity index 100% rename from src/core/mask.rs rename to src/widget/mask.rs diff --git a/src/core/mod.rs b/src/widget/mod.rs similarity index 100% rename from src/core/mod.rs rename to src/widget/mod.rs diff --git a/src/core/position/align.rs b/src/widget/position/align.rs similarity index 100% rename from src/core/position/align.rs rename to src/widget/position/align.rs diff --git a/src/core/position/layer.rs b/src/widget/position/layer.rs similarity index 100% rename from src/core/position/layer.rs rename to src/widget/position/layer.rs diff --git a/src/core/position/max_size.rs b/src/widget/position/max_size.rs similarity index 100% rename from src/core/position/max_size.rs rename to src/widget/position/max_size.rs diff --git a/src/core/position/mod.rs b/src/widget/position/mod.rs similarity index 100% rename from src/core/position/mod.rs rename to src/widget/position/mod.rs diff --git a/src/core/position/offset.rs b/src/widget/position/offset.rs similarity index 100% rename from src/core/position/offset.rs rename to src/widget/position/offset.rs diff --git a/src/core/position/pad.rs b/src/widget/position/pad.rs similarity index 100% rename from src/core/position/pad.rs rename to src/widget/position/pad.rs diff --git a/src/core/position/scroll.rs b/src/widget/position/scroll.rs similarity index 100% rename from src/core/position/scroll.rs rename to src/widget/position/scroll.rs diff --git a/src/core/position/sized.rs b/src/widget/position/sized.rs similarity index 100% rename from src/core/position/sized.rs rename to src/widget/position/sized.rs diff --git a/src/core/position/span.rs b/src/widget/position/span.rs similarity index 100% rename from src/core/position/span.rs rename to src/widget/position/span.rs diff --git a/src/core/position/stack.rs b/src/widget/position/stack.rs similarity index 100% rename from src/core/position/stack.rs rename to src/widget/position/stack.rs diff --git a/src/core/ptr.rs b/src/widget/ptr.rs similarity index 100% rename from src/core/ptr.rs rename to src/widget/ptr.rs diff --git a/src/core/rect.rs b/src/widget/rect.rs similarity index 100% rename from src/core/rect.rs rename to src/widget/rect.rs diff --git a/src/core/sense.rs b/src/widget/sense.rs similarity index 95% rename from src/core/sense.rs rename to src/widget/sense.rs index a1714ca..feedc8d 100644 --- a/src/core/sense.rs +++ b/src/widget/sense.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use crate::util::Id; use std::{ ops::{BitOr, Deref, DerefMut}, @@ -7,7 +8,7 @@ use std::{ use crate::{ layout::{UiModule, UiRegion, Vec2}, - util::{HashMap, Id}, + util::HashMap, }; #[derive(Clone, Copy, PartialEq)] @@ -166,8 +167,12 @@ impl CursorModule { } } -impl Ui { - pub fn run_sensors( +pub trait SensorUi { + fn run_sensors(&mut self, ctx: &mut Ctx, cursor: &CursorState, window_size: Vec2); +} + +impl SensorUi for Ui { + fn run_sensors( &mut self, ctx: &mut Ctx, cursor: &CursorState, @@ -179,8 +184,8 @@ impl Ui { impl CursorModule { pub fn run(ui: &mut Ui, ctx: &mut Ctx, cursor: &CursorState, window_size: Vec2) { - let layers = std::mem::take(&mut ui.data.layers); - let mut module = std::mem::take(ui.data.modules.get_mut::()); + let layers = std::mem::take(&mut ui.data_mut().layers); + let mut module = std::mem::take(ui.data_mut().modules.get_mut::()); for i in layers.indices().rev() { let Some(list) = module.active.get_mut(&i) else { @@ -218,10 +223,10 @@ impl CursorModule { } } - let ui_mod = ui.data.modules.get_mut::(); + let ui_mod = ui.data_mut().modules.get_mut::(); std::mem::swap(ui_mod, &mut module); ui_mod.merge(module); - ui.data.layers = layers; + ui.data_mut().layers = layers; } } diff --git a/src/core/text/build.rs b/src/widget/text/build.rs similarity index 95% rename from src/core/text/build.rs rename to src/widget/text/build.rs index b56a09c..3c9d601 100644 --- a/src/core/text/build.rs +++ b/src/widget/text/build.rs @@ -75,7 +75,7 @@ impl TextBuilderOutput for TextOutput { builder.attrs.line_height, )); let hint = builder.hint.get(ui); - let font_system = &mut ui.data.text.get_mut().font_system; + let font_system = &mut ui.data().text.get_mut().font_system; buf.set_text(font_system, &builder.content, &Attrs::new(), SHAPING, None); let mut text = Text { content: builder.content.into(), @@ -101,9 +101,9 @@ impl TextBuilderOutput for TextEditOutput { let mut text = TextEdit::new( TextView::new(buf, builder.attrs, builder.hint.get(ui)), builder.output.single_line, - ui.data.text.clone(), + ui.data().text.clone(), ); - let font_system = &mut ui.data.text.get_mut().font_system; + let font_system = &mut ui.data().text.get_mut().font_system; text.buf .set_text(font_system, &builder.content, &Attrs::new(), SHAPING, None); builder.attrs.apply(font_system, &mut text.buf, None); diff --git a/src/core/text/edit.rs b/src/widget/text/edit.rs similarity index 100% rename from src/core/text/edit.rs rename to src/widget/text/edit.rs diff --git a/src/core/text/mod.rs b/src/widget/text/mod.rs similarity index 100% rename from src/core/text/mod.rs rename to src/widget/text/mod.rs diff --git a/src/core/trait_fns.rs b/src/widget/trait_fns.rs similarity index 60% rename from src/core/trait_fns.rs rename to src/widget/trait_fns.rs index 9ef6434..71dde65 100644 --- a/src/core/trait_fns.rs +++ b/src/widget/trait_fns.rs @@ -1,39 +1,22 @@ -use super::*; use crate::prelude::*; +use iris_macro::widget_trait; // these methods should "not require any context" (require unit) because they're in core event_ctx!(()); -pub trait CoreWidget { - fn pad(self, padding: impl Into) -> impl WidgetFn; - fn align(self, align: impl Into) -> impl WidgetFn; - fn center(self) -> impl WidgetFn; - fn label(self, label: impl Into) -> impl WidgetIdFn; - fn sized(self, size: impl Into) -> impl WidgetFn; - fn width(self, len: impl Into) -> impl WidgetFn; - fn height(self, len: impl Into) -> impl WidgetFn; - fn max_width(self, width: impl Into) -> impl WidgetFn; - fn max_height(self, height: impl Into) -> impl WidgetFn; - fn offset(self, amt: impl Into) -> impl WidgetFn; - fn scroll(self) -> impl WidgetIdFn; - fn masked(self) -> impl WidgetFn; - fn background(self, w: impl WidgetLike) -> impl WidgetFn; - fn foreground(self, w: impl WidgetLike) -> impl WidgetFn; - fn layer_offset(self, offset: usize) -> impl WidgetFn; - fn to_any(self) -> impl WidgetRet; -} +widget_trait!( + pub CoreWidget; -impl, Tag> CoreWidget for W { fn pad(self, padding: impl Into) -> impl WidgetFn { |ui| Pad { padding: padding.into(), - inner: self.add(ui).any(), + inner: self.add(ui), } } fn align(self, align: impl Into) -> impl WidgetFn { move |ui| Aligned { - inner: self.add(ui).any(), + inner: self.add(ui), align: align.into(), } } @@ -42,7 +25,7 @@ impl, Tag> CoreWidget for W { self.align(Align::CENTER) } - fn label(self, label: impl Into) -> impl WidgetIdFn { + fn label(self, label: impl Into) -> impl WidgetIdFn { |ui| { let id = self.add(ui); id.set_label(label); @@ -53,7 +36,7 @@ impl, Tag> CoreWidget for W { fn sized(self, size: impl Into) -> impl WidgetFn { let size = size.into(); move |ui| Sized { - inner: self.add(ui).any(), + inner: self.add(ui), x: Some(size.x), y: Some(size.y), } @@ -62,7 +45,7 @@ impl, Tag> CoreWidget for W { fn max_width(self, len: impl Into) -> impl WidgetFn { let len = len.into(); move |ui| MaxSize { - inner: self.add(ui).any(), + inner: self.add(ui), x: Some(len), y: None, } @@ -71,7 +54,7 @@ impl, Tag> CoreWidget for W { fn max_height(self, len: impl Into) -> impl WidgetFn { let len = len.into(); move |ui| MaxSize { - inner: self.add(ui).any(), + inner: self.add(ui), x: None, y: Some(len), } @@ -80,7 +63,7 @@ impl, Tag> CoreWidget for W { fn width(self, len: impl Into) -> impl WidgetFn { let len = len.into(); move |ui| Sized { - inner: self.add(ui).any(), + inner: self.add(ui), x: Some(len), y: None, } @@ -89,7 +72,7 @@ impl, Tag> CoreWidget for W { fn height(self, len: impl Into) -> impl WidgetFn { let len = len.into(); move |ui| Sized { - inner: self.add(ui).any(), + inner: self.add(ui), x: None, y: Some(len), } @@ -97,14 +80,14 @@ impl, Tag> CoreWidget for W { fn offset(self, amt: impl Into) -> impl WidgetFn { move |ui| Offset { - inner: self.add(ui).any(), + inner: self.add(ui), amt: amt.into(), } } fn scroll(self) -> impl WidgetIdFn { move |ui| { - Scroll::new(self.add(ui).any(), Axis::Y) + Scroll::new(self.add(ui), Axis::Y) .on(CursorSense::Scroll, |ctx| { let s = &mut *ctx.widget.get_mut(); s.scroll(ctx.data.scroll_delta.y * 50.0); @@ -115,35 +98,39 @@ impl, Tag> CoreWidget for W { fn masked(self) -> impl WidgetFn { move |ui| Masked { - inner: self.add(ui).any(), + inner: self.add(ui), } } - fn background(self, w: impl WidgetLike) -> impl WidgetFn { + fn background(self, w: impl WidgetLike) -> impl WidgetFn { move |ui| Stack { - children: vec![w.add(ui).any(), self.add(ui).any()], + children: vec![w.add(ui), self.add(ui)], size: StackSize::Child(1), } } - fn foreground(self, w: impl WidgetLike) -> impl WidgetFn { + fn foreground(self, w: impl WidgetLike) -> impl WidgetFn { move |ui| Stack { - children: vec![self.add(ui).any(), w.add(ui).any()], + children: vec![self.add(ui), w.add(ui)], size: StackSize::Child(0), } } fn layer_offset(self, offset: usize) -> impl WidgetFn { move |ui| LayerOffset { - inner: self.add(ui).any(), + inner: self.add(ui), offset, } } fn to_any(self) -> impl WidgetRet { - |ui| self.add(ui).any() + |ui| self.add(ui) } -} + + fn set_ptr(self, ptr: &WidgetRef, ui: &mut Ui) { + ptr.get_mut().inner = Some(self.add(ui)); + } +); pub trait CoreWidgetArr, Tag> { fn span(self, dir: Dir) -> SpanBuilder;