gui: node info content, new icons, remove default fonts, optimize imports, add translations

This commit is contained in:
ardocrat 2023-05-17 00:36:59 +03:00
parent dbed320dbc
commit d35729491b
22 changed files with 2113 additions and 510 deletions

411
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "ab_glyph"
version = "0.2.20"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe21446ad43aa56417a767f3e2f3d7c4ca522904de1dd640529a76e9c5c3b33c"
checksum = "5110f1c78cf582855d895ecd0746b653db010cec6d9f5575293f27934d980a39"
dependencies = [
"ab_glyph_rasterizer",
"owned_ttf_parser",
@ -125,6 +125,15 @@ dependencies = [
"memchr",
]
[[package]]
name = "aho-corasick"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
dependencies = [
"memchr",
]
[[package]]
name = "android-activity"
version = "0.4.1"
@ -187,9 +196,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.70"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "arboard"
@ -263,9 +272,9 @@ dependencies = [
[[package]]
name = "atomic_refcell"
version = "0.1.9"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8"
checksum = "79d6dc922a2792b006573f60b2648076355daeae5ce9cb59507e5908c9625d31"
[[package]]
name = "atty"
@ -341,8 +350,8 @@ dependencies = [
"lazycell",
"log",
"peeking_take_while",
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"regex",
"rustc-hash",
"shlex",
@ -442,9 +451,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.12.0"
version = "3.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b"
[[package]]
name = "bytemuck"
@ -461,9 +470,9 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -530,7 +539,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom 5.1.2",
"nom 5.1.3",
]
[[package]]
@ -759,9 +768,9 @@ dependencies = [
[[package]]
name = "cpufeatures"
version = "0.2.6"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181"
checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58"
dependencies = [
"libc",
]
@ -845,50 +854,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "cxx"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxx-build"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b"
dependencies = [
"cc",
"codespan-reporting",
"once_cell",
"proc-macro2 1.0.56",
"quote 1.0.26",
"scratch",
"syn 2.0.14",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb"
[[package]]
name = "cxxbridge-macro"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
]
[[package]]
name = "d3d12"
version = "0.5.0"
@ -902,9 +867,9 @@ dependencies = [
[[package]]
name = "darling"
version = "0.14.4"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944"
dependencies = [
"darling_core",
"darling_macro",
@ -912,26 +877,26 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.14.4"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb"
dependencies = [
"fnv",
"ident_case",
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 1.0.109",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
name = "darling_macro"
version = "0.14.4"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a"
dependencies = [
"darling_core",
"quote 1.0.26",
"syn 1.0.109",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -1179,8 +1144,8 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a4da76b3b6116d758c7ba93f7ec6a35d2e2cf24feda76c6e38a375f4d5c59f2"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 1.0.109",
]
@ -1195,23 +1160,23 @@ dependencies = [
[[package]]
name = "enumset"
version = "1.0.12"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753"
checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb"
dependencies = [
"enumset_derive",
]
[[package]]
name = "enumset_derive"
version = "0.6.1"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0"
checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af"
dependencies = [
"darling",
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 1.0.109",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -1313,8 +1278,8 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 1.0.109",
"synstructure",
]
@ -1339,12 +1304,12 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.25"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
dependencies = [
"crc32fast",
"miniz_oxide 0.6.2",
"miniz_oxide 0.7.1",
]
[[package]]
@ -1378,9 +1343,9 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -1518,9 +1483,9 @@ version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -1641,7 +1606,7 @@ version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
dependencies = [
"aho-corasick",
"aho-corasick 0.7.20",
"bstr",
"fnv",
"log",
@ -1662,9 +1627,9 @@ dependencies = [
[[package]]
name = "glutin"
version = "0.30.7"
version = "0.30.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f89bab9ec7715de13d5d5402238e66f48e3a5ae636ebb45aba4013c962e2ff15"
checksum = "62f9b771a65f0a1e3ddb6aa16f867d87dc73c922411c255e6c4ab7f6d45c7327"
dependencies = [
"bitflags 1.3.2",
"cfg_aliases",
@ -1685,9 +1650,9 @@ dependencies = [
[[package]]
name = "glutin_egl_sys"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5aaf0abb5c4148685b33101ae326a207946b4d3764d6cdc79f8316cdaa8367d"
checksum = "1b3bcbddc51573b977fc6dca5d93867e4f29682cdbaf5d13e48f4fa4346d4d87"
dependencies = [
"gl_generator",
"windows-sys 0.45.0",
@ -1714,9 +1679,9 @@ dependencies = [
[[package]]
name = "gpu-alloc"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fc59e5f710e310e76e6707f86c561dd646f69a8876da9131703b2f717de818d"
checksum = "22beaafc29b38204457ea030f6fb7a84c9e4dd1b86e311ba0542533453d87f62"
dependencies = [
"bitflags 1.3.2",
"gpu-alloc-types",
@ -1752,7 +1717,7 @@ dependencies = [
]
[[package]]
name = "grin-android"
name = "grim"
version = "0.1.0"
dependencies = [
"android_logger",
@ -2236,12 +2201,11 @@ dependencies = [
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cxx",
"cxx-build",
"cc",
]
[[package]]
@ -2385,9 +2349,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.61"
version = "0.3.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5"
dependencies = [
"wasm-bindgen",
]
@ -2455,9 +2419,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.141"
version = "0.2.144"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
[[package]]
name = "libgit2-sys"
@ -2493,9 +2457,9 @@ dependencies = [
[[package]]
name = "libz-sys"
version = "1.1.8"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db"
dependencies = [
"cc",
"libc",
@ -2503,15 +2467,6 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "link-cplusplus"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
dependencies = [
"cc",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@ -2520,9 +2475,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.3.1"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f"
checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f"
[[package]]
name = "lmdb-zero"
@ -2861,9 +2816,9 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "nom"
version = "5.1.2"
version = "5.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b"
dependencies = [
"memchr",
"version_check",
@ -2991,8 +2946,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
dependencies = [
"proc-macro-crate",
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 1.0.109",
]
@ -3096,18 +3051,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.25.2+1.1.1t"
version = "111.25.3+1.1.1t"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320708a054ad9b3bf314688b5db87cf4d6683d64cfc835e2337924ae62bf4431"
checksum = "924757a6a226bf60da5f7dd0311a34d2b52283dd82ddeb103208ddc66362f80c"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.85"
version = "0.9.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0"
checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e"
dependencies = [
"cc",
"libc",
@ -3127,9 +3082,9 @@ dependencies = [
[[package]]
name = "owned_ttf_parser"
version = "0.18.1"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e25e9fb15717794fae58ab55c26e044103aad13186fbb625893f9a3bbcc24228"
checksum = "706de7e2214113d63a8238d1910463cfce781129a6f263d13fdb09ff64355ba4"
dependencies = [
"ttf-parser",
]
@ -3225,22 +3180,22 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "pin-project"
version = "1.0.12"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.12"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 1.0.109",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -3263,9 +3218,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "png"
@ -3313,18 +3268,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.56"
version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
checksum = "c4ec6d5fe0b140acb27c9a0444118cf55bfbb4e0b259739429abb4521dd67c16"
dependencies = [
"unicode-ident",
]
[[package]]
name = "profiling"
version = "1.0.7"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df"
checksum = "332cd62e95873ea4f41f3dfd6bbbfc5b52aec892d7e8d534197c4720a0bbbab2"
[[package]]
name = "quick-error"
@ -3343,11 +3298,11 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.26"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500"
dependencies = [
"proc-macro2 1.0.56",
"proc-macro2 1.0.57",
]
[[package]]
@ -3542,20 +3497,20 @@ dependencies = [
[[package]]
name = "regex"
version = "1.7.3"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
dependencies = [
"aho-corasick",
"aho-corasick 1.0.1",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c"
[[package]]
name = "renderdoc-sys"
@ -3591,16 +3546,16 @@ dependencies = [
[[package]]
name = "rust-i18n"
version = "1.1.4"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3dcb86b090a450cb642b6a465f0e9a3d4be26bdb9d8795a2a49fb02601b370f"
checksum = "169fbf8f663e7bef4cddc3e0af0c350c4f8e8c1c40a1d92cdaa266865d2a749a"
dependencies = [
"anyhow",
"clap",
"glob",
"itertools",
"once_cell",
"quote 1.0.26",
"quote 1.0.27",
"regex",
"rust-i18n-extract",
"rust-i18n-macro",
@ -3617,8 +3572,8 @@ checksum = "ec44568e2cdf4bfb7a62381bbc6fcdf0a27c60cd503dfa12c59e6c17cf3177fa"
dependencies = [
"anyhow",
"ignore",
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"regex",
"rust-i18n-support",
"serde",
@ -3629,14 +3584,14 @@ dependencies = [
[[package]]
name = "rust-i18n-macro"
version = "1.1.0"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e7e3e8f27d472822c5cf092a22631ebc667d9f8dc89dfc50ef4e87f4ebdf92f"
checksum = "17107229a36fc4d21a868b4d5dce9f85ea7cffacb5d210a15e57c85ab7935703"
dependencies = [
"glob",
"once_cell",
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"rust-i18n-support",
"serde",
"serde_json",
@ -3652,7 +3607,7 @@ checksum = "9e6bbf2d058c3558bef952564ceb9afcb19631cde22b47dc44f436e62ecfb916"
dependencies = [
"glob",
"once_cell",
"proc-macro2 1.0.56",
"proc-macro2 1.0.57",
"serde",
"serde_json",
"serde_yaml",
@ -3660,9 +3615,9 @@ dependencies = [
[[package]]
name = "rustc-demangle"
version = "0.1.22"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc-hash"
@ -3678,9 +3633,9 @@ checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
[[package]]
name = "rustix"
version = "0.37.11"
version = "0.37.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77"
checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
dependencies = [
"bitflags 1.3.2",
"errno",
@ -3760,12 +3715,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scratch"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
[[package]]
name = "sct"
version = "0.6.1"
@ -3822,9 +3771,9 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.160"
version = "1.0.163"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2"
dependencies = [
"serde_derive",
]
@ -3841,20 +3790,20 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.160"
version = "1.0.163"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
name = "serde_json"
version = "1.0.95"
version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744"
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
dependencies = [
"itoa 1.0.6",
"ryu",
@ -4061,19 +4010,19 @@ version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.14"
version = "2.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf316d5356ed6847742d036f8a39c3b8435cac10bd528a4bd461928a6ab34d5"
checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"unicode-ident",
]
@ -4083,8 +4032,8 @@ version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 1.0.109",
"unicode-xid 0.2.4",
]
@ -4145,9 +4094,9 @@ version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]
@ -4262,8 +4211,8 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 1.0.109",
]
@ -4353,9 +4302,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.30"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
]
@ -4384,9 +4333,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "ttf-parser"
version = "0.18.1"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633"
checksum = "44dcf002ae3b32cd25400d6df128c5babec3927cd1eb7ce813cfff20eb6c3746"
[[package]]
name = "type-map"
@ -4541,9 +4490,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.84"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@ -4551,24 +4500,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.84"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 1.0.109",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.34"
version = "0.4.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
@ -4578,32 +4527,32 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.84"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434"
dependencies = [
"quote 1.0.26",
"quote 1.0.27",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.84"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 1.0.109",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.84"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb"
[[package]]
name = "wayland-client"
@ -4662,8 +4611,8 @@ version = "0.29.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"xml-rs",
]
@ -4692,9 +4641,9 @@ dependencies = [
[[package]]
name = "web-sys"
version = "0.3.61"
version = "0.3.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -4702,9 +4651,9 @@ dependencies = [
[[package]]
name = "webbrowser"
version = "0.8.8"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579cc485bd5ce5bfa0d738e4921dd0b956eca9800be1fd2e5257ebe95bc4617e"
checksum = "b692165700260bbd40fbc5ff23766c03e339fbaca907aeea5cb77bf0a553ca83"
dependencies = [
"core-foundation 0.9.3",
"dirs 4.0.0",
@ -4913,8 +4862,8 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9539b6bd3eadbd9de66c9666b22d802b833da7e996bc06896142e09854a61767"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 1.0.109",
]
@ -5142,9 +5091,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.4.1"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28"
checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699"
dependencies = [
"memchr",
]
@ -5212,9 +5161,9 @@ dependencies = [
[[package]]
name = "xml-rs"
version = "0.8.4"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
checksum = "dc95a04ea24f543cd9be5aab44f963fa35589c99e18415c38fb2b17e133bf8d2"
[[package]]
name = "yaml-rust"
@ -5240,9 +5189,9 @@ version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2 1.0.56",
"quote 1.0.26",
"syn 2.0.14",
"proc-macro2 1.0.57",
"quote 1.0.27",
"syn 2.0.16",
]
[[package]]

View file

@ -2,7 +2,7 @@
#members = ["wallet", "config"]
[package]
name = "grin-android"
name = "grim"
version = "0.1.0"
edition = "2021"
build = "src/build/build.rs"
@ -32,7 +32,7 @@ openssl-sys = { version = "0.9.82", features = ["vendored"] }
## ui
pollster = "0.3.0"
wgpu = "0.14.0"
egui = "0.20.1"
egui = { version = "0.20.1", default-features = false }
egui_extras = { version = "0.20.0" }
eframe = { version = "0.20.1", features = [ "wgpu" ] }
egui_demo_lib = "0.20.0"
@ -45,7 +45,7 @@ dirs = "2.0"
once_cell = "1.10.0"
rust-i18n = "1.1.4"
sys-locale = "0.3.0"
chrono = "0.4.11"
chrono = "0.4.23"
[patch.crates-io]
winit = { git = "https://github.com/rib/winit", branch = "android-activity" }

Binary file not shown.

BIN
fonts/phosphor.ttf Normal file

Binary file not shown.

View file

@ -1,4 +1,33 @@
accounts: Accounts
node: Node
integrated_node: Integrated Node
metrics: Metrics
settings: Settings
server_restarting: Server is restarting
server_down: Server is down
header: Header
block: Block
hash: Hash
height: Height
difficulty: Difficulty
time_utc: Time (UTC)
transactions: Transactions
main_pool: Main pool
stem_pool: Stem pool
data: Data
size: Size (GB)
peers: Peers
sync_status:
initial: Server is starting
no_sync: Server is running
awaiting_peers: Waiting for peers
header_sync: Downloading headers
header_sync_percent: 'Downloading headers: %{percent}%'
tx_hashset_download: Downloading chain state
tx_hashset_download_percent: 'Downloading chain state: %{percent}%'
tx_hashset_setup: Preparing state for validation
tx_hashset_range_proofs_validation: 'Validating state - range proofs: %{percent}%'
tx_hashset_kernels_validation: 'Validating state - kernels: %{percent}%'
tx_hashset_save: Finalizing chain state
body_sync: Downloading blocks
body_sync_percent: 'Downloading blocks: %{percent}%'
shutdown: Shutting down

View file

@ -1 +1,33 @@
accounts: Аккаунты
integrated_node: Встроенный узел
metrics: Метрики
settings: Настройки
server_restarting: Сервер перезапускается
server_down: Сервер выключен
header: Заголовок
block: Блок
hash: Хэш
height: Высота
difficulty: Сложность
time_utc: Время (UTC)
transactions: Транзакции
main_pool: Основной пул
stem_pool: Stem пул
data: Данные
size: Размер (ГБ)
peers: Пиры
sync_status:
initial: Запуск сервера
no_sync: Сервер запущен
awaiting_peers: Ожидание пиров
header_sync: Загрузка заголовков
header_sync_percent: 'Загрузка заголовков: %{percent}%'
tx_hashset_download: Загрузка состояния цепи
tx_hashset_download_percent: 'Загрузка состояния цепи: %{percent}%'
tx_hashset_setup: Подготовка состояния для проверки
tx_hashset_range_proofs_validation: 'Проверка доказательств: %{percent}%'
tx_hashset_kernels_validation: 'Проверка ядер: %{percent}%'
tx_hashset_save: Сохранение состояния цепи
body_sync: Загрузка блоков
body_sync_percent: 'Загрузка блоков: %{percent}%'
shutdown: Выключение

View file

@ -13,8 +13,7 @@
// limitations under the License.
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::path::Path;
fn main() {
// build and versioning information

View file

@ -13,7 +13,7 @@
// limitations under the License.
use eframe::{AppCreator, NativeOptions, Renderer, Theme};
use log::LevelFilter::{Debug, Info, Trace, Warn};
use log::LevelFilter::Info;
#[cfg(target_os = "android")]
use winit::platform::android::activity::AndroidApp;

View file

@ -12,15 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::cmp::min;
use eframe::Frame;
use egui::{Color32, Context, Stroke};
use eframe::epaint::Stroke;
use egui::{Context, Frame};
use egui::style::Margin;
use crate::gui::{COLOR_LIGHT, COLOR_YELLOW};
use crate::gui::colors::COLOR_LIGHT;
use crate::gui::platform::PlatformCallbacks;
use crate::gui::screens::{Root, Screen};
use crate::gui::screens::Root;
pub struct PlatformApp<Platform> {
pub(crate) app: App,
@ -40,10 +38,10 @@ impl Default for App {
}
impl App {
pub fn ui(&mut self, ctx: &Context, frame: &mut Frame, cb: &dyn PlatformCallbacks) {
pub fn ui(&mut self, ctx: &Context, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
let Self { root } = self;
egui::CentralPanel::default()
.frame(egui::Frame {
.frame(Frame {
inner_margin: Margin::same(0.0),
outer_margin: Margin::same(0.0),
stroke: Stroke::NONE,
@ -56,11 +54,11 @@ impl App {
}
}
pub fn is_dual_panel_mode(frame: &mut Frame) -> bool {
pub fn is_dual_panel_mode(frame: &mut eframe::Frame) -> bool {
is_landscape(frame) && frame.info().window_info.size.x > 400.0
}
pub fn is_landscape(frame: &mut Frame) -> bool {
pub fn is_landscape(frame: &mut eframe::Frame) -> bool {
return frame.info().window_info.size.x > frame.info().window_info.size.y
}

View file

@ -12,3 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pub const COLOR_YELLOW: egui::Color32 = egui::Color32::from_rgb(254, 241, 2);
pub const COLOR_LIGHT: egui::Color32 = egui::Color32::from_gray(240);
pub const COLOR_DARK: egui::Color32 = egui::Color32::from_gray(60);
pub const COLOR_GRAY: egui::Color32 = egui::Color32::from_gray(120);

1273
src/gui/icons.rs Normal file

File diff suppressed because it is too large Load diff

View file

@ -19,18 +19,8 @@ pub use app::PlatformApp;
pub mod platform;
pub mod screens;
pub mod views;
pub mod icons;
pub mod colors;
mod app;
pub const COLOR_YELLOW: egui::Color32 = egui::Color32::from_rgb(254, 241, 2);
pub const COLOR_LIGHT: egui::Color32 = egui::Color32::from_gray(240);
pub const COLOR_DARK: egui::Color32 = egui::Color32::from_gray(60);
// Material icons chars
pub const SYM_ARROW_BACK: &str = "";
pub const SYM_ACCOUNTS: &str = "";
pub const SYM_NETWORK: &str = "";
pub const SYM_SETTINGS: &str = "";
pub const SYM_TUNING: &str = "";
pub const SYM_METRICS: &str = "";

View file

@ -96,26 +96,13 @@ impl PlatformApp<Android> {
let mut fonts = egui::FontDefinitions::default();
// Tweak emoji icons to look nice against main font y-offset
// fonts.font_data.insert(
// "emoji-icon-font".to_owned(),
// egui::FontData {
// font: fonts.font_data.get("emoji-icon-font").unwrap().clone().font,
// index: 0,
// tweak: egui::FontTweak {
// scale: 0.88,
// y_offset_factor: 0.26,
// y_offset: 0.0,
// },
// });
fonts.font_data.insert(
"material".to_owned(),
"phosphor".to_owned(),
egui::FontData::from_static(include_bytes!(
"../../../../fonts/material.otf"
"../../../../fonts/phosphor.ttf"
)).tweak(egui::FontTweak {
scale: 1.0,
y_offset_factor: 0.16,
y_offset_factor: 0.14,
y_offset: 0.0
}),
);
@ -123,7 +110,7 @@ impl PlatformApp<Android> {
.families
.entry(Proportional)
.or_default()
.insert(0, "material".to_owned());
.insert(0, "phosphor".to_owned());
fonts.font_data.insert(
"noto".to_owned(),
@ -141,8 +128,6 @@ impl PlatformApp<Android> {
.or_default()
.insert(0, "noto".to_owned());
ctx.set_fonts(fonts);
use egui::FontId;
@ -151,7 +136,6 @@ impl PlatformApp<Android> {
let mut style = (*ctx.style()).clone();
style.text_styles = [
(Heading, FontId::new(20.0, Proportional)),
(Name("icon".into()), FontId::new(24.0, Proportional)),
(Body, FontId::new(16.0, Proportional)),
(Button, FontId::new(18.0, Proportional)),
(Small, FontId::new(12.0, Proportional)),

View file

@ -12,28 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::ops::{Deref, DerefMut};
use eframe::epaint::{Color32, Stroke};
use egui::Frame;
use egui::{Frame, Widget};
use crate::gui::{SYM_ARROW_BACK, SYM_NETWORK, SYM_SETTINGS};
use crate::gui::app::is_dual_panel_mode;
use crate::gui::icons::{ARROW_CIRCLE_LEFT, GEAR_SIX, GLOBE};
use crate::gui::platform::PlatformCallbacks;
use crate::gui::screens::{Navigator, Screen, ScreenId};
use crate::gui::views::{TitlePanel, TitlePanelAction};
use crate::gui::views::{DEFAULT_STROKE, TitlePanel, TitlePanelAction};
pub struct Accounts {
title: String,
}
impl Default for Accounts {
fn default() -> Self {
Self {
title: t!("accounts"),
}
}
}
#[derive(Default)]
pub struct Accounts {}
impl Screen for Accounts {
fn id(&self) -> ScreenId {
@ -45,36 +33,33 @@ impl Screen for Accounts {
frame: &mut eframe::Frame,
nav: &mut Navigator,
cb: &dyn PlatformCallbacks) {
let Self { title } = self;
let mut panel: TitlePanel = TitlePanel::default()
.title(title)
let mut panel: TitlePanel = TitlePanel::new(nav)
.title(t!("accounts"))
.right_action(TitlePanelAction {
icon: SYM_SETTINGS.into(),
icon: GEAR_SIX.into(),
on_click: Box::new(|nav| {
//TODO: open settings
}),
})
.with_navigator(nav);
});
if !is_dual_panel_mode(frame) {
panel = panel.left_action(TitlePanelAction {
icon: SYM_NETWORK.into(),
icon: GLOBE.into(),
on_click: Box::new(|nav|{
nav.as_mut().unwrap().toggle_left_panel();
nav.toggle_left_panel();
}),
});
}
panel.ui(ui);
egui::CentralPanel::default().frame(Frame {
stroke: Stroke::new(1.0, Color32::from_gray(190)),
stroke: DEFAULT_STROKE,
.. Default::default()
}).show_inside(ui, |ui| {
ui.label(format!("{}Here we go 10000 ツ", SYM_ARROW_BACK));
ui.label(format!("{}Here we go 10000 ツ", ARROW_CIRCLE_LEFT));
if ui.button("TEST").clicked() {
nav.to(ScreenId::Account)
};
if ui.button(format!("{}BACK ", SYM_ARROW_BACK)).clicked() {
if ui.button(format!("{}BACK ", ARROW_CIRCLE_LEFT)).clicked() {
nav.to(ScreenId::Account)
};
});

View file

@ -17,9 +17,7 @@ pub use accounts::Accounts;
pub use navigator::Navigator;
pub use root::Root;
use crate::gui::App;
use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::TitlePanelAction;
mod navigator;
mod root;
@ -28,7 +26,6 @@ mod account;
#[derive(Ord, Eq, PartialOrd, PartialEq)]
pub enum ScreenId {
Root,
Accounts,
Account,
}

View file

@ -14,10 +14,6 @@
use std::cmp::min;
use eframe::epaint::{Color32, Shadow, Stroke};
use egui::style::Margin;
use crate::gui::{App, COLOR_YELLOW};
use crate::gui::app::is_dual_panel_mode;
use crate::gui::platform::PlatformCallbacks;
use crate::gui::screens::{Account, Accounts, Navigator, Screen, ScreenId};
@ -43,10 +39,6 @@ impl Default for Root {
}
impl Root {
fn id(&self) -> ScreenId {
ScreenId::Root
}
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
let is_network_panel_open = self.navigator.left_panel_open || is_dual_panel_mode(frame);

59
src/gui/views/common.rs Normal file
View file

@ -0,0 +1,59 @@
// Copyright 2023 The Grim Developers
//
// 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.
use eframe::epaint::{Color32, Stroke};
use egui::{RichText, Sense, Widget};
use crate::gui::colors::{COLOR_DARK, COLOR_LIGHT};
use crate::gui::views::DEFAULT_STROKE;
pub fn title_button(ui: &mut egui::Ui, icon: &str, action: impl FnOnce()) {
let b = egui::widgets::Button::new(
RichText::new(icon.to_string()).size(24.0).color(COLOR_DARK)
).fill(Color32::TRANSPARENT)
.ui(ui).interact(Sense::click_and_drag());
// Click optimization for touch screens
if b.drag_released() || b.clicked() {
(action)();
};
}
pub fn tab_button(ui: &mut egui::Ui, icon: &str, active: bool, mut action: impl FnMut()) {
let stroke = match active {
true => { Stroke::NONE }
false => { DEFAULT_STROKE }
};
let color = match active {
true => { COLOR_LIGHT }
false => { Color32::WHITE }
};
let b = egui::widgets::Button::new(
RichText::new(icon.to_string()).size(24.0).color(COLOR_DARK)
).min_size(ui.available_size_before_wrap())
.stroke(stroke)
.fill(color)
.ui(ui).interact(Sense::click_and_drag());
// Click optimization for touch screens
if b.drag_released() || b.clicked() {
(action)();
};
}
pub fn sub_title(ui: &mut egui::Ui, text: String, color: Color32) {
ui.label(RichText::new(text).size(17.0).color(color));
}

View file

@ -12,14 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
pub mod buttons;
use eframe::epaint::{Color32, Stroke};
mod title_panel;
pub use crate::gui::views::network::Network;
pub use crate::gui::views::title_panel::{TitlePanel, TitlePanelAction, TitlePanelActions};
mod network;
pub use crate::gui::views::network::Network;
pub mod common;
mod title_panel;
mod network;
mod network_node;
mod network_tuning;
mod network_metrics;
@ -28,3 +30,6 @@ pub trait NetworkTab {
fn ui(&mut self, ui: &mut egui::Ui, node: &mut crate::node::Node);
fn name(&self) -> &String;
}
pub const DEFAULT_STROKE: Stroke = Stroke { width: 1.0, color: Color32::from_gray(190) };

View file

@ -12,40 +12,39 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::borrow::Cow;
use std::collections::hash_map::DefaultHasher;
use std::sync::atomic::Ordering;
use std::time::Duration;
use chrono::Utc;
use eframe::epaint::{Color32, FontId, Stroke};
use eframe::emath::lerp;
use eframe::epaint::{Color32, FontId, Rgba, Stroke};
use eframe::epaint::text::{LayoutJob, TextFormat, TextWrapping};
use egui::{Response, RichText, Sense, Spinner, Widget};
use egui::RichText;
use egui::style::Margin;
use egui_extras::{Size, StripBuilder};
use grin_chain::SyncStatus;
use grin_core::global::ChainTypes;
use grin_servers::ServerStats;
use crate::gui::app::is_dual_panel_mode;
use crate::gui::colors::{COLOR_DARK, COLOR_YELLOW};
use crate::gui::icons::{CARDHOLDER, DATABASE, DOTS_THREE_OUTLINE_VERTICAL, FACTORY, FADERS, GAUGE};
use crate::gui::platform::PlatformCallbacks;
use crate::gui::screens::Navigator;
use crate::gui::{COLOR_DARK, COLOR_LIGHT, COLOR_YELLOW, SYM_ACCOUNTS, SYM_METRICS, SYM_NETWORK};
use crate::gui::views::{NetworkTab, TitlePanel, TitlePanelAction};
use crate::gui::views::{DEFAULT_STROKE, NetworkTab};
use crate::gui::views::common::{tab_button, title_button};
use crate::gui::views::network_node::NetworkNode;
use crate::node;
use crate::node::Node;
#[derive(PartialEq)]
enum Mode {
Node,
// Miner,
Metrics,
Miner,
Tuning
}
pub struct Network {
current_mode: Mode,
node: Node,
current_mode: Mode,
node_view: NetworkNode,
}
@ -80,17 +79,9 @@ impl Network {
self.draw_title(ui, frame, nav);
});
egui::CentralPanel::default().frame(egui::Frame {
stroke: Stroke::new(1.0, Color32::from_gray(190)),
fill: Color32::WHITE,
.. Default::default()
}).show_inside(ui, |ui| {
self.draw_tab_content(ui);
});
egui::TopBottomPanel::bottom("network_tabs")
.frame(egui::Frame {
stroke: Stroke::new(1.0, Color32::from_gray(190)),
outer_margin: Margin::same(6.0),
.. Default::default()
})
.resizable(false)
@ -98,19 +89,41 @@ impl Network {
self.draw_tabs(ui);
});
ui.ctx().request_repaint_after(Duration::from_millis(1000));
egui::CentralPanel::default().frame(egui::Frame {
stroke: DEFAULT_STROKE,
inner_margin: Margin::same(4.0),
fill: Color32::WHITE,
.. Default::default()
}).show_inside(ui, |ui| {
self.draw_tab_content(ui);
});
}
fn draw_tabs(&self, ui: &mut egui::Ui) {
ui.vertical_centered(|ui| {
ui.columns(3, |columns| {
columns[0].horizontal_wrapped(|ui| {
fn draw_tabs(&mut self, ui: &mut egui::Ui) {
ui.columns(4, |columns| {
columns[0].vertical_centered(|ui| {
tab_button(ui, DATABASE, self.current_mode == Mode::Node, || {
self.current_mode = Mode::Node;
});
});
columns[1].vertical_centered(|ui| {
});
columns[2].horizontal_wrapped(|ui| {
tab_button(ui, GAUGE, self.current_mode == Mode::Metrics, || {
self.current_mode = Mode::Metrics;
});
});
columns[2].vertical_centered(|ui| {
tab_button(ui, FACTORY, self.current_mode == Mode::Miner, || {
self.current_mode = Mode::Miner;
});
});
columns[3].vertical_centered(|ui| {
tab_button(ui, FADERS, self.current_mode == Mode::Tuning, || {
self.current_mode = Mode::Tuning;
});
});
});
}
@ -121,6 +134,7 @@ impl Network {
}
Mode::Metrics => {}
Mode::Tuning => {}
Mode::Miner => {}
}
}
@ -137,22 +151,22 @@ impl Network {
.size(Size::remainder())
.size(Size::exact(52.0))
.horizontal(|mut strip| {
strip.empty();
strip.cell(|ui| {
ui.centered_and_justified(|ui| {
title_button(ui, DOTS_THREE_OUTLINE_VERTICAL, || {
//TODO: Actions for node
});
});
});
strip.strip(|builder| {
self.draw_title_text(builder);
});
strip.cell(|ui| {
if !is_dual_panel_mode(frame) {
ui.centered_and_justified(|ui| {
let b = egui::widgets::Button::new(
RichText::new(SYM_ACCOUNTS)
.size(24.0)
.color(COLOR_DARK)
).fill(Color32::TRANSPARENT)
.ui(ui).interact(Sense::click_and_drag());
if b.drag_released() || b.clicked() {
title_button(ui, CARDHOLDER, || {
nav.toggle_left_panel();
};
});
});
}
});
@ -161,9 +175,7 @@ impl Network {
});
}
fn draw_title_text(&self, mut builder: StripBuilder) {
let Self { node, ..} = self;
fn draw_title_text(&self, builder: StripBuilder) {
let title_text = match &self.current_mode {
Mode::Node => {
self.node_view.name()
@ -171,78 +183,107 @@ impl Network {
Mode::Metrics => {
self.node_view.name()
}
Mode::Miner => {
self.node_view.name()
}
Mode::Tuning => {
self.node_view.name()
}
};
let syncing = node.state.is_syncing();
let mut b = builder.size(Size::remainder());
if syncing {
b = b.size(Size::remainder());
}
b.vertical(|mut strip| {
builder
.size(Size::exact(19.0))
.size(Size::remainder())
.vertical(|mut strip| {
strip.cell(|ui| {
ui.centered_and_justified(|ui| {
ui.heading(title_text.to_uppercase());
ui.label(RichText::new(title_text.to_uppercase())
.size(19.0)
.color(COLOR_DARK));
});
});
if syncing {
strip.cell(|ui| {
ui.centered_and_justified(|ui| {
let status_text = if node.state.is_restarting() {
"Restarting".to_string()
// Select sync status text
let sync_status = self.node.state.get_sync_status();
let status_text = if self.node.state.is_restarting() {
t!("server_restarting")
} else {
let sync_status = node.state.get_sync_status();
get_sync_status_text(sync_status.unwrap()).to_string()
match sync_status {
None => {
t!("server_down")
}
Some(ss) => {
get_sync_status_text(ss).to_string()
}
}
};
// Setup text color animation based on sync status
let idle = match sync_status {
None => { !self.node.state.is_starting() }
Some(ss) => { ss == SyncStatus::NoSync }
};
let (dark, bright) = (0.3, 1.0);
let color_factor = if !idle {
lerp(dark..=bright, ui.input().time.cos().abs())
} else {
bright
};
// Repaint based on sync status
if idle {
ui.ctx().request_repaint_after(Duration::from_millis(600));
} else {
ui.ctx().request_repaint();
}
// Draw sync text
let mut job = LayoutJob::single_section(status_text, TextFormat {
font_id: FontId::proportional(15.0),
color: COLOR_DARK,
color: Color32::from(Rgba::from(COLOR_DARK) * color_factor as f32),
.. Default::default()
});
job.wrap = TextWrapping {
max_rows: 1,
break_anywhere: false,
overflow_character: Option::from('…'),
overflow_character: Option::from(''),
..Default::default()
};
ui.label(job);
});
});
}
});
}
}
fn get_sync_status_text(sync_status: SyncStatus) -> Cow<'static, str> {
fn get_sync_status_text(sync_status: SyncStatus) -> String {
match sync_status {
SyncStatus::Initial => Cow::Borrowed("Initializing"),
SyncStatus::NoSync => Cow::Borrowed("Running"),
SyncStatus::AwaitingPeers(_) => Cow::Borrowed("Waiting for peers"),
SyncStatus::Initial => t!("sync_status.initial"),
SyncStatus::NoSync => t!("sync_status.no_sync"),
SyncStatus::AwaitingPeers(_) => t!("sync_status.awaiting_peers"),
SyncStatus::HeaderSync {
sync_head,
highest_height,
..
} => {
if highest_height == 0 {
Cow::Borrowed("Downloading headers")
t!("sync_status.header_sync")
} else {
let percent = sync_head.height * 100 / highest_height;
Cow::Owned(format!("Downloading headers: {}%", percent))
t!("sync_status.header_sync_percent", "percent" => percent)
}
}
SyncStatus::TxHashsetDownload(stat) => {
if stat.total_size > 0 {
let percent = stat.downloaded_size * 100 / stat.total_size;
Cow::Owned(format!("Downloading chain state: {}%", percent))
t!("sync_status.tx_hashset_download_percent", "percent" => percent)
} else {
Cow::Borrowed("Downloading chain state")
t!("sync_status.tx_hashset_download")
}
}
SyncStatus::TxHashsetSetup => {
Cow::Borrowed("Preparing state for validation")
t!("sync_status.tx_hashset_setup")
}
SyncStatus::TxHashsetRangeProofsValidation {
rproofs,
@ -253,7 +294,7 @@ fn get_sync_status_text(sync_status: SyncStatus) -> Cow<'static, str> {
} else {
0
};
Cow::Owned(format!("Validating state - range proofs: {}%", r_percent))
t!("sync_status.tx_hashset_range_proofs_validation", "percent" => r_percent)
}
SyncStatus::TxHashsetKernelsValidation {
kernels,
@ -264,28 +305,23 @@ fn get_sync_status_text(sync_status: SyncStatus) -> Cow<'static, str> {
} else {
0
};
Cow::Owned(format!("Validating state - kernels: {}%", k_percent))
t!("sync_status.tx_hashset_kernels_validation", "percent" => k_percent)
}
SyncStatus::TxHashsetSave => {
Cow::Borrowed("Finalizing chain state")
}
SyncStatus::TxHashsetDone => {
Cow::Borrowed("Finalized chain state")
SyncStatus::TxHashsetSave | SyncStatus::TxHashsetDone => {
t!("sync_status.tx_hashset_save")
}
SyncStatus::BodySync {
current_height,
highest_height,
} => {
if highest_height == 0 {
Cow::Borrowed("Downloading blocks data")
t!("sync_status.body_sync")
} else {
Cow::Owned(format!(
"Downloading blocks: {}%",
current_height * 100 / highest_height
))
let percent = current_height * 100 / highest_height;
t!("sync_status.body_sync_percent", "percent" => percent)
}
}
SyncStatus::Shutdown => Cow::Borrowed("Shutting down"),
SyncStatus::Shutdown => t!("sync_status.shutdown"),
}
}

View file

@ -11,3 +11,29 @@
// 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.
use egui::Ui;
use crate::gui::views::NetworkTab;
use crate::node::Node;
pub struct NetworkMetrics {
title: String
}
impl Default for NetworkMetrics {
fn default() -> Self {
Self {
title: t!("metrics"),
}
}
}
impl NetworkTab for NetworkMetrics {
fn ui(&mut self, ui: &mut Ui, node: &mut Node) {
}
fn name(&self) -> &String {
&self.title
}
}

View file

@ -12,20 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::borrow::Cow;
use std::ptr::null;
use std::sync::mpsc;
use std::time::SystemTime;
use chrono::Utc;
use egui::{Ui, Widget};
use grin_chain::SyncStatus;
use grin_core::global::ChainTypes;
use grin_servers::ServerStats;
use chrono::{DateTime, Local, Offset, TimeZone, Utc};
use chrono::format::DelayedFormat;
use eframe::emath::Vec2;
use eframe::epaint::{FontId, Stroke};
use eframe::epaint::text::{LayoutJob, TextFormat, TextWrapping};
use egui::{Color32, RichText, Rounding, ScrollArea, Spinner, Widget};
use egui_extras::{Size, StripBuilder};
use grin_servers::common::stats::TxStats;
use grin_servers::PeerStats;
use crate::gui::views::NetworkTab;
use crate::gui::colors::{COLOR_DARK, COLOR_GRAY, COLOR_LIGHT, COLOR_YELLOW};
use crate::gui::icons::{AT, CUBE, DEVICES, DOWNLOAD_SIMPLE, FLOW_ARROW, HANDSHAKE, PACKAGE, PLUGS_CONNECTED, SHARE_NETWORK};
use crate::gui::views::{DEFAULT_STROKE, NetworkTab};
use crate::gui::views::common::sub_title;
use crate::node::Node;
pub struct NetworkNode {
title: String
}
@ -33,44 +37,294 @@ pub struct NetworkNode {
impl Default for NetworkNode {
fn default() -> Self {
Self {
title: t!("node"),
title: t!("integrated_node"),
}
}
}
impl NetworkTab for NetworkNode {
fn ui(&mut self, ui: &mut Ui, node: &mut Node) {
// ui.vertical_centered_justified(|ui| {
// let node_state = node.acquire_state();
// let stats = &node_state.stats;
// if stats.is_some() {
// ui.horizontal_wrapped(|ui| {
// let sync_status = stats.as_ref().unwrap().sync_status;
// ui.label(get_sync_progress_status(sync_status));
// ui.spinner();
// });
// } else {
// if node.stop_state.is_stopped() {
// ui.label("Stopped");
// } else {
// ui.label(get_sync_progress_status(SyncStatus::Initial));
// }
// }
// });
if ui.button("stop").clicked() {
node.stop();
fn ui(&mut self, ui: &mut egui::Ui, node: &mut Node) {
let server_stats = node.state.get_stats();
if !server_stats.is_some() {
ui.centered_and_justified(|ui| {
Spinner::new().size(42.0).color(COLOR_GRAY).ui(ui);
});
return;
}
if ui.button("re-start").clicked() {
node.restart();
}
let stats = server_stats.as_ref().unwrap();
if ui.button("start").clicked() {
node.start(ChainTypes::Mainnet);
// Make scroll bar thinner
ui.style_mut().spacing.scroll_bar_width = 4.0;
ScrollArea::vertical()
.auto_shrink([false; 2])
.show(ui, |ui| {
// Disable item spacing
ui.style_mut().spacing.item_spacing = Vec2::new(0.0, 0.0);
// Show header stats
ui.vertical_centered_justified(|ui| {
sub_title(ui, format!("{} {}", FLOW_ARROW, t!("header")), COLOR_DARK);
});
ui.add_space(4.0);
ui.columns(2, |columns| {
columns[0].vertical_centered(|ui| {
draw_stat_box(ui,
stats.header_stats.last_block_h.to_string(),
t!("hash"),
StatBoxRounding::TopLeft);
});
columns[1].vertical_centered(|ui| {
draw_stat_box(ui,
stats.header_stats.height.to_string(),
t!("height"),
StatBoxRounding::TopRight);
});
});
ui.columns(2, |columns| {
columns[0].vertical_centered(|ui| {
draw_stat_box(ui,
stats.header_stats.total_difficulty.to_string(),
t!("difficulty"),
StatBoxRounding::BottomLeft);
});
columns[1].vertical_centered(|ui| {
let ts = stats.header_stats.latest_timestamp;
draw_stat_box(ui,
format!("{}", ts.format("%d/%m/%Y %H:%M")),
t!("time_utc"),
StatBoxRounding::BottomRight);
});
});
// Show block stats
ui.add_space(5.0);
ui.vertical_centered_justified(|ui| {
sub_title(ui, format!("{} {}", CUBE, t!("block")), COLOR_DARK);
});
ui.add_space(4.0);
ui.columns(2, |columns| {
columns[0].vertical_centered(|ui| {
draw_stat_box(ui,
stats.chain_stats.last_block_h.to_string(),
t!("hash"),
StatBoxRounding::TopLeft);
});
columns[1].vertical_centered(|ui| {
draw_stat_box(ui,
stats.chain_stats.height.to_string(),
t!("height"),
StatBoxRounding::TopRight);
});
});
ui.columns(2, |columns| {
columns[0].vertical_centered(|ui| {
draw_stat_box(ui,
stats.chain_stats.total_difficulty.to_string(),
t!("difficulty"),
StatBoxRounding::BottomLeft);
});
columns[1].vertical_centered(|ui| {
let ts = stats.chain_stats.latest_timestamp;
draw_stat_box(ui,
format!("{}", ts.format("%d/%m/%Y %H:%M")),
t!("time_utc"),
StatBoxRounding::BottomRight);
});
});
// Show data stats
ui.add_space(5.0);
ui.vertical_centered_justified(|ui| {
sub_title(ui, format!("{} {}", SHARE_NETWORK, t!("data")), COLOR_DARK);
});
ui.add_space(4.0);
ui.columns(2, |columns| {
columns[0].vertical_centered(|ui| {
let tx_stat = match &stats.tx_stats {
None => { "0 (0)".to_string() }
Some(tx) => {
format!("{} ({})", tx.tx_pool_size, tx.tx_pool_kernels)
}
};
draw_stat_box(ui, tx_stat, t!("main_pool"), StatBoxRounding::TopLeft);
});
columns[1].vertical_centered(|ui| {
let stem_tx_stat = match &stats.tx_stats {
None => { "0 (0)".to_string() }
Some(stx) => {
format!("{} ({})", stx.stem_pool_size, stx.stem_pool_kernels)
}
};
draw_stat_box(ui, stem_tx_stat, t!("stem_pool"), StatBoxRounding::TopRight);
});
});
ui.columns(2, |columns| {
columns[0].vertical_centered(|ui| {
draw_stat_box(ui,
stats.disk_usage_gb.to_string(),
t!("size"),
StatBoxRounding::BottomLeft);
});
columns[1].vertical_centered(|ui| {
let ts = stats.chain_stats.latest_timestamp;
draw_stat_box(ui,
stats.peer_count.to_string(),
t!("peers"),
StatBoxRounding::BottomRight);
});
});
// Show peers stats when available
if stats.peer_count > 0 {
ui.add_space(5.0);
ui.vertical_centered_justified(|ui| {
sub_title(ui, format!("{} {}", HANDSHAKE, t!("peers")), COLOR_DARK);
});
ui.add_space(4.0);
for (index, ps) in stats.peer_stats.iter().enumerate() {
let rounding = if index == 0 {
if stats.peer_count == 1 {
[true, true];
}
[true, false]
} else if index == &stats.peer_stats.len() - 1 {
[false, true]
} else {
[false, false]
};
ui.vertical_centered(|ui| {
draw_peer_stats(ui, ps, rounding);
});
}
}
});
}
fn name(&self) -> &String {
&self.title
}
}
fn draw_peer_stats(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(77.0);
ui.painter().rect(
rect,
Rounding {
nw: if rounding[0] { 8.0 } else { 0.0 },
ne: if rounding[0] { 8.0 } else { 0.0 },
sw: if rounding[1] { 8.0 } else { 0.0 },
se: if rounding[1] { 8.0 } else { 0.0 },
},
Color32::WHITE,
Stroke { width: 1.0, color: Color32::from_gray(230) }
);
ui.add_space(2.0);
ui.horizontal_top(|ui| {
ui.add_space(6.0);
ui.heading(RichText::new(PLUGS_CONNECTED)
.color(Color32::BLACK)
.size(18.0));
ui.add_space(6.0);
// Draw peer address
ui.heading(RichText::new(&peer.addr)
.color(Color32::BLACK)
.size(18.0));
});
ui.horizontal_top(|ui| {
ui.add_space(6.0);
ui.heading(RichText::new(PACKAGE)
.color(COLOR_DARK)
.size(16.0));
ui.add_space(6.0);
// Draw peer difficulty and height
ui.heading(RichText::new(peer.total_difficulty.to_string())
.color(COLOR_DARK)
.size(16.0));
ui.heading(RichText::new(AT).color(COLOR_DARK).size(16.0));
ui.heading(RichText::new(peer.height.to_string())
.color(COLOR_DARK)
.size(16.0));
});
ui.horizontal_top(|ui| {
ui.add_space(6.0);
ui.heading(RichText::new(DEVICES)
.color(COLOR_GRAY)
.size(16.0));
ui.add_space(6.0);
// Draw peer user-agent
ui.heading(RichText::new(&peer.user_agent)
.color(COLOR_GRAY)
.size(16.0));
});
ui.add_space(2.0);
}
#[derive(PartialEq)]
enum StatBoxRounding {
TopLeft, TopRight, BottomRight, BottomLeft
}
fn draw_stat_box(ui: &mut egui::Ui, value: String, label: String, rounding: StatBoxRounding) {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(46.0);
// Draw box background
ui.painter().rect(
rect,
Rounding {
nw: if rounding == StatBoxRounding::TopLeft { 8.0 } else { 0.0 },
ne: if rounding == StatBoxRounding::TopRight { 8.0 } else { 0.0 },
sw: if rounding == StatBoxRounding::BottomLeft { 8.0 } else { 0.0 },
se: if rounding == StatBoxRounding::BottomRight { 8.0 } else { 0.0 },
},
Color32::WHITE,
Stroke { width: 1.0, color: Color32::from_gray(230) },
);
ui.vertical_centered_justified(|ui| {
// Correct vertical spacing between items
ui.style_mut().spacing.item_spacing.y = -4.0;
// Draw box value
let mut job = LayoutJob::single_section(value, TextFormat {
font_id: FontId::proportional(18.0),
color: Color32::BLACK,
.. Default::default()
});
job.wrap = TextWrapping {
max_rows: 1,
break_anywhere: false,
overflow_character: Option::from(''),
..Default::default()
};
ui.label(job);
// Draw box label
ui.label(RichText::new(label).color(COLOR_GRAY).size(15.0));
});
}

View file

@ -12,17 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use eframe::epaint::{FontId, Stroke};
use eframe::epaint::text::{LayoutJob, TextFormat, TextWrapping};
use egui::{Color32, FontId, RichText, Sense, Stroke, Widget};
use egui::style::Margin;
use egui_extras::{Size, StripBuilder};
use crate::gui::colors::{COLOR_DARK, COLOR_YELLOW};
use crate::gui::{COLOR_DARK, COLOR_YELLOW};
use crate::gui::screens::Navigator;
use crate::gui::views::common::title_button;
pub struct TitlePanelAction {
pub(crate) icon: Box<str>,
pub(crate) on_click: Box<dyn Fn(&mut Option<&mut Navigator>)>,
pub(crate) on_click: Box<dyn Fn(&mut Navigator)>,
}
#[derive(Default)]
@ -31,15 +32,22 @@ pub struct TitlePanelActions {
right: Option<TitlePanelAction>
}
#[derive(Default)]
pub struct TitlePanel<'nav> {
title: Option<&'nav str>,
title: Option<String>,
actions: TitlePanelActions,
navigator: Option<&'nav mut Navigator>
nav: &'nav mut Navigator
}
impl<'nav> TitlePanel<'nav> {
pub fn title(mut self, title: &'nav str) -> Self {
pub fn new(nav: &'nav mut Navigator) -> TitlePanel<'nav> {
Self {
title: None,
actions: Default::default(),
nav,
}
}
pub fn title(mut self, title: String) -> Self {
self.title = Some(title);
self
}
@ -54,16 +62,11 @@ impl<'nav> TitlePanel<'nav> {
self
}
pub fn with_navigator(mut self, nav: &'nav mut Navigator) -> Self {
self.navigator = Some(nav);
self
}
pub fn ui(&mut self, ui: &mut egui::Ui) {
// Disable stroke around panel buttons on hover
ui.style_mut().visuals.widgets.active.bg_stroke = Stroke::NONE;
let Self { actions, title, navigator } = self;
let Self { actions, title, nav } = self;
egui::TopBottomPanel::top("title_panel")
.resizable(false)
@ -85,50 +88,19 @@ impl<'nav> TitlePanel<'nav> {
.size(Size::exact(52.0))
.horizontal(|mut strip| {
strip.cell(|ui| {
if actions.left.is_some() {
let action = actions.left.as_ref().unwrap();
ui.centered_and_justified(|ui| {
let b = egui::widgets::Button::new(
RichText::new(&action.icon.to_string())
.size(24.0)
.color(COLOR_DARK)
).fill(Color32::TRANSPARENT)
.ui(ui)
.interact(Sense::click_and_drag());
if b.drag_released() || b.clicked() {
(action.on_click)(navigator);
};
});
}
Self::show_action(ui, actions.left.as_ref(), nav);
});
strip.strip(|builder| {
builder
.size(Size::remainder())
.vertical(|mut strip| {
strip.cell(|ui| {
if title.is_some() {
ui.centered_and_justified(|ui| {
Self::show_title(title.unwrap(), ui);
});
}
Self::show_title(&*title, ui);
});
});
});
strip.cell(|ui| {
if actions.right.is_some() {
let action = actions.right.as_ref().unwrap();
ui.centered_and_justified(|ui| {
let b = egui::widgets::Button::new(
RichText::new(action.icon.to_string())
.size(24.0)
.color(COLOR_DARK)
).fill(Color32::TRANSPARENT)
.ui(ui).interact(Sense::click_and_drag());
if b.drag_released() || b.clicked() {
(action.on_click)(navigator);
};
});
}
Self::show_action(ui, actions.right.as_ref(), nav);
});
});
});
@ -136,8 +108,24 @@ impl<'nav> TitlePanel<'nav> {
});
}
fn show_title(title: &str, ui: &mut egui::Ui) {
let mut job = LayoutJob::single_section(title.to_uppercase(), TextFormat {
fn show_action(ui: &mut egui::Ui,
action: Option<&TitlePanelAction>,
navigator: &mut Navigator) {
if action.is_some() {
let action = action.unwrap();
ui.centered_and_justified(|ui| {
title_button(ui, &action.icon, || {
(action.on_click)(navigator);
});
});
}
}
fn show_title(title: &Option<String>, ui: &mut egui::Ui) {
if title.is_some() {
ui.centered_and_justified(|ui| {
let title_text = title.as_ref().unwrap().to_uppercase();
let mut job = LayoutJob::single_section(title_text, TextFormat {
font_id: FontId::proportional(20.0),
color: COLOR_DARK,
.. Default::default()
@ -145,10 +133,13 @@ impl<'nav> TitlePanel<'nav> {
job.wrap = TextWrapping {
max_rows: 1,
break_anywhere: false,
overflow_character: Option::from(''),
overflow_character: Option::from(''),
..Default::default()
};
ui.label(job);
});
}
}
}