From 5a78a5fa6597cb9d0c80e56de72754d826f22f8e Mon Sep 17 00:00:00 2001 From: Enrico Lumetti Date: Thu, 15 Oct 2020 23:54:10 +0200 Subject: [PATCH] code dump 3 --- Cargo.lock | 620 ++++++++++++++++++++++++----------------- Cargo.toml | 4 +- src/bin/gtk_capture.rs | 8 +- src/main.rs | 149 ++++++++-- 4 files changed, 503 insertions(+), 278 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa0ef9c..487a984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,10 +13,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" [[package]] -name = "atk" -version = "0.8.0" +name = "associative-cache" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444daefa55f229af145ea58d77efd23725024ee1f6f3102743709aa6b18c663e" +checksum = "46016233fc1bb55c23b856fe556b7db6ccd05119a0a392e04f0b3b7c79058f16" + +[[package]] +name = "atk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812b4911e210bd51b24596244523c856ca749e6223c50a7fbbba3f89ee37c426" dependencies = [ "atk-sys", "bitflags", @@ -28,14 +34,14 @@ dependencies = [ [[package]] name = "atk-sys" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e552c1776737a4c80110d06b36d099f47c727335f9aaa5d942a72b6863a8ec6f" +checksum = "f530e4af131d94cc4fa15c5c9d0348f0ef28bac64ba660b6b2a1cf2605dedfce" dependencies = [ "glib-sys", "gobject-sys", "libc", - "pkg-config", + "system-deps", ] [[package]] @@ -49,12 +55,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - [[package]] name = "base-x" version = "0.2.6" @@ -73,12 +73,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "boolinator" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9" - [[package]] name = "bstr" version = "0.2.13" @@ -105,9 +99,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cairo-rs" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157049ba9618aa3a61c39d5d785102c04d3b1f40632a706c621a9aedc21e6084" +checksum = "c5c0f2e047e8ca53d0ff249c54ae047931d7a6ebe05d00af73e0ffeb6e34bdb8" dependencies = [ "bitflags", "cairo-sys-rs", @@ -115,17 +109,18 @@ dependencies = [ "glib-sys", "gobject-sys", "libc", + "thiserror", ] [[package]] name = "cairo-sys-rs" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff65ba02cac715be836f63429ab00a767d48336efc5497c5637afb53b4f14d63" +checksum = "2ed2639b9ad5f1d6efa76de95558e11339e7318426d84ac4890b86c03e828ca7" dependencies = [ "glib-sys", "libc", - "pkg-config", + "system-deps", ] [[package]] @@ -142,14 +137,30 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cocoa" -version = "0.20.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8" +checksum = "c54201c07dcf3a5ca33fececb8042aed767ee4bfd5a0235a8ceabcda956044b2" +dependencies = [ + "bitflags", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics", + "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", - "core-graphics", + "core-graphics-types", "foreign-types", "libc", "objc", @@ -173,9 +184,9 @@ checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2" [[package]] name = "core-foundation" -version = "0.7.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" dependencies = [ "core-foundation-sys", "libc", @@ -183,15 +194,28 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.7.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" [[package]] name = "core-graphics" -version = "0.19.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" +checksum = "fc239bba52bab96649441699533a68de294a101533b0270b2d65aa402b29a7f9" +dependencies = [ + "bitflags", + "core-foundation", + "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", @@ -201,9 +225,9 @@ dependencies = [ [[package]] name = "core-text" -version = "15.0.0" +version = "19.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131b3fd1f8bd5db9f2b398fa4fdb6008c64afc04d447c306ac2c7e98fba2a61d" +checksum = "d2c7f46e8b820fd5f4b28528104b28b0a91cbe9e9c5bde8017087fb44bc93a60" dependencies = [ "core-foundation", "core-graphics", @@ -233,40 +257,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "direct2d" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa6ff10857eb253d1ae16987ebfd27372f4129b0c7a3fa41466fbdf7e453e75" -dependencies = [ - "directwrite", - "dxgi", - "either", - "winapi", - "wio", -] - -[[package]] -name = "direct3d11" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "315aa929e68ba066cb6fb86f1b22af24f517e02fd9b5734c4d07e42cb9f4aefa" -dependencies = [ - "dxgi", - "winapi", - "wio", -] - -[[package]] -name = "directwrite" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdcd739e9351c411b8caf5cab32a27c818cfe06260595da121382ecdd22083d" -dependencies = [ - "winapi", - "wio", -] - [[package]] name = "discard" version = "1.0.4" @@ -276,8 +266,7 @@ checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" [[package]] name = "druid" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4b259ffca57f018990c2eac38b4b095811ae77b6387a1ce0a13a89e6eda4058" +source = "git+https://github.com/doppioandante/druid?branch=stylus_events#c5e5f1c119fcb9b4216f1b72aed0862896b6e3a6" dependencies = [ "console_log", "druid-derive", @@ -297,8 +286,7 @@ dependencies = [ [[package]] name = "druid-derive" version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b53703b0938df4629bdd2c2b91cac35bb5a7a6ed6d18704099ff3c37beb9346" +source = "git+https://github.com/doppioandante/druid?branch=stylus_events#c5e5f1c119fcb9b4216f1b72aed0862896b6e3a6" dependencies = [ "proc-macro2", "quote", @@ -308,8 +296,7 @@ dependencies = [ [[package]] name = "druid-shell" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da6ec49be2a815bd553c0af453043625841441c405a33e6e2d51c9a5acfe59b" +source = "git+https://github.com/doppioandante/druid?branch=stylus_events#c5e5f1c119fcb9b4216f1b72aed0862896b6e3a6" dependencies = [ "anyhow", "bitflags", @@ -319,6 +306,7 @@ dependencies = [ "core-graphics", "foreign-types", "gdk", + "gdk-pixbuf", "gdk-sys", "gio", "glib", @@ -327,11 +315,13 @@ dependencies = [ "gtk-sys", "instant", "js-sys", + "keyboard-types", "kurbo", "lazy_static", "log", "objc", "piet-common", + "scopeguard", "time", "wasm-bindgen", "web-sys", @@ -340,13 +330,13 @@ dependencies = [ ] [[package]] -name = "dxgi" -version = "0.1.7" +name = "dwrote" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1639bbfd6765e92a40267d217a7acbac5b49320b68013f39a8e4376aa8c1e091" +checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" dependencies = [ - "boolinator", - "num", + "lazy_static", + "libc", "winapi", "wio", ] @@ -445,10 +435,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] -name = "fuchsia-cprng" -version = "0.1.1" +name = "futures" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +checksum = "5d8e3078b7b2a8a671cb7a3d17b4760e4181ea243227776ba83fd043b4ca034e" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] [[package]] name = "futures-channel" @@ -457,6 +456,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a4d35f7401e948629c9c3d6638fb9bf94e0b2121e96c3b428cc4e631f3eb74" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -494,6 +494,12 @@ dependencies = [ "syn", ] +[[package]] +name = "futures-sink" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8764258ed64ebc5d9ed185cf86a95db5cac810269c5d20ececb32e0088abbd" + [[package]] name = "futures-task" version = "0.3.6" @@ -509,9 +515,13 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a894a0acddba51a2d49a6f4263b1e64b8c579ece8af50fa86503d52cd1eea34" dependencies = [ + "futures-channel", "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project", "pin-utils", "proc-macro-hack", @@ -536,9 +546,9 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "gdk" -version = "0.12.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e8772fc0865c52460cdd7a59d7d47700f44d9809d1dd00eecceb769a7589" +checksum = "db00839b2a68a7a10af3fa28dfb3febaba3a20c3a9ac2425a33b7df1f84a6b7d" dependencies = [ "bitflags", "cairo-rs", @@ -556,9 +566,9 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e248220c46b329b097d4b158d2717f8c688f16dd76d0399ace82b3e98062bdd7" +checksum = "8f6dae3cb99dd49b758b88f0132f8d401108e63ae8edd45f432d42cdff99998a" dependencies = [ "gdk-pixbuf-sys", "gio", @@ -571,22 +581,22 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8991b060a9e9161bafd09bf4a202e6fd404f5b4dd1a08d53a1e84256fb34ab0" +checksum = "3bfe468a7f43e97b8d193a762b6c5cf67a7d36cacbc0b9291dbcae24bfea1e8f" dependencies = [ "gio-sys", "glib-sys", "gobject-sys", "libc", - "pkg-config", + "system-deps", ] [[package]] name = "gdk-sys" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6adf679e91d1bff0c06860287f80403e7db54c2d2424dce0a470023b56c88fbb" +checksum = "0a9653cfc500fd268015b1ac055ddbc3df7a5c9ea3f4ccef147b3957bd140d69" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -596,15 +606,17 @@ dependencies = [ "libc", "pango-sys", "pkg-config", + "system-deps", ] [[package]] name = "gio" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cd10f9415cce39b53f8024bf39a21f84f8157afa52da53837b102e585a296a5" +checksum = "1fb60242bfff700772dae5d9e3a1f7aa2e4ebccf18b89662a16acb2822568561" dependencies = [ "bitflags", + "futures", "futures-channel", "futures-core", "futures-io", @@ -613,27 +625,29 @@ dependencies = [ "glib", "glib-sys", "gobject-sys", - "lazy_static", "libc", + "once_cell", + "thiserror", ] [[package]] name = "gio-sys" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fad225242b9eae7ec8a063bb86974aca56885014672375e5775dc0ea3533911" +checksum = "5e24fb752f8f5d2cf6bbc2c606fd2bc989c81c5e2fe321ab974d54f8b6344eac" dependencies = [ "glib-sys", "gobject-sys", "libc", - "pkg-config", + "system-deps", + "winapi", ] [[package]] name = "glib" -version = "0.9.3" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40fb573a09841b6386ddf15fd4bc6655b4f5b106ca962f57ecaecde32a0061c0" +checksum = "0c685013b7515e668f1b57a165b009d4d28cb139a8a989bbd699c10dad29d0c5" dependencies = [ "bitflags", "futures-channel", @@ -641,38 +655,55 @@ dependencies = [ "futures-executor", "futures-task", "futures-util", + "glib-macros", "glib-sys", "gobject-sys", - "lazy_static", "libc", + "once_cell", +] + +[[package]] +name = "glib-macros" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41486a26d1366a8032b160b59065a59fb528530a46a49f627e7048fb8c064039" +dependencies = [ + "anyhow", + "heck", + "itertools", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "glib-sys" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95856f3802f446c05feffa5e24859fe6a183a7cb849c8449afc35c86b1e316e2" +checksum = "c7e9b997a66e9a23d073f2b1abb4dbfc3925e0b8952f67efd8d9b6e168e4cdc1" dependencies = [ "libc", - "pkg-config", + "system-deps", ] [[package]] name = "gobject-sys" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d1a804f62034eccf370006ccaef3708a71c31d561fee88564abe71177553d9" +checksum = "952133b60c318a62bf82ee75b93acc7e84028a093e06b9e27981c2b6fe68218c" dependencies = [ "glib-sys", "libc", - "pkg-config", + "system-deps", ] [[package]] name = "gtk" -version = "0.8.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e1e8d70290239c668594002d1b174fcc7d7ef5d26670ee141490ede8facf8f" +checksum = "2f022f2054072b3af07666341984562c8e626a79daa8be27b955d12d06a5ad6a" dependencies = [ "atk", "bitflags", @@ -689,17 +720,18 @@ dependencies = [ "glib-sys", "gobject-sys", "gtk-sys", - "lazy_static", "libc", + "once_cell", "pango", "pango-sys", + "pkg-config", ] [[package]] name = "gtk-sys" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53def660c7b48b00b510c81ef2d2fbd3c570f1527081d8d7947f471513e1a4c1" +checksum = "89acda6f084863307d948ba64a4b1ef674e8527dddab147ee4cdcc194c880457" dependencies = [ "atk-sys", "cairo-sys-rs", @@ -710,7 +742,16 @@ dependencies = [ "gobject-sys", "libc", "pango-sys", - "pkg-config", + "system-deps", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", ] [[package]] @@ -773,6 +814,15 @@ dependencies = [ "unic-langid", ] +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.6" @@ -788,6 +838,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keyboard-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a989afac88279b0482f402d234b5fbd405bf1ad051308595b58de4e6de22346b" +dependencies = [ + "bitflags", +] + [[package]] name = "kurbo" version = "0.6.3" @@ -837,90 +896,18 @@ dependencies = [ "libc", ] +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + [[package]] name = "memchr" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" -[[package]] -name = "num" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1" -dependencies = [ - "num-integer", - "num-traits", - "rand", - "rustc-serialize", -] - -[[package]] -name = "num-complex" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b288631d7878aaf59442cffd36910ea604ecd7745c36054328595114001c9656" -dependencies = [ - "num-traits", - "rustc-serialize", -] - -[[package]] -name = "num-integer" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "rustc-serialize", -] - -[[package]] -name = "num-traits" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" -dependencies = [ - "autocfg", -] - [[package]] name = "objc" version = "0.2.7" @@ -938,45 +925,45 @@ checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" [[package]] name = "pango" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c6b728f1be8edb5f9f981420b651d5ea30bdb9de89f1f1262d0084a020577" +checksum = "9937068580bebd8ced19975938573803273ccbcbd598c58d4906efd4ac87c438" dependencies = [ "bitflags", "glib", "glib-sys", "gobject-sys", - "lazy_static", "libc", + "once_cell", "pango-sys", ] [[package]] name = "pango-sys" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b93d84907b3cf0819bff8f13598ba72843bee579d5ebc2502e4b0367b4be7d" +checksum = "24d2650c8b62d116c020abd0cea26a4ed96526afda89b1c4ea567131fdefc890" dependencies = [ "glib-sys", "gobject-sys", "libc", - "pkg-config", + "system-deps", ] [[package]] name = "piet" -version = "0.1.0" +version = "0.2.0-pre5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256d71caa7e165076ed6d2f0cda83b97fb4a5db2b42fd9a0d06cc8ac2deb11d4" +checksum = "41dc88caa7ccaa1c1d53027f9664541c2e25bc215f711bbf3a37c7b76e08107e" dependencies = [ "kurbo", ] [[package]] name = "piet-cairo" -version = "0.1.0" +version = "0.2.0-pre5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a118675088b503c35ba2a91c43170ce2f843d88762285e48e8fc23ebdc7055b5" +checksum = "9ba3568ecdc1e9fee37f81382ff4732212d37da877e6f3ffa85137098538356f" dependencies = [ "cairo-rs", "piet", @@ -986,17 +973,14 @@ dependencies = [ [[package]] name = "piet-common" -version = "0.1.1" +version = "0.2.0-pre5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7472760c8f856e0a37a423f8af46708cdaaadc3032beb93891372ea2bfeeda" +checksum = "2ca8a570ed73009daa4118d5296106a89f4bb7133f989208200714f735ab6fd4" dependencies = [ "cairo-rs", + "cairo-sys-rs", "cfg-if", "core-graphics", - "direct2d", - "direct3d11", - "directwrite", - "dxgi", "piet", "piet-cairo", "piet-coregraphics", @@ -1008,33 +992,38 @@ dependencies = [ [[package]] name = "piet-coregraphics" -version = "0.1.1" +version = "0.2.0-pre5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54bbdad6e50184dfefe691f25b998defb2d1a832f65fc77043b08c07b1153475" +checksum = "235ce5a811a2b80aaa3cce285fc37f33e7ceb0f5386043565be5458341a6132a" dependencies = [ "core-foundation", "core-foundation-sys", "core-graphics", "core-text", + "foreign-types", "piet", + "unic-bidi", ] [[package]] name = "piet-direct2d" -version = "0.1.0" +version = "0.2.0-pre5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de6a8f033611d567c42c1b06803c169b1bd8b2bdc5c6a1daef0739165dd5c908" +checksum = "91cbf9d7a33cd261bdac060149f456f0fb10ed0502b800ffbfa84e4b83fbfcc8" dependencies = [ + "associative-cache", + "dwrote", "piet", + "utf16_lit", "winapi", "wio", ] [[package]] name = "piet-web" -version = "0.1.0" +version = "0.2.0-pre5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e812147c55d1dd8be983f50f3a117e1cef1785b70c7e0a5e286db39ba986710" +checksum = "4c5154285aedf517ad733560cf9f5f73ae1f67655ab7d41d00b32888e351693f" dependencies = [ "js-sys", "piet", @@ -1076,6 +1065,39 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "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-macro-hack" version = "0.5.18" @@ -1106,43 +1128,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "regex-automata" version = "0.1.9" @@ -1173,12 +1158,6 @@ dependencies = [ "syn", ] -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - [[package]] name = "rustc_version" version = "0.2.3" @@ -1194,6 +1173,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "semver" version = "0.9.0" @@ -1330,6 +1315,24 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" +[[package]] +name = "strum" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b" + +[[package]] +name = "strum_macros" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "syn" version = "1.0.42" @@ -1341,6 +1344,41 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-deps" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b" +dependencies = [ + "heck", + "pkg-config", + "strum", + "strum_macros", + "thiserror", + "toml", + "version-compare", +] + +[[package]] +name = "thiserror" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "time" version = "0.2.22" @@ -1385,6 +1423,15 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1" +[[package]] +name = "toml" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" +dependencies = [ + "serde", +] + [[package]] name = "type-map" version = "0.3.0" @@ -1414,6 +1461,37 @@ dependencies = [ "libudev-sys", ] +[[package]] +name = "unic-bidi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1356b759fb6a82050666f11dce4b6fe3571781f1449f3ef78074e408d468ec09" +dependencies = [ + "matches", + "unic-ucd-bidi", +] + +[[package]] +name = "unic-char-property" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" +dependencies = [ + "unic-char-range", +] + +[[package]] +name = "unic-char-range" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" + +[[package]] +name = "unic-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" + [[package]] name = "unic-langid" version = "0.9.0" @@ -1432,6 +1510,26 @@ dependencies = [ "tinystr", ] +[[package]] +name = "unic-ucd-bidi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d568b51222484e1f8209ce48caa6b430bf352962b877d592c29ab31fb53d8c" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-version" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" +dependencies = [ + "unic-common", +] + [[package]] name = "unicode-segmentation" version = "1.6.0" @@ -1444,6 +1542,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "utf16_lit" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403231d2fb8f0f55daf24cd03571f4fc1bb856e0fa98c1832bbae3f6ff7e7a07" + +[[package]] +name = "version-compare" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" + [[package]] name = "version_check" version = "0.9.2" diff --git a/Cargo.toml b/Cargo.toml index 3a5eab9..531e499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ udev = "0.2" libc = "0.2" errno = "0.2" csv = "1.1" -druid = "0.6" +druid = { git = "https://github.com/doppioandante/druid", branch = "stylus_events" } [dependencies.gtk] -version = "0.8.1" +version = "0.9.2" features = ["v3_24"] [dependencies.gio] diff --git a/src/bin/gtk_capture.rs b/src/bin/gtk_capture.rs index d81748a..efab0f4 100644 --- a/src/bin/gtk_capture.rs +++ b/src/bin/gtk_capture.rs @@ -68,9 +68,9 @@ fn main() { gtk::Inhibit(false) }); - let save_button = Button::new_from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Menu); - let clear_button = Button::new_from_icon_name(Some("edit-clear-all-symbolic"), gtk::IconSize::Menu); - let check_button = CheckButton::new_with_label("Join Points"); + let save_button = Button::from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Menu); + let clear_button = Button::from_icon_name(Some("edit-clear-all-symbolic"), gtk::IconSize::Menu); + let check_button = CheckButton::with_label("Join Points"); let header = HeaderBar::new(); header.pack_start(&save_button); @@ -142,11 +142,11 @@ fn main() { } } } + std::println!("{:#?}\n", event.get_device_tool().map(|tool| tool.get_tool_type())); gtk::Inhibit(capture_event) //std::println!("{:#?}",event.get_event_type()); //std::println!("{:#?}", event.get_source_device().and_then(|d| d.get_property_tool()).map(|t| t.get_tool_type())); //std::println!("{:#?}", event.get_device().and_then(|d| d.get_property_tool()).map(|t| t.get_tool_type())); - //std::println!("{:#?}\n", event.get_device_tool().map(|tool| tool.get_tool_type())); }); diff --git a/src/main.rs b/src/main.rs index 48856d3..be64506 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,137 @@ -use druid::widget::{Button, Flex, Label}; -use druid::{AppLauncher, LocalizedString, PlatformError, Widget, WidgetExt, WindowDesc}; +// Copyright 2019 The Druid Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. -fn main() -> Result<(), PlatformError> { - let main_window = WindowDesc::new(ui_builder); - let data = 0_u32; - AppLauncher::with_window(main_window) +//! An example of a custom drawing widget. + +use druid::kurbo::BezPath; +use druid::piet::{FontFamily, ImageFormat, InterpolationMode}; +use druid::widget::prelude::*; +use druid::{ + Affine, AppLauncher, ArcStr, Color, FontDescriptor, LocalizedString, Point, Rect, TextLayout, + WindowDesc, +}; + +struct CustomWidget; + +impl Widget for CustomWidget { + fn event(&mut self, _ctx: &mut EventCtx, event: &Event, _data: &mut String, _env: &Env) { + println!("{:?}", event); + } + + fn lifecycle( + &mut self, + _ctx: &mut LifeCycleCtx, + _event: &LifeCycle, + _data: &String, + _env: &Env, + ) { + } + + fn update(&mut self, _ctx: &mut UpdateCtx, _old_data: &String, _data: &String, _env: &Env) {} + + fn layout( + &mut self, + _layout_ctx: &mut LayoutCtx, + bc: &BoxConstraints, + _data: &String, + _env: &Env, + ) -> Size { + // BoxConstraints are passed by the parent widget. + // This method can return any Size within those constraints: + // bc.constrain(my_size) + // + // To check if a dimension is infinite or not (e.g. scrolling): + // bc.is_width_bounded() / bc.is_height_bounded() + bc.max() + } + + // The paint method gets called last, after an event flow. + // It goes event -> update -> layout -> paint, and each method can influence the next. + // Basically, anything that changes the appearance of a widget causes a paint. + fn paint(&mut self, ctx: &mut PaintCtx, data: &String, env: &Env) { + // Let's draw a picture with Piet! + + // Clear the whole widget with the color of your choice + // (ctx.size() returns the size of the layout rect we're painting in) + let size = ctx.size(); + let rect = size.to_rect(); + ctx.fill(rect, &Color::WHITE); + + // Note: ctx also has a `clear` method, but that clears the whole context, + // and we only want to clear this widget's area. + + // Create an arbitrary bezier path + let mut path = BezPath::new(); + path.move_to(Point::ORIGIN); + path.quad_to((80.0, 90.0), (size.width, size.height)); + // Create a color + let stroke_color = Color::rgb8(0, 128, 0); + // Stroke the path with thickness 1.0 + ctx.stroke(path, &stroke_color, 1.0); + + // Rectangles: the path for practical people + let rect = Rect::from_origin_size((10., 10.), (100., 100.)); + // Note the Color:rgba8 which includes an alpha channel (7F in this case) + let fill_color = Color::rgba8(0x00, 0x00, 0x00, 0x7F); + ctx.fill(rect, &fill_color); + + // Text is easy; in real use TextLayout should be stored in the widget + // and reused. + let mut layout = TextLayout::::from_text(data.to_owned()); + layout.set_font(FontDescriptor::new(FontFamily::SERIF).with_size(24.0)); + layout.set_text_color(fill_color); + layout.rebuild_if_needed(ctx.text(), env); + + // Let's rotate our text slightly. First we save our current (default) context: + ctx.with_save(|ctx| { + // Now we can rotate the context (or set a clip path, for instance): + ctx.transform(Affine::rotate(0.1)); + layout.draw(ctx, (80.0, 40.0)); + }); + // When we exit with_save, the original context's rotation is restored + + // Let's burn some CPU to make a (partially transparent) image buffer + let image_data = make_image_data(256, 256); + let image = ctx + .make_image(256, 256, &image_data, ImageFormat::RgbaSeparate) + .unwrap(); + // The image is automatically scaled to fit the rect you pass to draw_image + ctx.draw_image(&image, size.to_rect(), InterpolationMode::Bilinear); + } +} + +pub fn main() { + let window = WindowDesc::new(|| CustomWidget {}).title( + LocalizedString::new("custom-widget-demo-window-title").with_placeholder("Fancy Colors"), + ); + AppLauncher::with_window(window) .use_simple_logger() - .launch(data) + .launch("Druid + Piet".to_string()) + .expect("launch failed"); } -fn ui_builder() -> impl Widget { - // The label text will be computed dynamically based on the current locale and count - let text = - LocalizedString::new("hello-counter").with_arg("count", |data: &u32, _env| (*data).into()); - let label = Label::new(text).padding(5.0).center(); - let button = Button::new("increment") - .on_click(|_ctx, data, _env| *data += 1) - .padding(5.0); - - Flex::column().with_child(label).with_child(button) +fn make_image_data(width: usize, height: usize) -> Vec { + let mut result = vec![0; width * height * 4]; + for y in 0..height { + for x in 0..width { + let ix = (y * width + x) * 4; + result[ix] = x as u8; + result[ix + 1] = y as u8; + result[ix + 2] = !(x as u8); + result[ix + 3] = 127; + } + } + result } +