diff --git a/Cargo.lock b/Cargo.lock index de21eb1..62b8d96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.9.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4803cf8c252f374ae6bfbb341e49e5a37f7601f2ce74a105927a663eba952c67" +checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8" dependencies = [ "enumn", "serde", @@ -30,69 +30,64 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.13.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee8cf1202a4f94d31837f1902ab0a75c77b65bf59719e093703abe83efd74ec" +checksum = "04bb4d9e4772fe0d47df57d0d5dbe5d85dd05e2f37ae1ddb6b105e76be58fb00" dependencies = [ "accesskit", - "parking_lot 0.12.1", ] [[package]] name = "accesskit_macos" -version = "0.5.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10be25f2b27bc33aa1647072e86b948b41596f1af1ae43a2b4b9be5d2011cbda" +checksum = "134d0acf6acb667c89d3332999b1a5df4edbc8d6113910f392ebb73f2b03bb56" dependencies = [ "accesskit", "accesskit_consumer", "objc2", "once_cell", - "parking_lot 0.12.1", ] [[package]] name = "accesskit_unix" -version = "0.2.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630e7ee8f93c6246478bf0df6760db899b28d9ad54353a5f2d3157138ba817fc" +checksum = "e084cb5168790c0c112626175412dc5ad127083441a8248ae49ddf6725519e83" dependencies = [ "accesskit", "accesskit_consumer", "async-channel", "atspi", "futures-lite", - "parking_lot 0.12.1", "serde", "zbus", ] [[package]] name = "accesskit_windows" -version = "0.12.0" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13c462fabdd950ef14308a9390b07fa2e2e3aabccba1f3ea36ea2231bb942ab" +checksum = "9eac0a7f2d7cd7a93b938af401d3d8e8b7094217989a7c25c55a953023436e31" dependencies = [ "accesskit", "accesskit_consumer", "arrayvec", "once_cell", - "parking_lot 0.12.1", "paste", "windows", ] [[package]] name = "accesskit_winit" -version = "0.10.0" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17727888757ec027ec221db33070e226ee07df44425b583bc67684204d35eff9" +checksum = "825d23acee1bd6d25cbaa3ca6ed6e73faf24122a774ec33d52c5c86c6ab423c0" dependencies = [ "accesskit", "accesskit_macos", "accesskit_unix", "accesskit_windows", - "parking_lot 0.12.1", "winit", ] @@ -127,9 +122,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -193,7 +188,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" dependencies = [ - "event-listener", + "event-listener 2.5.3", "futures-core", ] @@ -204,20 +199,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] [[package]] name = "async-executor" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "78f2db9467baa66a700abce2a18c5ad793f6f83310aca1284796fc3921d113fd" dependencies = [ "async-lock", "async-task", "concurrent-queue", - "fastrand 1.9.0", + "fastrand 2.0.1", "futures-lite", "slab", ] @@ -260,24 +255,23 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", ] [[package]] name = "async-process" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9d28b1d97e08915212e2e45310d47854eafa69600756fc735fb788f75199c9" +checksum = "bf012553ce51eb7aa6dc2143804cc8252bd1cb681a1c5cb7fa94ca88682dee1d" dependencies = [ "async-io", "async-lock", - "autocfg", + "async-signal", "blocking", "cfg-if", - "event-listener", + "event-listener 3.0.0", "futures-lite", - "rustix 0.37.23", - "signal-hook 0.3.17", + "rustix 0.38.14", "windows-sys 0.48.0", ] @@ -293,10 +287,29 @@ dependencies = [ ] [[package]] -name = "async-task" -version = "4.4.0" +name = "async-signal" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "4af361a844928cb7d36590d406709473a1b574f443094422ef166daa3b493208" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "concurrent-queue", + "futures-core", + "futures-io", + "libc", + "signal-hook-registry", + "slab", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-task" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9441c6b2fe128a7c2bf680a44c34d0df31ce09e5b7e401fcca3faa483dbc921" [[package]] name = "async-trait" @@ -311,9 +324,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atomic_refcell" @@ -323,9 +336,9 @@ checksum = "112ef6b3f6cb3cb6fc5b6b494ef7a848492cff1ab0ef4de10b0f7d572861c905" [[package]] name = "atspi" -version = "0.8.7" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab84c09a770065868da0d713f1f4b35af85d96530a868f1c1a6c249178379187" +checksum = "674e7a3376837b2e7d12d34d58ac47073c491dc3bf6f71a7adaf687d4d817faa" dependencies = [ "async-recursion", "async-trait", @@ -340,17 +353,12 @@ dependencies = [ [[package]] name = "atspi-macros" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3ebc5a6f61f6996eca56a4cece7b3fe7da3b86f0473c7b71ab44e229f3acce4" +checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" dependencies = [ - "proc-macro2", "quote", - "serde", "syn 1.0.109", - "zbus", - "zbus_names", - "zvariant", ] [[package]] @@ -428,17 +436,18 @@ dependencies = [ [[package]] name = "blocking" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +checksum = "94c4ef1f913d78636d78d538eec1f18de81e481f44b1be0a81060090530846e1" dependencies = [ "async-channel", "async-lock", "async-task", - "atomic-waker", - "fastrand 1.9.0", + "fastrand 2.0.1", + "futures-io", "futures-lite", - "log", + "piper", + "tracing", ] [[package]] @@ -614,6 +623,42 @@ dependencies = [ "winapi", ] +[[package]] +name = "cocoa" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" +dependencies = [ + "bitflags 1.3.2", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" +dependencies = [ + "bitflags 1.3.2", + "block", + "core-foundation", + "core-graphics-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 = "combine" version = "4.6.6" @@ -626,9 +671,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] @@ -743,7 +788,7 @@ dependencies = [ "libc", "mio 0.7.14", "parking_lot 0.11.2", - "signal-hook 0.1.17", + "signal-hook", "winapi", ] @@ -857,9 +902,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "ecolor" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f99fe3cac305af9d6d92971af60d0f7ea4d783201ef1673571567b6699964d9" +checksum = "2e479a7fa3f23d4e794f8b2f8b3568dd4e47886ad1b12c9c095e141cb591eb63" dependencies = [ "bytemuck", "serde", @@ -867,11 +912,12 @@ dependencies = [ [[package]] name = "eframe" -version = "0.21.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df3ce60931e5f2d83bab4484d1a283908534d5308cc6b0c5c22c59cd15ee7cc" +checksum = "bf4596583a2c680c55b6feaa748f74890c4f9cb9c7cb69d6117110444cb65b2f" dependencies = [ "bytemuck", + "cocoa", "directories-next", "egui", "egui-winit", @@ -879,72 +925,85 @@ dependencies = [ "glow", "glutin", "glutin-winit", + "image", "js-sys", + "log", + "objc", "percent-encoding", "raw-window-handle", "ron", "serde", "thiserror", - "tracing", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "winapi", "winit", ] [[package]] name = "egui" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6412a21e0bde7c0918f7fb44bbbb86b5e1f88e63c026a4e747cc7af02f76dfbe" +checksum = "a3aef8ec3ae1b772f340170c65bf27d5b8c28f543a0116c844d2ac08d01123e7" dependencies = [ "accesskit", "ahash 0.8.3", "epaint", + "log", "nohash-hasher", "ron", "serde", - "tracing", ] [[package]] name = "egui-winit" -version = "0.21.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab43597ba41f0ce39a364ad83185594578bfd8b3409b99dbcbb01df23afc3dbb" +checksum = "4a49155fd4a0a4fb21224407a91de0030847972ef90fc64edb63621caea61cb2" dependencies = [ "accesskit_winit", - "android-activity", "arboard", "egui", "instant", + "log", + "raw-window-handle", "serde", "smithay-clipboard", - "tracing", "webbrowser", "winit", ] [[package]] -name = "egui_glow" -version = "0.21.0" +name = "egui_extras" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8257332fb168a965b3dca81d6a344e053153773c889cabdba0b3b76f1629ae81" +checksum = "9278f4337b526f0d57e5375e5a7340a311fa6ee8f9fcc75721ac50af13face02" +dependencies = [ + "egui", + "serde", +] + +[[package]] +name = "egui_glow" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8c2752cdf1b0ef5fcda59a898cacabad974d4f5880e92a420b2c917022da64" dependencies = [ "bytemuck", "egui", "glow", + "log", "memoffset 0.6.5", - "tracing", "wasm-bindgen", "web-sys", ] [[package]] name = "emath" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ecd80612937e0267909d5351770fe150004e24dab93954f69ca62eecd3f77e" +checksum = "3857d743a6e0741cdd60b622a74c7a36ea75f5f8f11b793b41d905d2c9721a4b" dependencies = [ "bytemuck", "serde", @@ -984,9 +1043,9 @@ dependencies = [ [[package]] name = "epaint" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e78b5c58a1f7f621f9d546add2adce20636422c9b251e29f749e8a2f713c95" +checksum = "09333964d4d57f40a85338ba3ca5ed4716070ab184dcfed966b35491c5c64f3b" dependencies = [ "ab_glyph", "ahash 0.8.3", @@ -994,6 +1053,7 @@ dependencies = [ "bytemuck", "ecolor", "emath", + "log", "nohash-hasher", "parking_lot 0.12.1", "serde", @@ -1042,6 +1102,17 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29e56284f00d94c1bc7fd3c77027b4623c88c1f53d8d2394c6199f2921dea325" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1053,9 +1124,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fdeflate" @@ -1305,9 +1376,9 @@ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -1334,6 +1405,20 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "image" +version = "0.24.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "num-rational", + "num-traits", + "png", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1416,9 +1501,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -1697,6 +1782,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.16" @@ -1776,9 +1882,9 @@ checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" [[package]] name = "objc2" -version = "0.3.0-beta.3" +version = "0.3.0-beta.3.patch-leaks.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe31e5425d3d0b89a15982c024392815da40689aceb34bad364d58732bcfd649" +checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" dependencies = [ "block2", "objc-sys", @@ -1845,9 +1951,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" +checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" [[package]] name = "parking_lot" @@ -1921,6 +2027,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + [[package]] name = "pkg-config" version = "0.3.27" @@ -2136,9 +2253,9 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "rend" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd" dependencies = [ "bytecheck", ] @@ -2188,6 +2305,7 @@ name = "rpn_rs" version = "0.6.0" dependencies = [ "confy", + "egui_extras", "lazy_static", "rust_decimal", "rust_decimal_macros", @@ -2205,11 +2323,13 @@ dependencies = [ "console_error_panic_hook", "eframe", "egui", + "egui_extras", "rpn_rs", "serde", "tracing", "tracing-subscriber", "tracing-wasm", + "wasm-bindgen", "wasm-bindgen-futures", ] @@ -2267,9 +2387,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" dependencies = [ "bitflags 2.4.0", "errno", @@ -2333,18 +2453,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-xml-rs" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0bf1ba0696ccf0872866277143ff1fd14d22eec235d2b23702f95e6660f7dfa" -dependencies = [ - "log", - "serde", - "thiserror", - "xml-rs", -] - [[package]] name = "serde_derive" version = "1.0.188" @@ -2392,9 +2500,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -2421,16 +2529,6 @@ dependencies = [ "signal-hook-registry", ] -[[package]] -name = "signal-hook" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -2472,15 +2570,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smithay-client-toolkit" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f307c47d32d2715eb2e0ece5589057820e0e5e70d07c247d1063e844e107f454" +checksum = "870427e30b8f2cbe64bf43ec4b86e88fe39b0a84b3f15efd9c9c2d020bc86eb9" dependencies = [ "bitflags 1.3.2", "calloop", @@ -2568,9 +2666,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", - "fastrand 2.0.0", + "fastrand 2.0.1", "redox_syscall 0.3.5", - "rustix 0.38.13", + "rustix 0.38.14", "windows-sys 0.48.0", ] @@ -2606,9 +2704,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" dependencies = [ "deranged", "itoa", @@ -2619,15 +2717,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" dependencies = [ "time-core", ] @@ -2855,9 +2953,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "url" @@ -2896,9 +2994,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "waker-fn" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "walkdir" @@ -2918,9 +3016,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2928,24 +3026,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.37", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -2955,9 +3053,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2965,22 +3063,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wayland-client" @@ -3069,9 +3167,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -3112,9 +3210,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -3136,25 +3234,31 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0286ba339aa753e70765d521bb0242cc48e1194562bfa2a2ad7ac8a6de28f5d5" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ "windows-implement", - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-interface", + "windows-targets 0.48.5", ] [[package]] name = "windows-implement" -version = "0.42.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9539b6bd3eadbd9de66c9666b22d802b833da7e996bc06896142e09854a61767" +checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "windows-interface" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" dependencies = [ "proc-macro2", "quote", @@ -3400,9 +3504,9 @@ dependencies = [ [[package]] name = "xml-rs" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab77e97b50aee93da431f2cee7cd0f43b4d1da3c408042f2d7d164187774f0a" +checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" [[package]] name = "yaml-rust" @@ -3432,7 +3536,7 @@ dependencies = [ "byteorder", "derivative", "enumflags2", - "event-listener", + "event-listener 2.5.3", "futures-core", "futures-sink", "futures-util", @@ -3442,7 +3546,6 @@ dependencies = [ "ordered-stream", "rand", "serde", - "serde-xml-rs", "serde_repr", "sha1", "static_assertions", diff --git a/Cargo.toml b/Cargo.toml index 9c32575..53ea37e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ rust_decimal_macros = "1.29.1" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } tracing-appender = "0.2.2" tracing = "0.1.37" +egui_extras = "0.22.0" [dependencies.confy] # TODO: Update this to v0.5.0 when it finally comes out -- for now, use latest git master diff --git a/README.adoc b/README.adoc index 034f3cb..6a5ace0 100644 --- a/README.adoc +++ b/README.adoc @@ -133,3 +133,7 @@ Will I implement these features? I don't know. Lots of these could be done by se * Bases: Not yet * Different math operators like `!` or `sum`: If someone asks me to, I guess * Conditionals: If someone asks me to, I guess + +=== Credits + +* LCD Solid Font licensed as public domain from: https://www.fontspace.com/lcd-solid-font-f11346 diff --git a/rpn_rs_gui/Cargo.lock b/rpn_rs_gui/Cargo.lock index c54de02..d43524a 100644 --- a/rpn_rs_gui/Cargo.lock +++ b/rpn_rs_gui/Cargo.lock @@ -35,7 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cee8cf1202a4f94d31837f1902ab0a75c77b65bf59719e093703abe83efd74ec" dependencies = [ "accesskit", - "parking_lot 0.12.1", + "parking_lot", ] [[package]] @@ -48,7 +48,7 @@ dependencies = [ "accesskit_consumer", "objc2", "once_cell", - "parking_lot 0.12.1", + "parking_lot", ] [[package]] @@ -62,7 +62,7 @@ dependencies = [ "async-channel", "atspi", "futures-lite", - "parking_lot 0.12.1", + "parking_lot", "serde", "zbus", ] @@ -77,7 +77,7 @@ dependencies = [ "accesskit_consumer", "arrayvec", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "paste", "windows", ] @@ -92,7 +92,7 @@ dependencies = [ "accesskit_macos", "accesskit_unix", "accesskit_windows", - "parking_lot 0.12.1", + "parking_lot", "winit", ] @@ -159,7 +159,7 @@ dependencies = [ "objc-foundation", "objc_id", "once_cell", - "parking_lot 0.12.1", + "parking_lot", "thiserror", "winapi", "x11rb", @@ -185,7 +185,7 @@ checksum = "1b19760fa2b7301cf235360ffd6d3558b1ed4249edd16d6cca8d690cee265b95" dependencies = [ "event-listener", "futures-core", - "parking_lot 0.12.1", + "parking_lot", ] [[package]] @@ -412,12 +412,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cassowary" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" - [[package]] name = "cc" version = "1.0.79" @@ -484,17 +478,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "confy" -version = "0.5.1" -source = "git+https://github.com/rust-cli/confy/#700337e5a3fbc12f4f49fc9b7ce449b1b71040ee" -dependencies = [ - "directories", - "serde", - "serde_yaml", - "thiserror", -] - [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -573,31 +556,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossterm" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e86d73f2a0b407b5768d10a8c720cf5d2df49a9efc10ca09176d201ead4b7fb" -dependencies = [ - "bitflags", - "crossterm_winapi", - "lazy_static", - "libc", - "mio 0.7.14", - "parking_lot 0.11.2", - "signal-hook", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2265c3f8e080075d9b6417aa72293fc71662f34b4af2612d8d1b074d29510db" -dependencies = [ - "winapi", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -635,15 +593,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "directories" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" -dependencies = [ - "dirs-sys", -] - [[package]] name = "directories-next" version = "2.0.0" @@ -846,7 +795,7 @@ dependencies = [ "ecolor", "emath", "nohash-hasher", - "parking_lot 0.12.1", + "parking_lot", "serde", ] @@ -1190,12 +1139,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "lock_api" version = "0.4.9" @@ -1263,19 +1206,6 @@ dependencies = [ "adler", ] -[[package]] -name = "mio" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", -] - [[package]] name = "mio" version = "0.8.5" @@ -1288,15 +1218,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -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.7.0" @@ -1377,15 +1298,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1521,17 +1433,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.1" @@ -1539,21 +1440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", + "parking_lot_core", ] [[package]] @@ -1765,37 +1652,18 @@ dependencies = [ ] [[package]] -name = "rpn_rs" -version = "0.6.0" -dependencies = [ - "confy", - "crossterm", - "lazy_static", - "serde", - "toml", - "tui", -] - -[[package]] -name = "rpn_rs_gui" +name = "rpn_rs2" version = "0.1.0" dependencies = [ "console_error_panic_hook", "eframe", "egui", - "rpn_rs", "serde", "tracing-subscriber", "tracing-wasm", "wasm-bindgen-futures", ] -[[package]] -name = "ryu" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" - [[package]] name = "same-file" version = "1.0.6" @@ -1873,18 +1741,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_yaml" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" -dependencies = [ - "indexmap", - "ryu", - "serde", - "yaml-rust", -] - [[package]] name = "sha1" version = "0.10.5" @@ -1905,26 +1761,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "signal-hook" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" -dependencies = [ - "libc", - "mio 0.7.14", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "slab" version = "0.4.7" @@ -2101,15 +1937,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "toml" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "0.5.1" @@ -2202,19 +2029,6 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633" -[[package]] -name = "tui" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ced152a8e9295a5b168adc254074525c17ac4a83c90b2716274cc38118bddc9" -dependencies = [ - "bitflags", - "cassowary", - "crossterm", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "typenum" version = "1.16.0" @@ -2252,18 +2066,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "url" version = "2.3.1" @@ -2666,7 +2468,7 @@ dependencies = [ "instant", "libc", "log", - "mio 0.8.5", + "mio", "ndk", "objc2", "once_cell", @@ -2734,15 +2536,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "zbus" version = "3.9.0" diff --git a/rpn_rs_gui/Cargo.toml b/rpn_rs_gui/Cargo.toml index 90db214..442419c 100644 --- a/rpn_rs_gui/Cargo.toml +++ b/rpn_rs_gui/Cargo.toml @@ -8,17 +8,13 @@ rust-version = "1.65" [dependencies] rpn_rs = {path=".."} -egui = "0.21.0" -eframe = { version = "0.21.0", default-features = false, features = [ - "accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies. - "default_fonts", # Embed the default egui fonts. - "glow", # Use the glow rendering backend. Alternative: "wgpu". - "persistence", # Enable restoring app state when restarting the app. -] } +egui = "0.22.0" +eframe = { version = "0.22.0", default-features = false, features = ["accesskit", "default_fonts", "glow", "persistence"] } # You only need serde if you want app persistence: serde = { version = "1", features = ["derive"] } tracing = "0.1.37" +egui_extras = "0.22.0" # native: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -28,6 +24,7 @@ tracing-subscriber = "0.3" [target.'cfg(target_arch = "wasm32")'.dependencies] console_error_panic_hook = "0.1.6" tracing-wasm = "0.2" +wasm-bindgen = { version = "0.2.87" } wasm-bindgen-futures = "0.4" diff --git a/rpn_rs_gui/LcdSolid-VPzB.ttf b/rpn_rs_gui/LcdSolid-VPzB.ttf new file mode 100644 index 0000000..808f3ee Binary files /dev/null and b/rpn_rs_gui/LcdSolid-VPzB.ttf differ diff --git a/rpn_rs_gui/src/app.rs b/rpn_rs_gui/src/app.rs index 8e8c40e..bcb9374 100644 --- a/rpn_rs_gui/src/app.rs +++ b/rpn_rs_gui/src/app.rs @@ -1,35 +1,120 @@ +use std::collections::HashSet; + use egui::{ - Button, Color32, FontId, Frame, Grid, Key, Label, RichText, Rounding, ScrollArea, Stroke, - Style, Vec2, + Align, Button, Color32, Direction, FontData, FontDefinitions, FontFamily, FontId, Frame, Grid, + Id, Key, Label, Layout, Margin, PointerButton, Pos2, Rect, RichText, Rounding, ScrollArea, + Sense, Stroke, Style, TouchId, TouchPhase, Vec2, +}; +use egui_extras::{Column, Size, StripBuilder, TableBuilder}; +use rpn_rs::calc::{ + entries::CalculatorEntry, + errors::CalculatorError, + types::{CalculatorDisplayMode, CalculatorState}, + Calculator, }; -use rpn_rs::calc::{errors::CalculatorError, Calculator}; use tracing::{error, info}; +mod buttons; +use buttons::CalculatorButton; + +use self::buttons::{BUTTON_LAYOUT, BUTTON_LAYOUT_SETTINGS}; const DEFAULT_FONT_SIZE: f32 = 45.0; const STACK_FONT_SIZE: f32 = 25.0; const DEFAULT_FONT: FontId = FontId::monospace(DEFAULT_FONT_SIZE); +// const BUTTON_SIZE_WIDTH: Size = Size::remainder(); +// const BUTTON_SIZE_HEIGHT: Size = Size::remainder(); +// const BUTTON_SIZE: Vec2 = Vec2 { x: 67.0, y: 60.0 }; const BUTTON_SPACING: Vec2 = Vec2 { x: 0.0, y: 0.0 }; -const BUTTON_PADDING: Vec2 = Vec2 { x: 24.0, y: 5.0 }; +// const BUTTON_PADDING: Vec2 = Vec2 { x: 24.0, y: 5.0 }; +const BUTTON_PADDING: Vec2 = Vec2 { x: 0.0, y: 0.0 }; /// We derive Deserialize/Serialize so we can persist app state on shutdown. #[derive(serde::Deserialize, serde::Serialize)] -#[serde(default)] // if we add new fields, give them default values when deserializing old state +#[serde(default)] pub struct TemplateApp { - calculator: Calculator, + calculator: CalculatorInner, #[serde(skip)] latest_error: Option, + #[serde(skip)] + touches_down: HashSet, + + #[serde(skip)] + new_touches: Vec, +} + +#[derive(serde::Deserialize, serde::Serialize, Default)] +#[serde(default)] +pub struct CalculatorInner { + calculator: Calculator, + #[serde(skip)] error_state: ErrorState, } +impl CalculatorInner { + fn calculator_input(&mut self, c: char) { + let action = if c == '$' { + self.calculator.backspace() + } else { + self.calculator.take_input(c) + }; + + if let Err(e) = action { + self.error_state.errored(e); + } else { + self.error_state.success(); + } + } +} + +/// Phase of a click or tap +#[derive(Debug, Clone, Copy)] +enum ClickPhase { + Start, + End, + Ignored, +} + +/// ID of a click or tap +/// +/// Required because taps have IDs, but clicks don't +#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] +enum ClickTapId { + Tap(u64), + Click(u8), +} + +impl From<&TouchId> for ClickTapId { + fn from(value: &TouchId) -> Self { + Self::Tap(value.0) + } +} + +impl From<&PointerButton> for ClickTapId { + fn from(value: &PointerButton) -> Self { + Self::Click(*value as u8) + } +} + +impl From<&TouchPhase> for ClickPhase { + fn from(value: &TouchPhase) -> Self { + match value { + TouchPhase::Start => Self::Start, + TouchPhase::End => Self::End, + TouchPhase::Move | TouchPhase::Cancel => Self::Ignored, + } + } +} + impl Default for TemplateApp { fn default() -> Self { Self { - calculator: Calculator::default(), + calculator: CalculatorInner::default(), latest_error: None, - error_state: ErrorState::default(), + touches_down: HashSet::new(), + new_touches: Vec::new(), } } } @@ -42,37 +127,57 @@ impl TemplateApp { // Load previous app state (if any). // Note that you must enable the `persistence` feature for this to work. + let ret; if let Some(storage) = cc.storage { - return eframe::get_value(storage, eframe::APP_KEY).unwrap_or_default(); - } - - Default::default() - } - - fn calculator_input(&mut self, c: char) { - if let Err(e) = self.calculator.take_input(c) { - self.error_state.errored(e); + ret = eframe::get_value(storage, eframe::APP_KEY).unwrap_or_default(); } else { - self.error_state.success(); + ret = Default::default() } + + TemplateApp::initialize_fonts(&cc.egui_ctx); + + ret } fn draw_stack(&mut self, ui: &mut egui::Ui) { - ui.add(Label::new( - RichText::new( - self.calculator - .stack - .iter() - .rev() - .map(|e| e.to_string()) - .collect::>() - .join("\n"), - ) - .background_color(egui::Color32::RED) - .font(DEFAULT_FONT) - .size(STACK_FONT_SIZE) - .color(Color32::WHITE), - )); + TableBuilder::new(ui) + .stick_to_bottom(true) + // .column(Column::auto() ) + .column(Column::remainder()) + // .header(20.0, |mut header| { + // header.col(|ui| { + // ui.heading("Entry"); + // }); + // header.col(|ui| { + // ui.heading("Value"); + // }); + // }) + .body(|mut body| { + for (_idx, entry) in self.calculator.calculator.stack.iter().enumerate().rev() { + body.row(30.0, |mut row| { + // row.col(|ui| { + // ui.add(Label::new( + // RichText::new(format!("{idx}")) + // .background_color(Color32::RED) + // .font(DEFAULT_FONT) + // .size(STACK_FONT_SIZE) + // .color(Color32::WHITE) + // )); + // }); + row.col(|ui| { + ui.add(Label::new( + RichText::new( + entry.format_entry(&self.calculator.calculator.display_mode), + ) + .background_color(Color32::DARK_GRAY) + .font(DEFAULT_FONT) + .size(STACK_FONT_SIZE) + .color(Color32::WHITE), + )); + }); + }); + } + }); } fn draw_error(&mut self, ui: &mut egui::Ui) { @@ -81,50 +186,114 @@ impl TemplateApp { RichText::new(e.to_string()) .font(DEFAULT_FONT) .size(STACK_FONT_SIZE) - .color(Color32::RED), + .background_color(Color32::RED) + .color(Color32::WHITE), ); } } fn draw_input(&mut self, ui: &mut egui::Ui) { - egui::Frame::none() - .fill(egui::Color32::RED) - .inner_margin(5.0) - .stroke(Stroke::new(10.0, Color32::BLUE)) - .show(ui, |ui| { - ui.label( - RichText::new(self.calculator.get_l()) - .color(Color32::WHITE) - .font(DEFAULT_FONT), - ); - }); + ui.painter() + .rect_filled(ui.available_rect_before_wrap(), 0.0, Color32::LIGHT_GREEN); + ui.label( + RichText::new(self.calculator.calculator.get_l()) + .color(Color32::BLACK) + .font(FontId::monospace(30.0)), + ); } fn draw_buttons(&mut self, ui: &mut egui::Ui) { - Grid::new("grid").spacing(BUTTON_SPACING).show(ui, |ui| { - for row in BUTTON_LAYOUT.iter() { - for button in row.iter() { - let label = RichText::new(button.value) - .font(DEFAULT_FONT) - .color(Color32::WHITE); - if ui - .add_enabled( - button.enabled, - Button::new(label) - .stroke(Stroke::NONE) - .rounding(Rounding::none()) - .fill(Color32::from_gray(0x12)), - ) - .on_hover_text(button.help) - .clicked() - { - info!("Clicked button {}", button.value); - self.calculator_input(button.value); - } + let button_layout = match self.calculator.calculator.state { + CalculatorState::Normal => BUTTON_LAYOUT, + CalculatorState::WaitingForConstant => return, + CalculatorState::WaitingForMacro => return, + CalculatorState::WaitingForRegister(_) => return, + CalculatorState::WaitingForSetting => BUTTON_LAYOUT_SETTINGS, + }; + + StripBuilder::new(ui) + .sizes(Size::exact(60.0), button_layout.len()) + // .sizes(Size::remainder(), button_layout.len()) + .vertical(|mut strip| { + for row in button_layout.iter() { + strip.strip(|builder| { + builder + .sizes(Size::remainder(), row.len()) + .horizontal(|mut strip| { + for button_definition in row.iter() { + strip.cell(|ui| { + let sense = Sense::click(); + + let label = RichText::new(button_definition.value) + .font(DEFAULT_FONT) + .color(Color32::WHITE) + .background_color(Color32::BLACK); + + ui.painter().rect_filled( + ui.available_rect_before_wrap(), + 0.0, + Color32::GOLD, + ); + ui.style_mut().spacing.window_margin = Margin { + left: 0.0, + right: 0.0, + top: 0.0, + bottom: 0.0, + }; + + let max_size = { + let ret = ui.available_rect_before_wrap(); + Vec2 { + x: ret.width(), + y: ret.height(), + } + }; + + ui.vertical_centered(|ui| { + ui.add_enabled( + button_definition.enabled, + Button::new(label) + .stroke(Stroke::NONE) + .rounding(Rounding::none()) + .fill(Color32::from_gray(0x12)) + .min_size(max_size) + .sense(sense), + ) + }); + + // let button = { + // let ret = ui.add_enabled( + // button_definition.enabled, + // Button::new(label) + // .stroke(Stroke::NONE) + // .rounding(Rounding::none()) + // .fill(Color32::from_gray(0x12)) + // .min_size(max_size) + // .sense(sense), + // ); + + // ret + // }; + + // Check if any new touches intersect with this button + let max_rect = ui.max_rect(); + for touch in self.new_touches.iter() { + if max_rect.contains(*touch) { + self.calculator + .calculator_input(button_definition.value); + } + } + }); + } + }); + }); } - ui.end_row(); - } - }); + }); + } + + fn layout() -> Layout { + Layout::from_main_dir_and_cross_align(Direction::TopDown, Align::Center) + .with_cross_justify(true) } fn handle_input(&mut self, i: &egui::InputState) { @@ -135,63 +304,126 @@ impl TemplateApp { for e in i.events.iter() { match e { egui::Event::Text(t) => { - self.calculator_input(t.chars().next().unwrap()); - } - egui::Event::Key { - key: Key::ArrowLeft, - pressed: true, - .. - } => { - self.calculator_input('<'); + self.calculator.calculator_input(t.chars().next().unwrap()); } + // egui::Event::Key { + // key: Key::ArrowLeft, + // pressed: true, + // .. + // } => { + // self.calculator.calculator_input('<'); + // } egui::Event::Key { key: Key::ArrowRight, pressed: true, .. } => { - self.calculator_input('>'); + self.calculator.calculator_input('>'); } egui::Event::Key { key: Key::Enter, pressed: true, .. } => { - self.calculator_input(' '); + self.calculator.calculator_input(' '); } + egui::Event::Touch { + device_id: _, + id, + phase, + pos, + force: _, + } => { + self.handle_touch_event(phase.into(), pos.clone(), id); + } + egui::Event::PointerButton { + pos, + button, + pressed, + modifiers: _, + } => self.handle_touch_event( + if *pressed { + ClickPhase::Start + } else { + ClickPhase::End + }, + *pos, + button, + ), - egui::Event::Copy => continue, - egui::Event::Cut => continue, - egui::Event::Paste(_) => continue, - egui::Event::Key { + egui::Event::Copy + | egui::Event::Cut + | egui::Event::Paste(_) + | egui::Event::Key { key: _, pressed: _, repeat: _, modifiers: _, - } => continue, - egui::Event::PointerMoved(_) => continue, - egui::Event::PointerButton { - pos: _, - button: _, - pressed: _, + } + | egui::Event::PointerMoved(_) + | egui::Event::PointerGone + | egui::Event::Scroll(_) + | egui::Event::Zoom(_) + | egui::Event::CompositionStart + | egui::Event::CompositionUpdate(_) + | egui::Event::CompositionEnd(_) + | egui::Event::AccessKitActionRequest(_) + | egui::Event::MouseWheel { + unit: _, + delta: _, modifiers: _, - } => continue, - egui::Event::PointerGone => continue, - egui::Event::Scroll(_) => continue, - egui::Event::Zoom(_) => continue, - egui::Event::CompositionStart => continue, - egui::Event::CompositionUpdate(_) => continue, - egui::Event::CompositionEnd(_) => continue, - egui::Event::Touch { - device_id: _, - id: _, - phase: _, - pos: _, - force: _, - } => continue, - egui::Event::AccessKitActionRequest(_) => continue, + } + | egui::Event::WindowFocused(_) => continue, } } } + + fn handle_touch_event(&mut self, phase: ClickPhase, pos: Pos2, id: impl Into) { + let id = id.into(); + match phase { + ClickPhase::Start => { + // TODO: This can be way better + + // If this is a brand new touch + if !self.touches_down.contains(&id) + // And it isn't a duplicate + // This can occur on phones where touches can be pointer events + && !self.new_touches.contains(&pos) + { + self.new_touches.push(pos); + } + self.touches_down.insert(id); + } + ClickPhase::End => { + self.touches_down.remove(&id); + } + ClickPhase::Ignored => {} + } + } + + fn initialize_fonts(egui_ctx: &egui::Context) { + info!("Initializing fonts"); + let mut fonts = FontDefinitions::default(); + + fonts.font_data.insert( + "LCD_Solid".to_owned(), + FontData::from_static(include_bytes!("../LcdSolid-VPzB.ttf")), + ); + + fonts + .families + .get_mut(&FontFamily::Monospace) + .unwrap() + .insert(0, "LCD_Solid".to_owned()); + + fonts + .families + .get_mut(&FontFamily::Monospace) + .unwrap() + .push("LCD_Solid".to_owned()); + + egui_ctx.set_fonts(fonts); + } } impl eframe::App for TemplateApp { @@ -209,135 +441,62 @@ impl eframe::App for TemplateApp { style.spacing.button_padding = BUTTON_PADDING; ctx.set_style(style); - // #[cfg(not(target_arch = "wasm32"))] - // egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { - // // The top panel is often a good place for a menu bar: - // egui::menu::bar(ui, |ui| { - // ui.menu_button("File", |ui| { - // if ui.button("Quit").clicked() { - // _frame.close(); - // } - // }); - // }); - // }); - - self.error_state = ErrorState::default(); + self.calculator.error_state = ErrorState::default(); egui::CentralPanel::default().show(ctx, |ui| { + // ui.with_layout(self.layout, add_contents) ui.input(|i: &egui::InputState| self.handle_input(i)); - Frame::none().fill(Color32::GREEN).show(ui, |ui| { - ui.vertical(|ui| { - ui.heading("rpn_rs_gui"); - ui.hyperlink("https://gitea.austen-wares.com/stonewareslord/rpn_rs"); - - // Buttons - self.draw_buttons(ui); - - // Stack - - ScrollArea::vertical().show(ui, |ui| { + StripBuilder::new(ui) + // header + .size(Size::exact(65.0)) + // Stack + // .size(Size::remainder().at_most(35.0)) + .size(Size::remainder().at_least(40.0)) + // Input + .size(Size::exact(40.0)) + // Error + .size(Size::exact(20.0)) + // Buttons + .size(Size::exact(450.0)) + .vertical(|mut strip| { + strip.cell(|ui| { + ui.heading("rpn_rs_gui"); + ui.hyperlink("https://gitea.austen-wares.com/stonewareslord/rpn_rs"); + }); + strip.cell(|ui| { + // Stack + ui.painter().rect_filled( + ui.available_rect_before_wrap(), + 0.0, + Color32::LIGHT_GRAY, + ); self.draw_stack(ui); }); - - self.draw_input(ui); - // Reset the error state and update `self.latest_error` if required - match std::mem::take(&mut self.error_state) { - ErrorState::NoModify => {} - ErrorState::Errored(e) => self.latest_error = Some(e), - ErrorState::Clear => self.latest_error = None, - } - - self.draw_error(ui); - egui::warn_if_debug_build(ui); - }); - }) + strip.cell(|ui| { + self.draw_input(ui); + // Reset the error state and update `self.latest_error` if required + match std::mem::take(&mut self.calculator.error_state) { + ErrorState::NoModify => {} + ErrorState::Errored(e) => self.latest_error = Some(e), + ErrorState::Clear => self.latest_error = None, + } + }); + strip.cell(|ui| { + // Error bar + self.draw_error(ui); + }); + strip.cell(|ui| { + // Buttons + self.draw_buttons(ui); + }); + }) }); - // if false { - // egui::Window::new("Window").show(ctx, |ui| { - // ui.label("Windows can be moved by dragging them."); - // ui.label("They are automatically sized based on contents."); - // ui.label("You can turn on resizing and scrolling if you like."); - // ui.label("You would normally choose either panels OR windows."); - // }); - // } + self.new_touches.drain(..); } } -struct CalculatorButton { - value: char, - help: &'static str, - enabled: bool, -} - -impl CalculatorButton { - const fn new(value: char, help: &'static str, enabled: bool) -> Self { - Self { - value, - help, - enabled, - } - } -} - -const BUTTON_LAYOUT: &[&[CalculatorButton]] = &[ - &[ - // CalculatorButton::new('s', "Sin", true), - CalculatorButton::new('u', "Undo", true), - CalculatorButton::new('U', "Redo", true), - CalculatorButton::new('>', "Swap", true), - CalculatorButton::new('@', "Drop", true), - ], - &[ - // CalculatorButton::new('|', "AbsoluteValue", true), - CalculatorButton::new('v', "Sqrt", true), - CalculatorButton::new('^', "Pow", true), - CalculatorButton::new('l', "Log", true), - CalculatorButton::new('L', "Ln", true), - ], - &[ - // CalculatorButton::new('c', "Cos", true), - CalculatorButton::new('n', "Negate", true), - CalculatorButton::new('%', "Modulo", true), - CalculatorButton::new('i', "Inverse", true), - CalculatorButton::new('/', "Divide", true), - ], - &[ - // CalculatorButton::new('t', "Tan", true), - CalculatorButton::new('7', "7", true), - CalculatorButton::new('8', "8", true), - CalculatorButton::new('9', "9", true), - CalculatorButton::new('*', "Multiply", true), - ], - &[ - // CalculatorButton::new('S', "ASin", true), - CalculatorButton::new('4', "4", true), - CalculatorButton::new('5', "5", true), - CalculatorButton::new('6', "6", true), - CalculatorButton::new('-', "Subtract", true), - ], - &[ - // CalculatorButton::new('C', "ACos", true), - CalculatorButton::new('1', "1", true), - CalculatorButton::new('2', "2", true), - CalculatorButton::new('3', "3", true), - CalculatorButton::new('+', "Add", true), - ], - &[ - // CalculatorButton::new('T', "ATan", true), - CalculatorButton::new('0', "0", true), - CalculatorButton::new('\\', "Drop", true), - CalculatorButton::new('.', "Decimal", true), - CalculatorButton::new(' ', "Return", true), - ], - // CalculatorButton::new ( '?', "IntegerDivide", true), - // CalculatorButton::new ( 'V', "BuildVector", true), - // CalculatorButton::new ( 'M', "BuildMatrix", true), - // CalculatorButton::new ( '_', "Deconstruct", true), - // CalculatorButton::new ( ', true)', "Transpose"), -]; - enum ErrorState { // Do not touch the state of the error NoModify, diff --git a/rpn_rs_gui/src/app/buttons.rs b/rpn_rs_gui/src/app/buttons.rs new file mode 100644 index 0000000..7adaf46 --- /dev/null +++ b/rpn_rs_gui/src/app/buttons.rs @@ -0,0 +1,108 @@ +use rpn_rs::calc::Calculator; + +pub struct CalculatorButton { + pub value: char, + pub help: Option<&'static str>, + pub enabled: bool, +} + +impl CalculatorButton { + const fn new(value: char, help: Option<&'static str>, enabled: bool) -> Self { + Self { + value, + help, + enabled, + } + } +} + +pub(crate) const BUTTON_LAYOUT_SETTINGS: &[&[CalculatorButton]] = &[ + &[CalculatorButton::new('q', Some("Exit"), true)], + &[ + CalculatorButton::new('d', Some("Degrees"), true), + CalculatorButton::new('r', Some("Radians"), true), + CalculatorButton::new('g', Some("Grads"), true), + ], + &[ + CalculatorButton::new('_', Some("Default"), true), + CalculatorButton::new(',', Some("Comma separated"), true), + CalculatorButton::new(' ', Some("Space separated"), true), + ], + &[ + CalculatorButton::new('s', Some("Scientific"), true), + CalculatorButton::new('S', Some("Scientific (stack precision)"), true), + ], + &[ + CalculatorButton::new('e', Some("Engineering"), true), + CalculatorButton::new('E', Some("Engineering (stack precision)"), true), + ], + &[ + CalculatorButton::new('f', Some("Fixed"), true), + CalculatorButton::new('F', Some("Fixed (stack precision)"), true), + ], + // CalculatorButton::new('w', Some("Do not write settings and stack on quit (default)"), true), + // CalculatorButton::new('W', Some("Write stack and settings on quit"), true), + // CalculatorButton::new('L', Some("Left align"), true), + // CalculatorButton::new('R', Some("Right align"), true), +]; + +pub(crate) const BUTTON_LAYOUT: &[&[CalculatorButton]] = &[ + &[ + // CalculatorButton::new('s', "Sin", true), + CalculatorButton::new('\\', Some("Drop"), true), + // TODO: Settings buttons + CalculatorButton::new('@', Some("Settings"), true), + // CalculatorButton::new(' ', Some("Enter"), true), + CalculatorButton::new('>', Some("Swap"), true), + CalculatorButton::new('$', Some("Backspace"), true), + ], + &[ + // CalculatorButton::new('|', "AbsoluteValue", true), + CalculatorButton::new('^', Some("Pow"), true), + CalculatorButton::new('U', Some("Redo"), true), + CalculatorButton::new('u', Some("Undo"), true), + CalculatorButton::new('L', Some("Ln"), true), + // CalculatorButton::new('l', Some("Log"), true), + ], + &[ + // CalculatorButton::new('c', "Cos", true), + CalculatorButton::new('v', Some("Sqrt"), true), + // CalculatorButton::new('%', Some("Modulo"), true), + CalculatorButton::new('n', Some("Negate"), true), + CalculatorButton::new('i', Some("Inverse"), true), + CalculatorButton::new('/', Some("Divide"), true), + ], + &[ + // CalculatorButton::new('t', "Tan", true), + CalculatorButton::new('7', None, true), + CalculatorButton::new('8', None, true), + CalculatorButton::new('9', None, true), + CalculatorButton::new('*', Some("Multiply"), true), + ], + &[ + // CalculatorButton::new('S', "ASin", true), + CalculatorButton::new('4', None, true), + CalculatorButton::new('5', None, true), + CalculatorButton::new('6', None, true), + CalculatorButton::new('-', Some("Subtract"), true), + ], + &[ + // CalculatorButton::new('C', "ACos", true), + CalculatorButton::new('1', None, true), + CalculatorButton::new('2', None, true), + CalculatorButton::new('3', None, true), + CalculatorButton::new('+', Some("Add"), true), + ], + &[ + // CalculatorButton::new('T', "ATan", true), + CalculatorButton::new('0', None, true), + CalculatorButton::new('.', Some("Decimal"), true), + CalculatorButton::new(' ', Some("Return"), true), + CalculatorButton::new(' ', Some("Return"), true), + ], + // CalculatorButton::new ( '?', "IntegerDivide", true), + // CalculatorButton::new ( 'V', "BuildVector", true), + // CalculatorButton::new ( 'M', "BuildMatrix", true), + // CalculatorButton::new ( '_', "Deconstruct", true), + // CalculatorButton::new ( ', true)', "Transpose"), +]; diff --git a/rpn_rs_gui/src/main.rs b/rpn_rs_gui/src/main.rs index c1a7239..79fe911 100644 --- a/rpn_rs_gui/src/main.rs +++ b/rpn_rs_gui/src/main.rs @@ -27,12 +27,13 @@ fn main() { let web_options = eframe::WebOptions::default(); wasm_bindgen_futures::spawn_local(async { - eframe::start_web( - "the_canvas_id", // hardcode it - web_options, - Box::new(|cc| Box::new(rpn_rs_gui::TemplateApp::new(cc))), - ) - .await - .expect("failed to start eframe"); + eframe::WebRunner::new() + .start( + "the_canvas_id", // hardcode it + web_options, + Box::new(|cc| Box::new(rpn_rs_gui::TemplateApp::new(cc))), + ) + .await + .expect("failed to start eframe"); }); }