From c9e42e6c2cb90494ecf5436a64102d0d4be68de0 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 17 Mar 2022 23:14:45 +0100 Subject: [PATCH] Add a basic adapter for vizia --- Cargo.lock | 507 +++++++++++++++++++++++++++++++++++--- Cargo.toml | 1 + README.md | 3 +- nih_plug_egui/README.md | 3 +- nih_plug_vizia/Cargo.toml | 18 ++ nih_plug_vizia/README.md | 4 + nih_plug_vizia/src/lib.rs | 138 +++++++++++ 7 files changed, 639 insertions(+), 35 deletions(-) create mode 100644 nih_plug_vizia/Cargo.toml create mode 100644 nih_plug_vizia/README.md create mode 100644 nih_plug_vizia/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index f0667fd3..b8ea3401 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + [[package]] name = "ab_glyph" version = "0.2.15" @@ -50,6 +56,21 @@ dependencies = [ "memchr 0.1.11", ] +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr 2.4.1", +] + +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "anyhow" version = "1.0.56" @@ -215,7 +236,7 @@ checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" dependencies = [ "async-io", "blocking", - "cfg-if", + "cfg-if 1.0.0", "event-listener", "futures-lite", "libc", @@ -419,6 +440,12 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -606,7 +633,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -623,7 +650,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-channel", "crossbeam-deque", "crossbeam-epoch", @@ -637,7 +664,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdbfe11fe19ff083c48923cf179540e8cd0535903dc35e178a1fdeeb59aef51f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -647,7 +674,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -659,7 +686,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" dependencies = [ "autocfg", - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "lazy_static 1.4.0", "memoffset", @@ -672,7 +699,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -682,10 +709,37 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "lazy_static 1.4.0", ] +[[package]] +name = "cssparser" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa 0.4.8", + "matches", + "phf", + "proc-macro2", + "quote", + "smallvec", + "syn", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "ctor" version = "0.1.21" @@ -757,7 +811,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-sys-next", ] @@ -787,6 +841,21 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + +[[package]] +name = "dtoa-short" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bde03329ae10e79ede66c9ce4dc930aa8599043b0743008548680f25b91502d6" +dependencies = [ + "dtoa", +] + [[package]] name = "dwrote" version = "0.11.0" @@ -882,6 +951,29 @@ dependencies = [ "instant", ] +[[package]] +name = "femtovg" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f95b1b0a3a4dc9bb7f866b2d6efc9c5c5f5bccefc21e40be75dfc2c12cb6ef8" +dependencies = [ + "bitflags", + "fnv", + "generational-arena", + "glow", + "image 0.24.1", + "imgref", + "lru", + "ouroboros", + "rgb", + "rustybuzz 0.5.0", + "ttf-parser 0.15.0", + "unicode-bidi", + "unicode-segmentation", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "fftw" version = "0.7.0" @@ -927,7 +1019,7 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crc32fast", "libc", "miniz_oxide 0.4.4", @@ -954,6 +1046,46 @@ dependencies = [ "num-traits", ] +[[package]] +name = "fluent-bundle" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e242c601dec9711505f6d5bbff5bedd4b61b2469f2e8bb8e57ee7c9747a87ffd" +dependencies = [ + "fluent-langneg", + "fluent-syntax", + "intl-memoizer", + "intl_pluralrules", + "rustc-hash", + "self_cell", + "smallvec", + "unic-langid", +] + +[[package]] +name = "fluent-langneg" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94" +dependencies = [ + "unic-langid", +] + +[[package]] +name = "fluent-syntax" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0abed97648395c902868fee9026de96483933faa54ea3b40d652f7dfe61ca78" +dependencies = [ + "thiserror", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "font-kit" version = "0.10.1" @@ -1040,7 +1172,7 @@ checksum = "542951aad0071952c27409e3bd7cb62d1a3ad419c4e7314106bf994e0083ad5d" dependencies = [ "chrono", "lazy_static 0.1.16", - "regex", + "regex 0.1.80", ] [[package]] @@ -1174,13 +1306,22 @@ dependencies = [ "nih_plug_iced", ] +[[package]] +name = "generational-arena" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "getrandom" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -1191,7 +1332,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] @@ -1499,7 +1640,7 @@ dependencies = [ "guillotiere", "iced_graphics", "iced_native", - "image", + "image 0.23.14", "kamadak-exif", "log", "raw-window-handle", @@ -1522,11 +1663,32 @@ dependencies = [ "gif", "jpeg-decoder", "num-iter", - "num-rational", + "num-rational 0.3.2", "num-traits", "png 0.16.8", ] +[[package]] +name = "image" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db207d030ae38f1eb6f240d5a1c1c88ff422aa005d10f8c6c6fc5e75286ab30e" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "num-iter", + "num-rational 0.4.0", + "num-traits", + "png 0.17.5", +] + +[[package]] +name = "imgref" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d0c0db6c932f8262e0ed8909f2e7f8c0e9b1cfb4da884267ce09a10be54365" + [[package]] name = "indexmap" version = "1.8.0" @@ -1549,12 +1711,38 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", ] +[[package]] +name = "intl-memoizer" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c310433e4a310918d6ed9243542a6b83ec1183df95dff8f23f87bb88a264a66f" +dependencies = [ + "type-map", + "unic-langid", +] + +[[package]] +name = "intl_pluralrules" +version = "7.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b18f988384267d7066cc2be425e6faf352900652c046b6971d2e228d3b1c5ecf" +dependencies = [ + "tinystr", + "unic-langid", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + [[package]] name = "itoa" version = "1.0.1" @@ -1671,7 +1859,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi 0.3.9", ] @@ -1681,6 +1869,19 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +[[package]] +name = "locale_config" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934" +dependencies = [ + "lazy_static 1.4.0", + "objc", + "objc-foundation", + "regex 1.5.5", + "winapi 0.3.9", +] + [[package]] name = "lock_api" version = "0.4.6" @@ -1696,10 +1897,16 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "value-bag", ] +[[package]] +name = "lru" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb87f3080f6d1d69e8c564c0fcfde1d7aa8cc451ce40cae89479111f03bc0eb" + [[package]] name = "lyon" version = "0.17.10" @@ -1855,6 +2062,15 @@ dependencies = [ "adler", ] +[[package]] +name = "morphorm" +version = "0.3.0" +source = "git+https://github.com/vizia/morphorm?rev=8d955d2f1d5b698e4fd1dbdfe36b3f3d9adbd19a#8d955d2f1d5b698e4fd1dbdfe36b3f3d9adbd19a" +dependencies = [ + "bitflags", + "smallvec", +] + [[package]] name = "mutate_once" version = "0.1.1" @@ -1899,7 +2115,7 @@ dependencies = [ "assert_no_alloc", "atomic_float", "atomic_refcell", - "cfg-if", + "cfg-if 1.0.0", "clap-sys", "crossbeam", "lazy_static 1.4.0", @@ -1951,6 +2167,17 @@ dependencies = [ "nih_plug_assets", ] +[[package]] +name = "nih_plug_vizia" +version = "0.0.0" +dependencies = [ + "baseview", + "crossbeam", + "nih_plug", + "nih_plug_assets", + "vizia", +] + [[package]] name = "nih_plug_xtask" version = "0.1.0" @@ -1970,7 +2197,7 @@ checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" dependencies = [ "bitflags", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset", ] @@ -2043,6 +2270,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.14" @@ -2116,6 +2354,30 @@ dependencies = [ "num-traits", ] +[[package]] +name = "ouroboros" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71643f290d126e18ac2598876d01e1d57aed164afc78fdb6e2a0c6589a1f6662" +dependencies = [ + "aliasable", + "ouroboros_macro", + "stable_deref_trait", +] + +[[package]] +name = "ouroboros_macro" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9a247206016d424fe8497bc611e510887af5c261fbbf977877c4bb55ca4d82" +dependencies = [ + "Inflector", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "owned_ttf_parser" version = "0.15.0" @@ -2182,7 +2444,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "instant", "libc", "redox_syscall", @@ -2196,7 +2458,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", @@ -2237,7 +2499,9 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ + "phf_macros", "phf_shared", + "proc-macro-hack", ] [[package]] @@ -2260,6 +2524,20 @@ dependencies = [ "rand 0.7.3", ] +[[package]] +name = "phf_macros" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "phf_shared" version = "0.8.0" @@ -2329,7 +2607,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "log", "wepoll-ffi", @@ -2342,6 +2620,36 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + [[package]] name = "proc-macro2" version = "1.0.36" @@ -2536,12 +2844,13 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55" dependencies = [ "getrandom 0.2.5", "redox_syscall", + "thiserror", ] [[package]] @@ -2559,19 +2868,36 @@ version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" dependencies = [ - "aho-corasick", + "aho-corasick 0.5.3", "memchr 0.1.11", - "regex-syntax", + "regex-syntax 0.3.9", "thread_local", "utf8-ranges", ] +[[package]] +name = "regex" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +dependencies = [ + "aho-corasick 0.7.18", + "memchr 2.4.1", + "regex-syntax 0.6.25", +] + [[package]] name = "regex-syntax" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + [[package]] name = "renderdoc-sys" version = "0.7.1" @@ -2643,6 +2969,22 @@ dependencies = [ "unicode-script", ] +[[package]] +name = "rustybuzz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ff94f20221325d000e552781713e53b0d85c1d9551b6f420d12daf5a08eace" +dependencies = [ + "bitflags", + "bytemuck", + "smallvec", + "ttf-parser 0.15.0", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-general-category", + "unicode-script", +] + [[package]] name = "ryu" version = "1.0.9" @@ -2699,6 +3041,12 @@ dependencies = [ "syn", ] +[[package]] +name = "self_cell" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af" + [[package]] name = "semver" version = "0.11.0" @@ -2743,7 +3091,7 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] @@ -2906,6 +3254,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -3023,11 +3377,17 @@ dependencies = [ "arrayref", "arrayvec 0.5.2", "bytemuck", - "cfg-if", + "cfg-if 1.0.0", "png 0.17.5", "safe_arch", ] +[[package]] +name = "tinystr" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1" + [[package]] name = "tokio" version = "1.17.0" @@ -3074,17 +3434,44 @@ version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] +[[package]] +name = "type-map" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d3364c5e96cb2ad1603037ab253ddd34d7fb72a58bdddf4b7350760fc69a46" +dependencies = [ + "rustc-hash", +] + [[package]] name = "ucd-trie" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +[[package]] +name = "unic-langid" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5" +dependencies = [ + "unic-langid-impl", +] + +[[package]] +name = "unic-langid-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d" +dependencies = [ + "tinystr", +] + [[package]] name = "unicode-bidi" version = "0.3.7" @@ -3155,7 +3542,7 @@ dependencies = [ "pico-args", "rctree", "roxmltree", - "rustybuzz", + "rustybuzz 0.4.0", "simplecss", "siphasher", "svgtypes", @@ -3197,6 +3584,60 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vizia" +version = "0.1.0" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=feature/baseview-modifiers#23e42ad14b98c4bb8420e5138cd7794e3d842b8b" +dependencies = [ + "vizia_baseview", + "vizia_core", +] + +[[package]] +name = "vizia_baseview" +version = "0.1.0" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=feature/baseview-modifiers#23e42ad14b98c4bb8420e5138cd7794e3d842b8b" +dependencies = [ + "baseview", + "femtovg", + "keyboard-types", + "raw-window-handle", + "vizia_core", +] + +[[package]] +name = "vizia_core" +version = "0.1.0" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=feature/baseview-modifiers#23e42ad14b98c4bb8420e5138cd7794e3d842b8b" +dependencies = [ + "bitflags", + "copypasta", + "cssparser", + "femtovg", + "fluent-bundle", + "fluent-langneg", + "fluent-syntax", + "fnv", + "image 0.24.1", + "instant", + "keyboard-types", + "locale_config", + "morphorm", + "unic-langid", + "unicode-segmentation", + "vizia_derive", +] + +[[package]] +name = "vizia_derive" +version = "0.1.0" +source = "git+https://github.com/robbert-vdh/vizia.git?branch=feature/baseview-modifiers#23e42ad14b98c4bb8420e5138cd7794e3d842b8b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "vst3-com" version = "0.1.0" @@ -3269,7 +3710,7 @@ version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -3294,7 +3735,7 @@ version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", diff --git a/Cargo.toml b/Cargo.toml index 4a5dad7e..28795e9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "nih_plug_derive", "nih_plug_egui", "nih_plug_iced", + "nih_plug_vizia", "nih_plug_xtask", "cargo_nih_plug", diff --git a/README.md b/README.md index 2d6af73b..4d22a0cf 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,8 @@ for download links. `true`. - Comes with adapters for popular Rust GUI frameworks as well as some basic widgets for them that integrate with NIH-plug's parameter system. Currently - there's support for [egui](nih_plug_egui) and [iced](nih_plug_iced). + there's support for [egui](nih_plug_egui), [iced](nih_plug_iced) and + [VIZIA](nih_plug_vizia). - Basic note/MIDI support. MIDI CC handling and note output is currently not implemented. Let me know if you need this. - A plugin bundler accessible through the diff --git a/nih_plug_egui/README.md b/nih_plug_egui/README.md index e747f385..4304fa86 100644 --- a/nih_plug_egui/README.md +++ b/nih_plug_egui/README.md @@ -4,4 +4,5 @@ This provides an adapter to create [egui](https://github.com/emilk/egui) based GUIs with NIH-plug through [egui-baseview](https://github.com/BillyDM/egui-baseview). -Consider using [`nih_plug_iced`](../nih_plug_iced) instead. +Consider using [`nih_plug_iced`](../nih_plug_iced) instead or +[`nih_plug_vizia`](../nih_plug_vizia). diff --git a/nih_plug_vizia/Cargo.toml b/nih_plug_vizia/Cargo.toml new file mode 100644 index 00000000..49308929 --- /dev/null +++ b/nih_plug_vizia/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "nih_plug_vizia" +version = "0.0.0" +edition = "2021" +authors = ["Robbert van der Helm "] +license = "ISC" + +description = "An adapter to use VIZIA GUIs with NIH-plug" + +[dependencies] +nih_plug = { path = ".." } +nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" } + +baseview = { git = "https://github.com/robbert-vdh/baseview.git", branch = "feature/mouse-event-modifiers" } +crossbeam = "0.8" +# This fork contains changed for better keyboard modifier handling and DPI +# scaling +vizia = { git = "https://github.com/robbert-vdh/vizia.git", branch = "feature/baseview-modifiers", default_features = false, features = ["baseview", "clipboard"] } diff --git a/nih_plug_vizia/README.md b/nih_plug_vizia/README.md new file mode 100644 index 00000000..e5066d7a --- /dev/null +++ b/nih_plug_vizia/README.md @@ -0,0 +1,4 @@ +# NIH-plug: VIZIA support + +This provides an adapter to create [VIZIA](https://github.com/geom3trik/VIZIA) +based GUIs with NIH-plug. diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs new file mode 100644 index 00000000..62ef33ae --- /dev/null +++ b/nih_plug_vizia/src/lib.rs @@ -0,0 +1,138 @@ +//! [VIZIA](https://github.com/vizia/vizia) editor support for NIH plug. + +use baseview::{WindowHandle, WindowScalePolicy}; +use crossbeam::atomic::AtomicCell; +use nih_plug::prelude::{Editor, GuiContext, ParamSetter, ParentWindowHandle}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use vizia::{Application, Context, WindowDescription}; + +// Re-export for convenience +pub use vizia; + +// TODO: Add exports for the nih_plug_assets fonts + +/// Create an [`Editor`] instance using a [`vizia`][::vizia] GUI. The [`ViziaState`] passed to this +/// function contains the GUI's intitial size, and this is kept in sync whenever the GUI gets +/// resized. You can also use this to know if the GUI is open, so you can avoid performing +/// potentially expensive calculations while the GUI is not open. If you want this size to be +/// persisted when restoring a plugin instance, then you can store it in a `#[persist = "key"]` +/// field on your parameters struct. +/// +/// See [VIZIA](https://github.com/vizia/vizia)'s repository for examples on how to use this. +pub fn create_vizia_editor(vizia_state: Arc, app: F) -> Option> +where + F: Fn(&mut Context, &ParamSetter) + 'static + Send + Sync, +{ + Some(Box::new(ViziaEditor { + vizia_state, + app: Arc::new(app), + + scaling_factor: AtomicCell::new(None), + })) +} + +// TODO: Once we add resizing, we may want to be able to remember the GUI size. In that case we need +// to make this serializable (only restoring the size of course) so it can be persisted. +pub struct ViziaState { + size: AtomicCell<(u32, u32)>, + open: AtomicBool, +} + +impl ViziaState { + /// Initialize the GUI's state. This value can be passed to [`create_vizia_editor()`]. The window + /// size is in logical pixels, so before it is multiplied by the DPI scaling factor. + pub fn from_size(width: u32, height: u32) -> Arc { + Arc::new(ViziaState { + size: AtomicCell::new((width, height)), + open: AtomicBool::new(false), + }) + } + + /// Return a `(width, height)` pair for the current size of the GUI in logical pixels. + pub fn size(&self) -> (u32, u32) { + self.size.load() + } + + /// Whether the GUI is currently visible. + // Called `is_open()` instead of `open()` to avoid the ambiguity. + pub fn is_open(&self) -> bool { + self.open.load(Ordering::Acquire) + } +} + +/// An [`Editor`] implementation that calls an vizia draw loop. +struct ViziaEditor { + vizia_state: Arc, + /// The user's app function. + app: Arc, + + /// The scaling factor reported by the host, if any. On macOS this will never be set and we + /// should use the system scaling factor instead. + scaling_factor: AtomicCell>, +} + +impl Editor for ViziaEditor { + fn spawn( + &self, + parent: ParentWindowHandle, + context: Arc, + ) -> Box { + let app = self.app.clone(); + + let (unscaled_width, unscaled_height) = self.vizia_state.size(); + let scaling_factor = self.scaling_factor.load(); + let window_description = + WindowDescription::new().with_inner_size(unscaled_width, unscaled_height); + + let window = Application::new(window_description, move |cx| { + let setter = ParamSetter::new(context.as_ref()); + + app(cx, &setter) + }) + .with_scale_policy( + scaling_factor + .map(|factor| WindowScalePolicy::ScaleFactor(factor as f64)) + .unwrap_or(WindowScalePolicy::SystemScaleFactor), + ) + .open_parented(&parent); + + self.vizia_state.open.store(true, Ordering::Release); + Box::new(ViziaEditorHandle { + vizia_state: self.vizia_state.clone(), + window, + }) + } + + fn size(&self) -> (u32, u32) { + self.vizia_state.size() + } + + fn set_scale_factor(&self, factor: f32) -> bool { + self.scaling_factor.store(Some(factor)); + true + } + + fn param_values_changed(&self) { + // TODO: Update the GUI when this happens + } +} + +/// The window handle used for [`ViziaEditor`]. +struct ViziaEditorHandle { + vizia_state: Arc, + window: WindowHandle, +} + +/// The window handle enum stored within 'WindowHandle' contains raw pointers. Is there a way around +/// having this requirement? +unsafe impl Send for ViziaEditorHandle {} +unsafe impl Sync for ViziaEditorHandle {} + +impl Drop for ViziaEditorHandle { + fn drop(&mut self) { + self.vizia_state.open.store(false, Ordering::Release); + // XXX: This should automatically happen when the handle gets dropped, but apparently not + self.window.close(); + } +}