diff --git a/Cargo.lock b/Cargo.lock index 18f50af62..89cd73d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,24 @@ # 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 = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aho-corasick" version = "0.7.18" @@ -11,6 +29,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + +[[package]] +name = "android_glue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" + [[package]] name = "anyhow" version = "1.0.57" @@ -35,6 +65,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "bstr" version = "0.2.17" @@ -46,18 +82,46 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "bumpalo" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + [[package]] name = "bytecount" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e" +[[package]] +name = "bytemuck" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "bytes" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "calloop" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf2eec61efe56aa1e813f5126959296933cf0700030e4314786c48779a66ab82" +dependencies = [ + "log", + "nix", +] + [[package]] name = "cassowary" version = "0.3.0" @@ -70,19 +134,34 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + [[package]] name = "chardetng" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14b8f0b65b7b08ae3c8187e8d77174de20cb6777864c6b832d8ad365999cf1ea" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "encoding_rs", "memchr", ] @@ -110,6 +189,53 @@ dependencies = [ "winapi", ] +[[package]] +name = "cocoa" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" +dependencies = [ + "bitflags", + "block", + "cocoa-foundation", + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" +dependencies = [ + "bitflags", + "block", + "core-foundation 0.9.3", + "core-graphics-types", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen", +] + [[package]] name = "content_inspector" version = "0.2.4" @@ -119,13 +245,104 @@ dependencies = [ "memchr", ] +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys 0.7.0", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys 0.8.3", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core-graphics" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" +dependencies = [ + "bitflags", + "core-foundation 0.7.0", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation 0.9.3", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation 0.9.3", + "foreign-types", + "libc", +] + +[[package]] +name = "core-video-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" +dependencies = [ + "cfg-if 0.1.10", + "core-foundation-sys 0.7.0", + "core-graphics 0.19.2", + "libc", + "objc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-utils" 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", ] @@ -140,7 +357,7 @@ dependencies = [ "futures-core", "libc", "mio", - "parking_lot", + "parking_lot 0.12.0", "signal-hook", "signal-hook-mio", "winapi", @@ -155,13 +372,63 @@ dependencies = [ "winapi", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + +[[package]] +name = "darling" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d720b8683f8dd83c65155f0530560cba68cd2bf395f6513a483caee57ff7f4" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a340f241d2ceed1deb47ae36c4144b2707ec7dd0b649f894cb39bb595986324" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c41b3b7352feb3211a0d743dc5700a4e3b60f51bd2b368892d1e0f9a95f44b" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deflate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f" +dependencies = [ + "adler32", +] + [[package]] name = "dirs-next" 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", ] @@ -176,6 +443,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dlib" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" +dependencies = [ + "libloading", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + [[package]] name = "either" version = "1.6.1" @@ -188,7 +476,7 @@ version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -216,11 +504,35 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "016b04fd1e94fb833d432634245c9bb61cf1c7409668a0e7d4c3ab00c5172dec" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-next", "thiserror", ] +[[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", + "glutin", + "image", + "imgref", + "lru", + "ouroboros", + "rgb", + "rustybuzz", + "ttf-parser", + "unicode-bidi", + "unicode-segmentation", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "fern" version = "0.6.1" @@ -236,6 +548,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.0.1" @@ -291,17 +618,37 @@ dependencies = [ "thread_local", ] +[[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.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi 0.10.2+wasi-snapshot-preview1", ] +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + [[package]] name = "globset" version = "0.4.8" @@ -315,6 +662,90 @@ dependencies = [ "regex", ] +[[package]] +name = "glow" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8bd5877156a19b8ac83a29b2306fe20537429d318f3ff0a1a2119f8d9c61919" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00ea9dbe544bc8a657c4c4a798c2d16cd01b549820e47657297549d28371f6d2" +dependencies = [ + "android_glue", + "cgl", + "cocoa", + "core-foundation 0.9.3", + "glutin_egl_sys", + "glutin_emscripten_sys", + "glutin_gles2_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "lazy_static", + "libloading", + "log", + "objc", + "osmesa-sys", + "parking_lot 0.11.2", + "wayland-client", + "wayland-egl", + "winapi", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211" +dependencies = [ + "gl_generator", + "winapi", +] + +[[package]] +name = "glutin_emscripten_sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" + +[[package]] +name = "glutin_gles2_sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103" +dependencies = [ + "gl_generator", + "objc", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696" +dependencies = [ + "gl_generator", +] + [[package]] name = "grep-matcher" version = "0.1.5" @@ -376,7 +807,7 @@ dependencies = [ "smartstring", "toml", "tree-sitter", - "unicode-general-category", + "unicode-general-category 0.5.1", "unicode-segmentation", "unicode-width", ] @@ -480,6 +911,19 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "helix-ui" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "femtovg", + "glutin", + "image", + "instant", + "resource", + "winit", +] + [[package]] name = "helix-view" version = "0.6.0" @@ -516,6 +960,12 @@ dependencies = [ "libc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.2.3" @@ -545,12 +995,67 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "image" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db207d030ae38f1eb6f240d5a1c1c88ff422aa005d10f8c6c6fc5e75286ab30e" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "jpeg-decoder", + "num-iter", + "num-rational", + "num-traits", + "png", +] + +[[package]] +name = "imgref" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d0c0db6c932f8262e0ed8909f2e7f8c0e9b1cfb4da884267ce09a10be54365" + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "itoa" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jpeg-decoder" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "105fb082d64e2100074587f59a74231f771750c664af903f1f9f76c9dedfc6f1" + +[[package]] +name = "js-sys" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "jsonrpc-core" version = "18.0.0" @@ -564,6 +1069,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "lazy_static" version = "1.4.0" @@ -582,7 +1093,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", ] @@ -602,9 +1113,15 @@ version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] +[[package]] +name = "lru" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb87f3080f6d1d69e8c564c0fcfde1d7aa8cc451ce40cae89479111f03bc0eb" + [[package]] name = "lsp-types" version = "0.93.0" @@ -618,6 +1135,15 @@ dependencies = [ "url", ] +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "matches" version = "0.1.9" @@ -639,6 +1165,30 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[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.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.2" @@ -654,57 +1204,229 @@ dependencies = [ ] [[package]] -name = "miow" -version = "0.3.7" +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "ndk" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d868f654c72e75f8687572699cdabe755f03effbb62542768e995d5b8d699d" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-context" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5cc68637e21fe8f077f6a1c9e0b9ca495bb74895226b476310f613325884" + +[[package]] +name = "ndk-glue" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1c68f70683c5fc9a747a383744206cd371741b2f0b31781ab6770487ec572e2" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-macro", + "ndk-sys", +] + +[[package]] +name = "ndk-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" +dependencies = [ + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" + +[[package]] +name = "nix" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" +dependencies = [ + "bitflags", + "cc", + "cfg-if 1.0.0", + "libc", + "memoffset", +] + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "ntapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +dependencies = [ + "winapi", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "objc" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ - "winapi", + "malloc_buf", ] [[package]] -name = "ntapi" -version = "0.3.7" +name = "once_cell" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] -name = "num-integer" -version = "0.1.44" +name = "osmesa-sys" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" dependencies = [ - "autocfg", - "num-traits", + "shared_library", ] [[package]] -name = "num-traits" -version = "0.2.14" +name = "ouroboros" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "71643f290d126e18ac2598876d01e1d57aed164afc78fdb6e2a0c6589a1f6662" dependencies = [ - "autocfg", + "aliasable", + "ouroboros_macro", + "stable_deref_trait", ] [[package]] -name = "num_cpus" -version = "1.13.1" +name = "ouroboros_macro" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "ed9a247206016d424fe8497bc611e510887af5c261fbbf977877c4bb55ca4d82" dependencies = [ - "hermit-abi", - "libc", + "Inflector", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "once_cell" -version = "1.10.0" +name = "parking_lot" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.5", +] [[package]] name = "parking_lot" @@ -713,7 +1435,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.2", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", ] [[package]] @@ -722,7 +1458,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", @@ -747,6 +1483,58 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" + +[[package]] +name = "png" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba" +dependencies = [ + "bitflags", + "crc32fast", + "deflate", + "miniz_oxide", +] + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[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-macro2" version = "1.0.36" @@ -803,6 +1591,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "raw-window-handle" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba75eee94a9d5273a68c9e1e105d9cffe1ef700532325788389e5a83e2522b7" +dependencies = [ + "cty", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -846,12 +1643,27 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +[[package]] +name = "resource" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a7f6703c396037a02da99195e49138c37f3cc5146cb95f2f7d26debc0c5622" + [[package]] name = "retain_mut" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c31b5c4033f8fdde8700e4657be2c497e7288f01515be52168c631e2e4d4086" +[[package]] +name = "rgb" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e74fdc210d8f24a7dbfedc13b04ba5764f5232754ccebfdf5fff1bad791ccbc6" +dependencies = [ + "bytemuck", +] + [[package]] name = "ropey" version = "1.4.1" @@ -862,6 +1674,22 @@ dependencies = [ "str_indices", ] +[[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", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-general-category 0.4.0", + "unicode-script", +] + [[package]] name = "ryu" version = "1.0.9" @@ -877,6 +1705,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "1.1.0" @@ -925,6 +1759,16 @@ dependencies = [ "syn", ] +[[package]] +name = "shared_library" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +dependencies = [ + "lazy_static", + "libc", +] + [[package]] name = "signal-hook" version = "0.3.13" @@ -1005,6 +1849,25 @@ dependencies = [ "version_check", ] +[[package]] +name = "smithay-client-toolkit" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1325f292209cee78d5035530932422a30aa4c8fda1a16593ac083c1de211e68a" +dependencies = [ + "bitflags", + "calloop", + "dlib", + "lazy_static", + "log", + "memmap2", + "nix", + "pkg-config", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + [[package]] name = "socket2" version = "0.4.4" @@ -1015,6 +1878,12 @@ dependencies = [ "winapi", ] +[[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" @@ -1033,6 +1902,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adfad63a1b47951101cd667a85b2959a62910cf03f814fff25df89c460b873f8" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "1.0.90" @@ -1109,7 +1984,7 @@ dependencies = [ "mio", "num_cpus", "once_cell", - "parking_lot", + "parking_lot 0.12.0", "pin-project-lite", "signal-hook-registry", "socket2", @@ -1158,6 +2033,12 @@ dependencies = [ "regex", ] +[[package]] +name = "ttf-parser" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c74c96594835e10fa545e2a51e8709f30b173a092bfd6036ef2cec53376244f3" + [[package]] name = "unicase" version = "2.6.0" @@ -1173,6 +2054,24 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +[[package]] +name = "unicode-bidi-mirroring" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d12260fb92d52f9008be7e4bca09f584780eb2266dc8fecc6a192bec561694" + +[[package]] +name = "unicode-ccc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1" + +[[package]] +name = "unicode-general-category" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07547e3ee45e28326cc23faac56d44f58f16ab23e413db526debce3b0bfd2742" + [[package]] name = "unicode-general-category" version = "0.5.1" @@ -1188,6 +2087,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-script" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dd944fd05f2f0b5c674917aea8a4df6af84f2d8de3fe8d988b95d28fb8fb09" + [[package]] name = "unicode-segmentation" version = "1.9.0" @@ -1248,6 +2153,153 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" + +[[package]] +name = "wayland-client" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91223460e73257f697d9e23d401279123d36039a3f7a449e983f123292d4458f" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix", + "scoped-tls", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f6e5e340d7c13490eca867898c4cec5af56c27a5ffe5c80c6fc4708e22d33e" +dependencies = [ + "nix", + "once_cell", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-cursor" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c52758f13d5e7861fc83d942d3d99bf270c83269575e52ac29e5b73cb956a6bd" +dependencies = [ + "nix", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-egl" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83281d69ee162b59031c666385e93bde4039ec553b90c4191cdb128ceea29a3a" +dependencies = [ + "wayland-client", + "wayland-sys", +] + +[[package]] +name = "wayland-protocols" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60147ae23303402e41fe034f74fb2c35ad0780ee88a1c40ac09a3be1e7465741" +dependencies = [ + "bitflags", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a1ed3143f7a143187156a2ab52742e89dac33245ba505c17224df48939f9e0" +dependencies = [ + "proc-macro2", + "quote", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.29.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4" +dependencies = [ + "dlib", + "lazy_static", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "which" version = "4.2.5" @@ -1333,6 +2385,65 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" +[[package]] +name = "winit" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b43cc931d58b99461188607efd7acb2a093e65fc621f54cad78517a6063e73a" +dependencies = [ + "bitflags", + "cocoa", + "core-foundation 0.9.3", + "core-graphics 0.22.3", + "core-video-sys", + "dispatch", + "instant", + "lazy_static", + "libc", + "log", + "mio", + "ndk", + "ndk-glue", + "ndk-sys", + "objc", + "parking_lot 0.11.2", + "percent-encoding", + "raw-window-handle", + "smithay-client-toolkit", + "wasm-bindgen", + "wayland-client", + "wayland-protocols", + "web-sys", + "winapi", + "x11-dl", +] + +[[package]] +name = "x11-dl" +version = "2.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea26926b4ce81a6f5d9d0f3a0bc401e5a37c6ae14a1bfaa8ff6099ca80038c59" +dependencies = [ + "lazy_static", + "libc", + "pkg-config", +] + +[[package]] +name = "xcursor" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" +dependencies = [ + "nom", +] + +[[package]] +name = "xml-rs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" + [[package]] name = "xtask" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 780811f78..a88c8bc37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "helix-view", "helix-term", "helix-tui", + "helix-ui", "helix-lsp", "helix-dap", "helix-loader", diff --git a/flake.nix b/flake.nix index 38ba9fd0c..ac7fd9433 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ }; }; - outputs = inputs@{ nixCargoIntegration, ... }: + outputs = inputs@{ nixpkgs, nixCargoIntegration, ... }: nixCargoIntegration.lib.makeOutputs { root = ./.; renameOutputs = { "helix-term" = "helix"; }; @@ -58,6 +58,7 @@ { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; } { name = "RUST_BACKTRACE"; value = "1"; } { name = "RUSTFLAGS"; value = "-C link-arg=-fuse-ld=lld -C target-cpu=native -Clink-arg=-Wl,--no-rosegment"; } + { name = "LD_LIBRARY_PATH"; value = nixpkgs.lib.makeLibraryPath (with common.pkgs; [ wayland libxkbcommon libGL ]); } ]; }; }; diff --git a/helix-ui/Cargo.toml b/helix-ui/Cargo.toml new file mode 100644 index 000000000..333195584 --- /dev/null +++ b/helix-ui/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "helix-ui" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +femtovg = "0.3.3" +winit = { version = "0.26.1", default-features = false, features = ["wayland"] } # TODO: figure out wayland-dlopen +resource = "0.5.0" +image = { version = "0.24.0", default-features = false, features = ["jpeg", "png"] } +console_error_panic_hook = "0.1.7" +glutin = "0.28.0" +instant = "0.1.12" diff --git a/helix-ui/assets/entypo.ttf b/helix-ui/assets/entypo.ttf new file mode 100644 index 000000000..fc305d2a9 Binary files /dev/null and b/helix-ui/assets/entypo.ttf differ diff --git a/helix-ui/assets/fonts/Inter Variable/Inter.ttf b/helix-ui/assets/fonts/Inter Variable/Inter.ttf new file mode 100644 index 000000000..1cb674b74 Binary files /dev/null and b/helix-ui/assets/fonts/Inter Variable/Inter.ttf differ diff --git a/helix-ui/assets/fonts/Inter Variable/Single axis/Inter-italic.ttf b/helix-ui/assets/fonts/Inter Variable/Single axis/Inter-italic.ttf new file mode 100644 index 000000000..5b4ac27c0 Binary files /dev/null and b/helix-ui/assets/fonts/Inter Variable/Single axis/Inter-italic.ttf differ diff --git a/helix-ui/assets/fonts/Inter Variable/Single axis/Inter-roman.ttf b/helix-ui/assets/fonts/Inter Variable/Single axis/Inter-roman.ttf new file mode 100644 index 000000000..18f550dbf Binary files /dev/null and b/helix-ui/assets/fonts/Inter Variable/Single axis/Inter-roman.ttf differ diff --git a/helix-ui/assets/fonts/LICENSE.txt b/helix-ui/assets/fonts/LICENSE.txt new file mode 100644 index 000000000..ff80f8c61 --- /dev/null +++ b/helix-ui/assets/fonts/LICENSE.txt @@ -0,0 +1,94 @@ +Copyright (c) 2016-2020 The Inter Project Authors. +"Inter" is trademark of Rasmus Andersson. +https://github.com/rsms/inter + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION AND CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/helix-ui/src/main.rs b/helix-ui/src/main.rs new file mode 100644 index 000000000..e5945dca3 --- /dev/null +++ b/helix-ui/src/main.rs @@ -0,0 +1,965 @@ +use resource::resource; + +use instant::Instant; +use winit::event::{ElementState, Event, KeyboardInput, MouseButton, VirtualKeyCode, WindowEvent}; +use winit::event_loop::{ControlFlow, EventLoop}; +use winit::window::WindowBuilder; +//use glutin::{GlRequest, Api}; + +use femtovg::{ + //CompositeOperation, + renderer::OpenGl, + Align, + Baseline, + Canvas, + Color, + FontId, + ImageFlags, + Paint, + Path, + Renderer, + Solidity, +}; + +// mezzopiano +// — +// 03/13/2022 +// I'm also assuming that there's some logic bugs in the demo application, which wasn't built with this in mind; I have a much simpler application that I'm happy to show if that would be helpful (would need to extract an example). As a rough solution, I apply the following transformation on Winit's WindowEvent::ScaleFactorChanged: + +// /* ... in an application struct/impl ... */ +// pub fn rescale( +// &mut self, +// new_size: winit::dpi::PhysicalSize, +// new_scale_factor: f64, +// ) { +// // Update translation +// // (TODO: This is a guestimate and not well-tested; +// // the size updates might turn out ot be completely unnecessary) +// let shift = self.size.height as f32 - new_size.height as f32; +// self.canvas.translate(0.0, -shift); + +// // Update properties +// self.size = new_size; +// self.scale_factor = new_scale_factor; +// self.canvas.set_size( +// self.size.width, +// self.size.height, +// self.scale_factor as f32, +// ) +// } + +// With this, the canvas position and scale is preserved while the window is moved across screens, but as I'd like to apply further translations and keeping track of everything is getting very hard 😅 . I'm wondering if I'm making a mistake somewhere, or if there might be some way to do this in femto. + +pub fn quantize(a: f32, d: f32) -> f32 { + (a / d + 0.5).trunc() * d +} + +struct Fonts { + regular: FontId, + bold: FontId, + icons: FontId, +} + +fn main() { + // This provides better error messages in debug mode. + // It's disabled in release mode so it doesn't bloat up the file size. + #[cfg(all(debug_assertions, target_arch = "wasm32"))] + console_error_panic_hook::set_once(); + + let el = EventLoop::new(); + + #[cfg(not(target_arch = "wasm32"))] + let (renderer, windowed_context) = { + use glutin::ContextBuilder; + + let wb = WindowBuilder::new() + .with_inner_size(winit::dpi::LogicalSize::::new(1000., 600.)) + .with_title("femtovg demo"); + + //let windowed_context = ContextBuilder::new().with_gl(GlRequest::Specific(Api::OpenGlEs, (2, 0))).with_vsync(false).build_windowed(wb, &el).unwrap(); + //let windowed_context = ContextBuilder::new().with_vsync(false).with_multisampling(8).build_windowed(wb, &el).unwrap(); + let windowed_context = ContextBuilder::new() + .with_vsync(true) // TODO: set to true? + .build_windowed(wb, &el) + .unwrap(); + let windowed_context = unsafe { windowed_context.make_current().unwrap() }; + + let renderer = + OpenGl::new_from_glutin_context(&windowed_context).expect("Cannot create renderer"); + + (renderer, windowed_context) + }; + + #[cfg(target_arch = "wasm32")] + let (renderer, window) = { + use wasm_bindgen::JsCast; + + let canvas = web_sys::window() + .unwrap() + .document() + .unwrap() + .get_element_by_id("canvas") + .unwrap() + .dyn_into::() + .unwrap(); + + use winit::platform::web::WindowBuilderExtWebSys; + + let renderer = OpenGl::new_from_html_canvas(&canvas).expect("Cannot create renderer"); + + let window = WindowBuilder::new() + .with_canvas(Some(canvas)) + .build(&el) + .unwrap(); + + (renderer, window) + }; + + let mut canvas = Canvas::new(renderer).expect("Cannot create canvas"); + + // TODO: better femtovg support for variable fonts + let fonts = Fonts { + regular: canvas + .add_font_mem(&resource!("assets/fonts/Inter\ Variable/Inter.ttf")) + .expect("Cannot add font"), + bold: canvas + .add_font_mem(&resource!("assets/fonts/Inter Variable/Inter.ttf")) + .expect("Cannot add font"), + icons: canvas + .add_font_mem(&resource!("assets/entypo.ttf")) + .expect("Cannot add font"), + }; + + //canvas.add_font("/usr/share/fonts/noto/NotoSansArabic-Regular.ttf").expect("Cannot add font"); + + //let image_id = canvas.create_image_file("assets/RoomRender.jpg", ImageFlags::FLIP_Y).expect("Cannot create image"); + //canvas.blur_image(image_id, 10, 1050, 710, 200, 200); + + //let image_id = canvas.load_image_file("assets/RoomRender.jpg", ImageFlags::FLIP_Y).expect("Cannot create image"); + + // let images = vec![ + // canvas + // .load_image_mem(&resource!("assets/images/image1.jpg"), ImageFlags::empty()) + // .unwrap(), + // canvas + // .load_image_mem(&resource!("assets/images/image2.jpg"), ImageFlags::empty()) + // .unwrap(), + // ]; + + let mut screenshot_image_id = None; + + let start = Instant::now(); + let mut prevt = start; + + let mut mousex = 0.0; + let mut mousey = 0.0; + let mut dragging = false; + + let mut perf = PerfGraph::new(); + + el.run(move |event, _, control_flow| { + #[cfg(not(target_arch = "wasm32"))] + let window = windowed_context.window(); + + *control_flow = ControlFlow::Poll; + + match event { + Event::LoopDestroyed => return, + Event::WindowEvent { ref event, .. } => match event { + #[cfg(not(target_arch = "wasm32"))] + WindowEvent::Resized(physical_size) => { + println!("resized!"); + // TODO: use DPI here? + windowed_context.resize(*physical_size); + } + WindowEvent::CursorMoved { + device_id: _, + position, + .. + } => { + if dragging { + let p0 = canvas + .transform() + .inversed() + .transform_point(mousex, mousey); + let p1 = canvas + .transform() + .inversed() + .transform_point(position.x as f32, position.y as f32); + + canvas.translate(p1.0 - p0.0, p1.1 - p0.1); + } + + mousex = position.x as f32; + mousey = position.y as f32; + } + WindowEvent::MouseWheel { + device_id: _, + delta, + .. + } => match delta { + winit::event::MouseScrollDelta::LineDelta(_, y) => { + let pt = canvas + .transform() + .inversed() + .transform_point(mousex, mousey); + canvas.translate(pt.0, pt.1); + canvas.scale(1.0 + (y / 10.0), 1.0 + (y / 10.0)); + canvas.translate(-pt.0, -pt.1); + } + + winit::event::MouseScrollDelta::PixelDelta(pos) => { + let y = pos.y as f32; + let pt = canvas + .transform() + .inversed() + .transform_point(mousex, mousey); + let rate = 2000.0; + canvas.translate(pt.0, pt.1); + canvas.scale(1.0 + (y / rate), 1.0 + (y / rate)); + canvas.translate(-pt.0, -pt.1); + } + }, + WindowEvent::MouseInput { + button: MouseButton::Left, + state, + .. + } => match state { + ElementState::Pressed => dragging = true, + ElementState::Released => dragging = false, + }, + WindowEvent::KeyboardInput { + input: + KeyboardInput { + virtual_keycode: Some(VirtualKeyCode::S), + state: ElementState::Pressed, + .. + }, + .. + } => { + if let Some(screenshot_image_id) = screenshot_image_id { + canvas.delete_image(screenshot_image_id); + } + + if let Ok(image) = canvas.screenshot() { + screenshot_image_id = Some( + canvas + .create_image(image.as_ref(), ImageFlags::empty()) + .unwrap(), + ); + } + } + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + _ => (), + }, + Event::RedrawRequested(_) => { + let now = Instant::now(); + let dt = (now - prevt).as_secs_f32(); + prevt = now; + + perf.update(dt); + + let dpi_factor = window.scale_factor(); + // println!("DPI {}", dpi_factor); + // let dpi_factor = 0.5f64; + let size = window.inner_size(); + // let size: winit::dpi::LogicalSize = window.inner_size().to_logical(dpi_factor); // TODO: adjust for dpi + // window.set_inner_size(size); + // let size = window.inner_size(); + + // let t = start.elapsed().as_secs_f32(); + + canvas.set_size(size.width as u32, size.height as u32, dpi_factor as f32); + canvas.clear_rect( + 0, + 0, + size.width as u32, + size.height as u32, + Color::rgbf(0.3, 0.3, 0.32), + ); + + // let height = size.height as f32; + // let width = size.width as f32; + + let winit::dpi::LogicalSize { width, height: _ } = + size.to_logical::(dpi_factor); + + let pt = canvas + .transform() + .inversed() + .transform_point(mousex, mousey); + let rel_mousex = pt.0; + let rel_mousey = pt.1; + + draw_paragraph( + &mut canvas, + fonts.regular, + width - 450.0, + 50.0, + 150.0, + 100.0, + rel_mousex, + rel_mousey, + ); + + draw_window( + &mut canvas, + &fonts, + "Widgets `n Stuff", + 50.0, + 50.0, + 300.0, + 400.0, + ); + + let x = 60.0; + let mut y = 95.0; + + draw_search_box(&mut canvas, &fonts, "Search", x, y, 280.0, 25.0); + y += 40.0; + draw_drop_down(&mut canvas, &fonts, "Effects", 60.0, 135.0, 280.0, 28.0); + y += 45.0; + + draw_label(&mut canvas, &fonts, "Login", x, y, 280.0, 20.0); + y += 25.0; + draw_edit_box(&mut canvas, &fonts, "Email", x, y, 280.0, 28.0); + y += 35.0; + draw_edit_box(&mut canvas, &fonts, "Password", x, y, 280.0, 28.0); + y += 38.0; + draw_check_box(&mut canvas, &fonts, "Remember me", x, y, 140.0, 28.0); + draw_button( + &mut canvas, + &fonts, + Some("\u{E740}"), + "Sign in", + x + 138.0, + y, + 140.0, + 28.0, + Color::rgba(0, 96, 128, 255), + ); + y += 45.0; + + // Slider + draw_label(&mut canvas, &fonts, "Diameter", x, y, 280.0, 20.0); + y += 25.0; + draw_edit_box_num( + &mut canvas, + &fonts, + "123.00", + "px", + x + 180.0, + y, + 100.0, + 28.0, + ); + y += 55.0; + + draw_button( + &mut canvas, + &fonts, + Some("\u{E729}"), + "Delete", + x, + y, + 160.0, + 28.0, + Color::rgba(128, 16, 8, 255), + ); + draw_button( + &mut canvas, + &fonts, + None, + "Cancel", + x + 170.0, + y, + 110.0, + 28.0, + Color::rgba(0, 0, 0, 0), + ); + + /* + draw_spinner(&mut canvas, 15.0, 285.0, 10.0, t); + */ + + if let Some(image_id) = screenshot_image_id { + let x = size.width as f32 - 512.0; + let y = size.height as f32 - 512.0; + + let paint = Paint::image(image_id, x, y, 512.0, 512.0, 0.0, 1.0); + + let mut path = Path::new(); + path.rect(x, y, 512.0, 512.0); + canvas.fill_path(&mut path, paint); + canvas.stroke_path(&mut path, Paint::color(Color::hex("454545"))); + } + + // if true { + // let paint = Paint::image(image_id, size.width as f32, 15.0, 1920.0, 1080.0, 0.0, 1.0); + // let mut path = Path::new(); + // path.rect(size.width as f32, 15.0, 1920.0, 1080.0); + // canvas.fill_path(&mut path, paint); + // } + + canvas.save_with(|canvas| { + canvas.reset(); + perf.render(canvas, 5.0, 5.0); + }); + + //canvas.restore(); + + canvas.flush(); + #[cfg(not(target_arch = "wasm32"))] + windowed_context.swap_buffers().unwrap(); + } + Event::MainEventsCleared => { + //scroll = 1.0; + window.request_redraw() + } + _ => (), + } + }); +} + +fn draw_paragraph( + canvas: &mut Canvas, + font: FontId, + x: f32, + y: f32, + width: f32, + _height: f32, + mx: f32, + my: f32, +) { + let text = "This is longer chunk of text.\n\nWould have used lorem ipsum but she was busy jumping over the lazy dog with the fox and all the men who came to the aid of the party.🎉"; + + canvas.save(); + + let mut paint = Paint::color(Color::rgba(255, 255, 255, 255)); + paint.set_font_size(14.0); + paint.set_font(&[font]); + paint.set_text_align(Align::Left); + paint.set_text_baseline(Baseline::Top); + + let mut gutter_y = 0.0; + let mut gutter = 0; + let mut y = y; + let mut px; + let mut caret_x; + + let lines = canvas + .break_text_vec(width, text, paint) + .expect("Cannot break text"); + + for (line_num, line_range) in lines.into_iter().enumerate() { + if let Ok(res) = canvas.fill_text(x, y, &text[line_range], paint) { + let hit = mx > x && mx < (x + width) && my >= y && my < (y + res.height()); + + if hit { + caret_x = if mx < x + res.width() / 2.0 { + x + } else { + x + res.width() + }; + px = x; + + for glyph in &res.glyphs { + let x0 = glyph.x; + let x1 = x0 + glyph.width; + let gx = x0 * 0.3 + x1 * 0.7; + + if mx >= px && mx < gx { + caret_x = glyph.x; + } + + px = gx; + } + + let mut path = Path::new(); + path.rect(caret_x, y, 1.0, res.height()); + canvas.fill_path(&mut path, Paint::color(Color::rgba(255, 192, 0, 255))); + + gutter = line_num + 1; + + gutter_y = y + 14.0 / 2.0; + } + + y += res.height(); + } + } + + if gutter > 0 { + let mut paint = Paint::color(Color::rgba(255, 192, 0, 255)); + paint.set_font_size(12.0); + paint.set_font(&[font]); + paint.set_text_align(Align::Right); + paint.set_text_baseline(Baseline::Middle); + + let text = format!("{}", gutter); + + if let Ok(res) = canvas.measure_text(x - 10.0, gutter_y, &text, paint) { + let mut path = Path::new(); + path.rounded_rect( + res.x - 4.0, + res.y - 2.0, + res.width() + 8.0, + res.height() + 4.0, + (res.height() + 4.0) / 2.0 - 1.0, + ); + canvas.fill_path(&mut path, paint); + + paint.set_color(Color::rgba(32, 32, 32, 255)); + let _ = canvas.fill_text(x - 10.0, gutter_y, &text, paint); + } + } + + // let mut start = 0; + + // while start < text.len() { + // let substr = &text[start..]; + + // if let Ok(index) = canvas.break_text(width, substr, paint) { + // if let Ok(res) = canvas.fill_text(x, y, &substr[0..index], paint) { + // y += res.height; + // } + + // start += &substr[0..index].len(); + // } else { + // break; + // } + // } + + canvas.restore(); +} + +fn draw_window( + canvas: &mut Canvas, + fonts: &Fonts, + title: &str, + x: f32, + y: f32, + w: f32, + h: f32, +) { + let corner_radius = 3.0; + + canvas.save(); + + //canvas.global_composite_operation(CompositeOperation::Lighter); + + // Window + let mut path = Path::new(); + path.rounded_rect(x, y, w, h, corner_radius); + canvas.fill_path(&mut path, Paint::color(Color::rgba(28, 30, 34, 192))); + + // Drop shadow + let shadow_paint = Paint::box_gradient( + x, + y + 2.0, + w, + h, + corner_radius * 2.0, + 10.0, + Color::rgba(0, 0, 0, 128), + Color::rgba(0, 0, 0, 0), + ); + let mut path = Path::new(); + path.rect(x - 10.0, y - 10.0, w + 20.0, h + 30.0); + path.rounded_rect(x, y, w, h, corner_radius); + path.solidity(Solidity::Hole); + canvas.fill_path(&mut path, shadow_paint); + + // Header + let header_paint = Paint::linear_gradient( + x, + y, + x, + y + 15.0, + Color::rgba(255, 255, 255, 8), + Color::rgba(0, 0, 0, 16), + ); + let mut path = Path::new(); + path.rounded_rect(x + 1.0, y + 1.0, w - 2.0, 30.0, corner_radius - 1.0); + canvas.fill_path(&mut path, header_paint); + + let mut path = Path::new(); + path.move_to(x + 0.5, y + 0.5 + 30.0); + path.line_to(x + 0.5 + w - 1.0, y + 0.5 + 30.0); + canvas.stroke_path(&mut path, Paint::color(Color::rgba(0, 0, 0, 32))); + + let mut text_paint = Paint::color(Color::rgba(0, 0, 0, 32)); + text_paint.set_font_size(16.0); + text_paint.set_font(&[fonts.bold]); + text_paint.set_text_align(Align::Center); + text_paint.set_color(Color::rgba(220, 220, 220, 160)); + + let _ = canvas.fill_text(x + (w / 2.0), y + 19.0, title, text_paint); + + // let bounds = canvas.text_bounds(x + (w / 2.0), y + 19.0, title, text_paint); + // + // let mut path = Path::new(); + // path.rect(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]); + // canvas.stroke_path(&mut path, Paint::color(Color::rgba(0, 0, 0, 255))); + + canvas.restore(); +} + +fn draw_search_box( + canvas: &mut Canvas, + fonts: &Fonts, + title: &str, + x: f32, + y: f32, + w: f32, + h: f32, +) { + let corner_radius = (h / 2.0) - 1.0; + + let bg = Paint::box_gradient( + x, + y + 1.5, + w, + h, + h / 2.0, + 5.0, + Color::rgba(0, 0, 0, 16), + Color::rgba(0, 0, 0, 92), + ); + let mut path = Path::new(); + path.rounded_rect(x, y, w, h, corner_radius); + canvas.fill_path(&mut path, bg); + + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 64)); + text_paint.set_font_size((h * 1.3).round()); + text_paint.set_font(&[fonts.icons]); + text_paint.set_text_align(Align::Center); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + h * 0.55, y + h * 0.55, "\u{1F50D}", text_paint); + + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 32)); + text_paint.set_font_size(16.0); + text_paint.set_font(&[fonts.regular]); + text_paint.set_text_align(Align::Left); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + h, y + h * 0.5, title, text_paint); + + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 32)); + text_paint.set_font_size((h * 1.3).round()); + text_paint.set_font(&[fonts.icons]); + text_paint.set_text_align(Align::Center); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + w - h * 0.55, y + h * 0.45, "\u{2716}", text_paint); +} + +fn draw_drop_down( + canvas: &mut Canvas, + fonts: &Fonts, + title: &str, + x: f32, + y: f32, + w: f32, + h: f32, +) { + let corner_radius = 4.0; + + let bg = Paint::linear_gradient( + x, + y, + x, + y + h, + Color::rgba(255, 255, 255, 16), + Color::rgba(0, 0, 0, 16), + ); + let mut path = Path::new(); + path.rounded_rect(x + 1.0, y + 1.0, w - 2.0, h - 2.0, corner_radius); + canvas.fill_path(&mut path, bg); + + let mut path = Path::new(); + path.rounded_rect(x + 0.5, y + 0.5, w - 1.0, h - 1.0, corner_radius - 0.5); + canvas.stroke_path(&mut path, Paint::color(Color::rgba(0, 0, 0, 48))); + + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 160)); + text_paint.set_font_size(16.0); + text_paint.set_font(&[fonts.regular]); + text_paint.set_text_align(Align::Left); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + h * 0.3, y + h * 0.5, title, text_paint); + + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 64)); + text_paint.set_font_size((h * 1.3).round()); + text_paint.set_font(&[fonts.icons]); + text_paint.set_text_align(Align::Center); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + w - h * 0.5, y + h * 0.45, "\u{E75E}", text_paint); +} + +fn draw_label( + canvas: &mut Canvas, + fonts: &Fonts, + title: &str, + x: f32, + y: f32, + _w: f32, + h: f32, +) { + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 128)); + text_paint.set_font_size(14.0); + text_paint.set_font(&[fonts.regular]); + text_paint.set_text_align(Align::Left); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x, y + h * 0.5, title, text_paint); +} + +fn draw_edit_box_base(canvas: &mut Canvas, x: f32, y: f32, w: f32, h: f32) { + let paint = Paint::box_gradient( + x + 1.0, + y + 2.5, + w - 2.0, + h - 2.0, + 3.0, + 4.0, + Color::rgba(255, 255, 255, 32), + Color::rgba(32, 32, 32, 32), + ); + + let mut path = Path::new(); + path.rounded_rect(x + 1.0, y + 1.0, w - 2.0, h - 2.0, 3.0); + canvas.fill_path(&mut path, paint); + + let mut path = Path::new(); + path.rounded_rect(x + 0.5, y + 0.5, w - 1.0, h - 1.0, 3.5); + canvas.stroke_path(&mut path, Paint::color(Color::rgba(0, 0, 0, 48))); +} + +fn draw_edit_box( + canvas: &mut Canvas, + fonts: &Fonts, + title: &str, + x: f32, + y: f32, + w: f32, + h: f32, +) { + draw_edit_box_base(canvas, x, y, w, h); + + let mut text_paint = Paint::color(Color::rgba(255, 255, 255, 64)); + text_paint.set_font_size(16.0); + text_paint.set_font(&[fonts.regular]); + text_paint.set_text_align(Align::Left); + text_paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + h * 0.5, y + h * 0.5, title, text_paint); +} + +fn draw_edit_box_num( + canvas: &mut Canvas, + fonts: &Fonts, + title: &str, + units: &str, + x: f32, + y: f32, + w: f32, + h: f32, +) { + draw_edit_box_base(canvas, x, y, w, h); + + let mut paint = Paint::color(Color::rgba(255, 255, 255, 64)); + paint.set_font_size(14.0); + paint.set_font(&[fonts.regular]); + paint.set_text_align(Align::Right); + paint.set_text_baseline(Baseline::Middle); + + if let Ok(layout) = canvas.measure_text(0.0, 0.0, units, paint) { + let _ = canvas.fill_text(x + w - h * 0.3, y + h * 0.5, units, paint); + + paint.set_font_size(16.0); + paint.set_color(Color::rgba(255, 255, 255, 128)); + + let _ = canvas.fill_text(x + w - layout.width() - h * 0.5, y + h * 0.5, title, paint); + } +} + +fn draw_check_box( + canvas: &mut Canvas, + fonts: &Fonts, + text: &str, + x: f32, + y: f32, + _w: f32, + h: f32, +) { + let mut paint = Paint::color(Color::rgba(255, 255, 255, 160)); + paint.set_font_size(14.0); + paint.set_font(&[fonts.regular]); + paint.set_text_baseline(Baseline::Middle); + + let _ = canvas.fill_text(x + 28.0, y + h * 0.5, text, paint); + + paint = Paint::box_gradient( + x + 1.0, + y + (h * 0.5).floor() - 9.0 + 1.0, + 18.0, + 18.0, + 3.0, + 3.0, + Color::rgba(0, 0, 0, 32), + Color::rgba(0, 0, 0, 92), + ); + let mut path = Path::new(); + path.rounded_rect(x + 1.0, y + (h * 0.5).floor() - 9.0, 18.0, 18.0, 3.0); + canvas.fill_path(&mut path, paint); + + paint = Paint::color(Color::rgba(255, 255, 255, 128)); + paint.set_font_size(36.0); + paint.set_font(&[fonts.icons]); + paint.set_text_align(Align::Center); + paint.set_text_baseline(Baseline::Middle); + let _ = canvas.fill_text(x + 9.0 + 2.0, y + h * 0.5, "\u{2713}", paint); +} + +fn draw_button( + canvas: &mut Canvas, + fonts: &Fonts, + preicon: Option<&str>, + text: &str, + x: f32, + y: f32, + w: f32, + h: f32, + color: Color, +) { + let corner_radius = 4.0; + + let a = if color.is_black() { 16 } else { 32 }; + + let bg = Paint::linear_gradient( + x, + y, + x, + y + h, + Color::rgba(255, 255, 255, a), + Color::rgba(0, 0, 0, a), + ); + + let mut path = Path::new(); + path.rounded_rect(x + 1.0, y + 1.0, w - 2.0, h - 2.0, corner_radius - 1.0); + + if !color.is_black() { + canvas.fill_path(&mut path, Paint::color(color)); + } + + canvas.fill_path(&mut path, bg); + + let mut path = Path::new(); + path.rounded_rect(x + 0.5, y + 0.5, w - 1.0, h - 1.0, corner_radius - 0.5); + canvas.stroke_path(&mut path, Paint::color(Color::rgba(0, 0, 0, 48))); + + let mut paint = Paint::color(Color::rgba(255, 255, 255, 96)); + paint.set_font_size(15.0); + paint.set_font(&[fonts.bold]); + paint.set_text_align(Align::Left); + paint.set_text_baseline(Baseline::Middle); + + let tw = if let Ok(layout) = canvas.measure_text(0.0, 0.0, text, paint) { + layout.width() + } else { + 0.0 + }; + + let mut iw = 0.0; + + if let Some(icon) = preicon { + paint.set_font(&[fonts.icons]); + paint.set_font_size(h * 1.3); + + if let Ok(layout) = canvas.measure_text(0.0, 0.0, icon, paint) { + iw = layout.width() + (h * 0.15); + } + + let _ = canvas.fill_text(x + w * 0.5 - tw * 0.5 - iw * 0.75, y + h * 0.5, icon, paint); + } + + paint.set_font_size(15.0); + paint.set_font(&[fonts.regular]); + paint.set_color(Color::rgba(0, 0, 0, 160)); + let _ = canvas.fill_text( + x + w * 0.5 - tw * 0.5 + iw * 0.25, + y + h * 0.5 - 1.0, + text, + paint, + ); + paint.set_color(Color::rgba(255, 255, 255, 160)); + let _ = canvas.fill_text(x + w * 0.5 - tw * 0.5 + iw * 0.25, y + h * 0.5, text, paint); +} + +struct PerfGraph { + history_count: usize, + values: Vec, + head: usize, +} + +impl PerfGraph { + fn new() -> Self { + Self { + history_count: 100, + values: vec![0.0; 100], + head: Default::default(), + } + } + + fn update(&mut self, frame_time: f32) { + self.head = (self.head + 1) % self.history_count; + self.values[self.head] = frame_time; + } + + fn get_average(&self) -> f32 { + self.values.iter().map(|v| *v).sum::() / self.history_count as f32 + } + + fn render(&self, canvas: &mut Canvas, x: f32, y: f32) { + let avg = self.get_average(); + + let w = 200.0; + let h = 35.0; + + let mut path = Path::new(); + path.rect(x, y, w, h); + canvas.fill_path(&mut path, Paint::color(Color::rgba(0, 0, 0, 128))); + + let mut path = Path::new(); + path.move_to(x, y + h); + + for i in 0..self.history_count { + let mut v = 1.0 / (0.00001 + self.values[(self.head + i) % self.history_count]); + if v > 80.0 { + v = 80.0; + } + let vx = x + (i as f32 / (self.history_count - 1) as f32) * w; + let vy = y + h - ((v / 80.0) * h); + path.line_to(vx, vy); + } + + path.line_to(x + w, y + h); + canvas.fill_path(&mut path, Paint::color(Color::rgba(255, 192, 0, 128))); + + let mut text_paint = Paint::color(Color::rgba(240, 240, 240, 255)); + text_paint.set_font_size(12.0); + let _ = canvas.fill_text(x + 5.0, y + 13.0, "Frame time", text_paint); + + let mut text_paint = Paint::color(Color::rgba(240, 240, 240, 255)); + text_paint.set_font_size(14.0); + text_paint.set_text_align(Align::Right); + text_paint.set_text_baseline(Baseline::Top); + let _ = canvas.fill_text(x + w - 5.0, y, &format!("{:.2} FPS", 1.0 / avg), text_paint); + + let mut text_paint = Paint::color(Color::rgba(240, 240, 240, 200)); + text_paint.set_font_size(12.0); + text_paint.set_text_align(Align::Right); + text_paint.set_text_baseline(Baseline::Alphabetic); + let _ = canvas.fill_text( + x + w - 5.0, + y + h - 5.0, + &format!("{:.2} ms", avg * 1000.0), + text_paint, + ); + } +}