ui: remove unused eframe argument

This commit is contained in:
ardocrat 2024-06-20 22:52:12 +03:00
parent 3cd3e8e5c1
commit 167b222f60
33 changed files with 173 additions and 426 deletions

312
Cargo.lock generated
View file

@ -1394,9 +1394,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.16.0" version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78834c15cb5d5efe3452d58b1e8ba890dd62d21907f867f383358198e56ebca5" checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e"
dependencies = [ dependencies = [
"bytemuck_derive", "bytemuck_derive",
] ]
@ -2080,16 +2080,15 @@ dependencies = [
[[package]] [[package]]
name = "curve25519-dalek" name = "curve25519-dalek"
version = "4.1.2" version = "4.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"curve25519-dalek-derive", "curve25519-dalek-derive",
"digest 0.10.7", "digest 0.10.7",
"fiat-crypto", "fiat-crypto",
"platforms",
"rustc_version", "rustc_version",
"subtle", "subtle",
"zeroize", "zeroize",
@ -2629,7 +2628,7 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871"
dependencies = [ dependencies = [
"curve25519-dalek 4.1.2", "curve25519-dalek 4.1.3",
"ed25519 2.2.3", "ed25519 2.2.3",
"merlin", "merlin",
"rand_core 0.6.4", "rand_core 0.6.4",
@ -3838,7 +3837,7 @@ dependencies = [
"arti-hyper", "arti-hyper",
"built", "built",
"chrono", "chrono",
"curve25519-dalek 4.1.2", "curve25519-dalek 4.1.3",
"dark-light", "dark-light",
"dirs 5.0.1", "dirs 5.0.1",
"ed25519-dalek 2.1.1", "ed25519-dalek 2.1.1",
@ -4598,9 +4597,9 @@ dependencies = [
[[package]] [[package]]
name = "httparse" name = "httparse"
version = "1.9.3" version = "1.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9"
[[package]] [[package]]
name = "httpdate" name = "httpdate"
@ -4862,124 +4861,6 @@ dependencies = [
"objc2 0.4.1", "objc2 0.4.1",
] ]
[[package]]
name = "icu_collections"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
dependencies = [
"displaydoc",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_locid"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
dependencies = [
"displaydoc",
"litemap",
"tinystr",
"writeable",
"zerovec",
]
[[package]]
name = "icu_locid_transform"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
dependencies = [
"displaydoc",
"icu_locid",
"icu_locid_transform_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_locid_transform_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e"
[[package]]
name = "icu_normalizer"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
dependencies = [
"displaydoc",
"icu_collections",
"icu_normalizer_data",
"icu_properties",
"icu_provider",
"smallvec",
"utf16_iter",
"utf8_iter",
"write16",
"zerovec",
]
[[package]]
name = "icu_normalizer_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516"
[[package]]
name = "icu_properties"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036"
dependencies = [
"displaydoc",
"icu_collections",
"icu_locid_transform",
"icu_properties_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_properties_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569"
[[package]]
name = "icu_provider"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
dependencies = [
"displaydoc",
"icu_locid",
"icu_provider_macros",
"stable_deref_trait",
"tinystr",
"writeable",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_provider_macros"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2 1.0.85",
"quote 1.0.36",
"syn 2.0.66",
]
[[package]] [[package]]
name = "id-arena" name = "id-arena"
version = "2.2.1" version = "2.2.1"
@ -4994,14 +4875,12 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "idna" name = "idna"
version = "1.0.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
dependencies = [ dependencies = [
"icu_normalizer", "unicode-bidi",
"icu_properties", "unicode-normalization",
"smallvec",
"utf8_iter",
] ]
[[package]] [[package]]
@ -5499,12 +5378,6 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
[[package]]
name = "litemap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704"
[[package]] [[package]]
name = "litrs" name = "litrs"
version = "0.4.1" version = "0.4.1"
@ -5807,9 +5680,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.7.3" version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
dependencies = [ dependencies = [
"adler", "adler",
"simd-adler32", "simd-adler32",
@ -6981,12 +6854,6 @@ version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "platforms"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7"
[[package]] [[package]]
name = "png" name = "png"
version = "0.17.13" version = "0.17.13"
@ -8796,12 +8663,6 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]] [[package]]
name = "static_assertions" name = "static_assertions"
version = "1.1.0" version = "1.1.0"
@ -8952,17 +8813,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "synstructure"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2 1.0.85",
"quote 1.0.36",
"syn 2.0.66",
]
[[package]] [[package]]
name = "sys-locale" name = "sys-locale"
version = "0.3.1" version = "0.3.1"
@ -9216,9 +9066,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
dependencies = [ dependencies = [
"displaydoc", "displaydoc",
"zerovec",
] ]
[[package]]
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tls-api" name = "tls-api"
version = "0.9.0" version = "0.9.0"
@ -10101,7 +9965,7 @@ dependencies = [
"aes", "aes",
"base64ct", "base64ct",
"ctr", "ctr",
"curve25519-dalek 4.1.2", "curve25519-dalek 4.1.3",
"derive_more", "derive_more",
"digest 0.10.7", "digest 0.10.7",
"ed25519-dalek 2.1.1", "ed25519-dalek 2.1.1",
@ -10602,12 +10466,27 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "unicode-bidi"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.12" version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-normalization"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
dependencies = [
"tinyvec",
]
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.11.0" version = "1.11.0"
@ -10684,9 +10563,9 @@ dependencies = [
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.1" version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna", "idna",
@ -10744,18 +10623,6 @@ dependencies = [
"tiny-skia-path", "tiny-skia-path",
] ]
[[package]]
name = "utf16_iter"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
[[package]]
name = "utf8_iter"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]] [[package]]
name = "utf8parse" name = "utf8parse"
version = "0.2.2" version = "0.2.2"
@ -11721,18 +11588,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "write16"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
[[package]]
name = "writeable"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]] [[package]]
name = "ws2_32-sys" name = "ws2_32-sys"
version = "0.2.1" version = "0.2.1"
@ -11812,7 +11667,7 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277"
dependencies = [ dependencies = [
"curve25519-dalek 4.1.2", "curve25519-dalek 4.1.3",
"rand_core 0.6.4", "rand_core 0.6.4",
"serde", "serde",
"zeroize", "zeroize",
@ -11900,30 +11755,6 @@ dependencies = [
"linked-hash-map", "linked-hash-map",
] ]
[[package]]
name = "yoke"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95"
dependencies = [
"proc-macro2 1.0.85",
"quote 1.0.36",
"syn 2.0.66",
"synstructure",
]
[[package]] [[package]]
name = "zbus" name = "zbus"
version = "3.15.2" version = "3.15.2"
@ -12072,27 +11903,6 @@ dependencies = [
"syn 2.0.66", "syn 2.0.66",
] ]
[[package]]
name = "zerofrom"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
dependencies = [
"proc-macro2 1.0.85",
"quote 1.0.36",
"syn 2.0.66",
"synstructure",
]
[[package]] [[package]]
name = "zeroize" name = "zeroize"
version = "1.8.1" version = "1.8.1"
@ -12113,28 +11923,6 @@ dependencies = [
"syn 2.0.66", "syn 2.0.66",
] ]
[[package]]
name = "zerovec"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c"
dependencies = [
"yoke",
"zerofrom",
"zerovec-derive",
]
[[package]]
name = "zerovec-derive"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7"
dependencies = [
"proc-macro2 1.0.85",
"quote 1.0.36",
"syn 2.0.66",
]
[[package]] [[package]]
name = "zip" name = "zip"
version = "0.5.13" version = "0.5.13"
@ -12166,9 +11954,9 @@ dependencies = [
[[package]] [[package]]
name = "zstd-sys" name = "zstd-sys"
version = "2.0.10+zstd.1.5.6" version = "2.0.11+zstd.1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4"
dependencies = [ dependencies = [
"cc", "cc",
"pkg-config", "pkg-config",

View file

@ -85,11 +85,6 @@ tls-api-native-tls = "0.9.0"
## stratum server ## stratum server
tokio-util = { version = "0.7.8", features = ["codec"] } tokio-util = { version = "0.7.8", features = ["codec"] }
### patch grin store
#grin_store = "5.3.1"
#[patch.crates-io]
#grin_store = { path = "../grin-store" }
[build-dependencies] [build-dependencies]
built = "0.7.0" built = "0.7.0"
@ -103,10 +98,6 @@ nokhwa = { version = "0.10.4", default-features = false, features = ["input-msmf
tls-api-openssl = "0.9.0" tls-api-openssl = "0.9.0"
openpnp_capture_sys = "0.4.0" openpnp_capture_sys = "0.4.0"
[patch.crates-io]
### fix cross-compilation support for macos
openpnp_capture_sys = { git = "https://github.com/ardocrat/openpnp-capture-rs", branch = "cross_compilation_support" }
[target.'cfg(not(target_os = "android"))'.dependencies] [target.'cfg(not(target_os = "android"))'.dependencies]
env_logger = "0.11.3" env_logger = "0.11.3"
winit = { version = "0.29.15" } winit = { version = "0.29.15" }
@ -121,4 +112,12 @@ jni = "0.21.1"
android-activity = { version = "0.6.0", features = ["game-activity"] } android-activity = { version = "0.6.0", features = ["game-activity"] }
wgpu = "0.19.1" wgpu = "0.19.1"
winit = { version = "0.29.15", features = ["android-game-activity"] } winit = { version = "0.29.15", features = ["android-game-activity"] }
eframe = { version = "0.27.2", features = ["wgpu", "android-game-activity"] } eframe = { version = "0.27.2", features = ["wgpu", "android-game-activity"] }
### patch grin store
#grin_store = "5.3.1"
#[patch.crates-io]
#grin_store = { path = "../grin-store" }
[patch.crates-io]
### fix cross-compilation support for macos
openpnp_capture_sys = { git = "https://github.com/ardocrat/openpnp-capture-rs", branch = "cross_compilation_support" }

View file

@ -27,31 +27,29 @@ lazy_static! {
} }
/// Implements ui entry point and contains platform-specific callbacks. /// Implements ui entry point and contains platform-specific callbacks.
pub struct PlatformApp<Platform> { pub struct App<Platform> {
/// Platform specific callbacks handler. /// Platform specific callbacks handler.
pub(crate) platform: Platform, pub(crate) platform: Platform,
/// Main ui content. /// Main ui content.
root: Root root: Root
} }
impl<Platform> PlatformApp<Platform> { impl<Platform: PlatformCallbacks> App<Platform> {
pub fn new(platform: Platform) -> Self { pub fn new(platform: Platform) -> Self {
Self { platform, root: Root::default() } Self { platform, root: Root::default() }
} }
}
impl<Platform: PlatformCallbacks> eframe::App for PlatformApp<Platform> { /// Draw application content.
fn update(&mut self, ctx: &Context, frame: &mut eframe::Frame) { pub fn ui(&mut self, ctx: &Context) {
// Handle Esc keyboard key event and platform Back button key event. // Handle Esc keyboard key event and platform Back button key event.
let back_button_pressed = BACK_BUTTON_PRESSED.load(Ordering::Relaxed); let back_button_pressed = BACK_BUTTON_PRESSED.load(Ordering::Relaxed);
if ctx.input_mut(|i| i.consume_key(Modifiers::NONE, egui::Key::Escape)) || back_button_pressed { if ctx.input_mut(|i| i.consume_key(Modifiers::NONE, egui::Key::Escape)) || back_button_pressed {
self.root.on_back(); self.root.on_back();
// Request repaint to update previous content.
ctx.request_repaint();
if back_button_pressed { if back_button_pressed {
BACK_BUTTON_PRESSED.store(false, Ordering::Relaxed); BACK_BUTTON_PRESSED.store(false, Ordering::Relaxed);
} }
// Request repaint to update previous content.
ctx.request_repaint();
} }
// Handle Close event (on desktop). // Handle Close event (on desktop).
@ -77,11 +75,18 @@ impl<Platform: PlatformCallbacks> eframe::App for PlatformApp<Platform> {
..Default::default() ..Default::default()
}) })
.show(ctx, |ui| { .show(ctx, |ui| {
self.root.ui(ui, frame, &self.platform); self.root.ui(ui, &self.platform);
}); });
} }
} }
/// To draw with egui`s eframe (for wgpu, glow backends and wasm target).
impl<Platform: PlatformCallbacks> eframe::App for App<Platform> {
fn update(&mut self, ctx: &Context, _: &mut eframe::Frame) {
self.ui(ctx);
}
}
#[allow(dead_code)] #[allow(dead_code)]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
#[allow(non_snake_case)] #[allow(non_snake_case)]

View file

@ -14,7 +14,7 @@
mod app; mod app;
pub use app::PlatformApp; pub use app::App;
mod colors; mod colors;
pub use colors::Colors; pub use colors::Colors;

View file

@ -66,7 +66,6 @@ impl ModalContainer for ConnectionsContent {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -80,9 +79,9 @@ impl ConnectionsContent {
/// External connection [`Modal`] identifier. /// External connection [`Modal`] identifier.
pub const NETWORK_EXT_CONNECTION_MODAL: &'static str = "network_ext_connection_modal"; pub const NETWORK_EXT_CONNECTION_MODAL: &'static str = "network_ext_connection_modal";
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
ui.add_space(2.0); ui.add_space(2.0);

View file

@ -43,12 +43,12 @@ impl Default for NetworkContent {
} }
impl NetworkContent { impl NetworkContent {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Flag to show connections or integrated node content. // Flag to show connections or integrated node content.
let show_connections = AppConfig::show_connections_network_panel(); let show_connections = AppConfig::show_connections_network_panel();
// Show title panel. // Show title panel.
self.title_ui(ui, frame, show_connections, cb); self.title_ui(ui, show_connections);
// Show integrated node tabs content. // Show integrated node tabs content.
egui::TopBottomPanel::bottom("node_tabs_panel") egui::TopBottomPanel::bottom("node_tabs_panel")
@ -94,7 +94,7 @@ impl NetworkContent {
}) })
.show_inside(ui, |ui| { .show_inside(ui, |ui| {
// Draw node tab content. // Draw node tab content.
self.node_tab_content.ui(ui, frame, cb); self.node_tab_content.ui(ui, cb);
}); });
}); });
@ -140,7 +140,7 @@ impl NetworkContent {
ui.available_width() ui.available_width()
}; };
View::max_width_ui(ui, max_width, |ui| { View::max_width_ui(ui, max_width, |ui| {
self.connections.ui(ui, frame, cb); self.connections.ui(ui, cb);
}); });
}); });
}); });
@ -188,11 +188,7 @@ impl NetworkContent {
} }
/// Draw title content. /// Draw title content.
fn title_ui(&mut self, fn title_ui(&mut self, ui: &mut egui::Ui, show_connections: bool) {
ui: &mut egui::Ui,
frame: &mut eframe::Frame,
show_connections: bool,
_: &dyn PlatformCallbacks) {
// Setup values for title panel. // Setup values for title panel.
let title_text = self.node_tab_content.get_type().title().to_uppercase(); let title_text = self.node_tab_content.get_type().title().to_uppercase();
let subtitle_text = Node::get_sync_status_text(); let subtitle_text = Node::get_sync_status_text();
@ -204,7 +200,7 @@ impl NetworkContent {
}; };
// Draw title panel. // Draw title panel.
TitlePanel::ui(TitleType::Single(title_content), |ui, _| { TitlePanel::ui(TitleType::Single(title_content), |ui| {
if !show_connections { if !show_connections {
View::title_button(ui, DOTS_THREE_OUTLINE_VERTICAL, || { View::title_button(ui, DOTS_THREE_OUTLINE_VERTICAL, || {
AppConfig::toggle_show_connections_network_panel(); AppConfig::toggle_show_connections_network_panel();
@ -213,13 +209,13 @@ impl NetworkContent {
} }
}); });
} }
}, |ui, _| { }, |ui| {
if !Root::is_dual_panel_mode(ui) { if !Root::is_dual_panel_mode(ui) {
View::title_button(ui, BRIEFCASE, || { View::title_button(ui, BRIEFCASE, || {
Root::toggle_network_panel(); Root::toggle_network_panel();
}); });
} }
}, ui, frame); }, ui);
} }
/// Content to draw when node is disabled. /// Content to draw when node is disabled.

View file

@ -36,7 +36,7 @@ impl NetworkTab for NetworkMetrics {
NetworkTabType::Metrics NetworkTabType::Metrics
} }
fn ui(&mut self, ui: &mut egui::Ui, _: &mut eframe::Frame, _: &dyn PlatformCallbacks) { fn ui(&mut self, ui: &mut egui::Ui, _: &dyn PlatformCallbacks) {
// Show an error content when available. // Show an error content when available.
let node_err = Node::get_error(); let node_err = Node::get_error();
if node_err.is_some() { if node_err.is_some() {

View file

@ -44,7 +44,7 @@ impl NetworkTab for NetworkMining {
NetworkTabType::Mining NetworkTabType::Mining
} }
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Show an error content when available. // Show an error content when available.
let node_err = Node::get_error(); let node_err = Node::get_error();
if node_err.is_some() { if node_err.is_some() {
@ -83,7 +83,7 @@ impl NetworkTab for NetworkMining {
ui.add_space(1.0); ui.add_space(1.0);
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| { View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
self.stratum_server_setup.ui(ui, frame, cb); self.stratum_server_setup.ui(ui, cb);
}); });
}); });
}); });

View file

@ -32,7 +32,7 @@ impl NetworkTab for NetworkNode {
NetworkTabType::Node NetworkTabType::Node
} }
fn ui(&mut self, ui: &mut egui::Ui, _: &mut eframe::Frame, _: &dyn PlatformCallbacks) { fn ui(&mut self, ui: &mut egui::Ui, _: &dyn PlatformCallbacks) {
// Show an error content when available. // Show an error content when available.
let node_err = Node::get_error(); let node_err = Node::get_error();
if node_err.is_some() { if node_err.is_some() {

View file

@ -66,7 +66,6 @@ impl ModalContainer for NetworkSettings {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
_: &dyn PlatformCallbacks) { _: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -81,9 +80,9 @@ impl NetworkTab for NetworkSettings {
NetworkTabType::Settings NetworkTabType::Settings
} }
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
ScrollArea::vertical() ScrollArea::vertical()
.id_source("network_settings") .id_source("network_settings")
@ -94,35 +93,35 @@ impl NetworkTab for NetworkSettings {
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| { View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
// Draw node setup section. // Draw node setup section.
self.node.ui(ui, frame, cb); self.node.ui(ui, cb);
ui.add_space(6.0); ui.add_space(6.0);
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());
ui.add_space(4.0); ui.add_space(4.0);
// Draw P2P server setup section. // Draw P2P server setup section.
self.p2p.ui(ui, frame, cb); self.p2p.ui(ui, cb);
ui.add_space(6.0); ui.add_space(6.0);
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());
ui.add_space(4.0); ui.add_space(4.0);
// Draw Stratum server setup section. // Draw Stratum server setup section.
self.stratum.ui(ui, frame, cb); self.stratum.ui(ui, cb);
ui.add_space(6.0); ui.add_space(6.0);
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());
ui.add_space(4.0); ui.add_space(4.0);
// Draw pool setup section. // Draw pool setup section.
self.pool.ui(ui, frame, cb); self.pool.ui(ui, cb);
ui.add_space(6.0); ui.add_space(6.0);
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());
ui.add_space(4.0); ui.add_space(4.0);
// Draw Dandelion server setup section. // Draw Dandelion server setup section.
self.dandelion.ui(ui, frame, cb); self.dandelion.ui(ui, cb);
ui.add_space(6.0); ui.add_space(6.0);
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());

View file

@ -73,7 +73,6 @@ impl ModalContainer for DandelionSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -87,9 +86,9 @@ impl ModalContainer for DandelionSetup {
} }
impl DandelionSetup { impl DandelionSetup {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
View::sub_title(ui, format!("{} {}", GRAPH, "Dandelion")); View::sub_title(ui, format!("{} {}", GRAPH, "Dandelion"));
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());

View file

@ -84,7 +84,6 @@ impl ModalContainer for NodeSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -98,9 +97,9 @@ impl ModalContainer for NodeSetup {
} }
impl NodeSetup { impl NodeSetup {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
View::sub_title(ui, format!("{} {}", COMPUTER_TOWER, t!("network_settings.server"))); View::sub_title(ui, format!("{} {}", COMPUTER_TOWER, t!("network_settings.server")));
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());

View file

@ -132,7 +132,6 @@ impl ModalContainer for P2PSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -153,9 +152,9 @@ impl P2PSetup {
/// Title for custom DNS Seeds setup section. /// Title for custom DNS Seeds setup section.
const DNS_SEEDS_TITLE: &'static str = "DNS Seeds"; const DNS_SEEDS_TITLE: &'static str = "DNS Seeds";
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
View::sub_title(ui, format!("{} {}", HANDSHAKE, t!("network_settings.p2p_server"))); View::sub_title(ui, format!("{} {}", HANDSHAKE, t!("network_settings.p2p_server")));
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());

View file

@ -80,7 +80,6 @@ impl ModalContainer for PoolSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -95,9 +94,9 @@ impl ModalContainer for PoolSetup {
} }
impl PoolSetup { impl PoolSetup {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
View::sub_title(ui, format!("{} {}", CHART_SCATTER, t!("network_settings.tx_pool"))); View::sub_title(ui, format!("{} {}", CHART_SCATTER, t!("network_settings.tx_pool")));
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());

View file

@ -79,7 +79,6 @@ impl ModalContainer for StratumSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -92,9 +91,9 @@ impl ModalContainer for StratumSetup {
} }
impl StratumSetup { impl StratumSetup {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
View::sub_title(ui, format!("{} {}", HARD_DRIVES, t!("network_mining.server"))); View::sub_title(ui, format!("{} {}", HARD_DRIVES, t!("network_mining.server")));
View::horizontal_line(ui, Colors::stroke()); View::horizontal_line(ui, Colors::stroke());

View file

@ -17,7 +17,7 @@ use crate::gui::platform::PlatformCallbacks;
/// Network tab content interface. /// Network tab content interface.
pub trait NetworkTab { pub trait NetworkTab {
fn get_type(&self) -> NetworkTabType; fn get_type(&self) -> NetworkTabType;
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks); fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks);
} }
/// Type of [`NetworkTab`] content. /// Type of [`NetworkTab`] content.

View file

@ -76,7 +76,6 @@ impl ModalContainer for Root {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
_: &dyn PlatformCallbacks) { _: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -100,9 +99,9 @@ impl Root {
/// Default width of side panel at application UI. /// Default width of side panel at application UI.
pub const SIDE_PANEL_WIDTH: f32 = 400.0; pub const SIDE_PANEL_WIDTH: f32 = 400.0;
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
let (is_panel_open, panel_width) = Self::network_panel_state_width(ui); let (is_panel_open, panel_width) = Self::network_panel_state_width(ui);
// Show network content. // Show network content.
@ -119,7 +118,7 @@ impl Root {
let window_size = View::window_size(ui); let window_size = View::window_size(ui);
rect.set_height(window_size.1); rect.set_height(window_size.1);
ui.allocate_ui_at_rect(rect, |ui| { ui.allocate_ui_at_rect(rect, |ui| {
self.network.ui(ui, frame, cb); self.network.ui(ui, cb);
}); });
}); });
@ -135,7 +134,7 @@ impl Root {
let window_size = View::window_size(ui); let window_size = View::window_size(ui);
rect.set_height(window_size.1); rect.set_height(window_size.1);
ui.allocate_ui_at_rect(rect, |ui| { ui.allocate_ui_at_rect(rect, |ui| {
self.wallets.ui(ui, frame, cb); self.wallets.ui(ui, cb);
}); });
}); });

View file

@ -27,10 +27,9 @@ impl TitlePanel {
pub const DEFAULT_HEIGHT: f32 = 54.0; pub const DEFAULT_HEIGHT: f32 = 54.0;
pub fn ui(title: TitleType, pub fn ui(title: TitleType,
mut left_content: impl FnMut(&mut egui::Ui, &mut eframe::Frame), mut left_content: impl FnMut(&mut egui::Ui),
mut right_content: impl FnMut(&mut egui::Ui, &mut eframe::Frame), mut right_content: impl FnMut(&mut egui::Ui),
ui: &mut egui::Ui, ui: &mut egui::Ui) {
frame: &mut eframe::Frame) {
// Setup identifier and title type. // Setup identifier and title type.
let (id, dual_title) = match &title { let (id, dual_title) = match &title {
TitleType::Single(content) => { TitleType::Single(content) => {
@ -85,7 +84,7 @@ impl TitlePanel {
strip.cell(|ui| { strip.cell(|ui| {
// Draw left panel action content. // Draw left panel action content.
ui.centered_and_justified(|ui| { ui.centered_and_justified(|ui| {
(left_content)(ui, frame); (left_content)(ui);
}); });
}); });
// Draw title text content. // Draw title text content.
@ -104,7 +103,7 @@ impl TitlePanel {
strip.cell(|ui| { strip.cell(|ui| {
// Draw right panel action content. // Draw right panel action content.
ui.centered_and_justified(|ui| { ui.centered_and_justified(|ui| {
(right_content)(ui, frame); (right_content)(ui);
}); });
}); });
}); });

View file

@ -54,20 +54,18 @@ pub trait ModalContainer {
/// Draw modal ui content. /// Draw modal ui content.
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks); cb: &dyn PlatformCallbacks);
/// Draw [`Modal`] for current ui container if it's possible. /// Draw [`Modal`] for current ui container if it's possible.
fn current_modal_ui(&mut self, fn current_modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
let modal_id = Modal::opened(); let modal_id = Modal::opened();
let draw = modal_id.is_some() && self.modal_ids().contains(&modal_id.unwrap()); let draw = modal_id.is_some() && self.modal_ids().contains(&modal_id.unwrap());
if draw { if draw {
Modal::ui(ui.ctx(), |ui, modal| { Modal::ui(ui.ctx(), |ui, modal| {
self.modal_ui(ui, frame, modal, cb); self.modal_ui(ui, modal, cb);
}); });
} }
} }

View file

@ -76,7 +76,6 @@ impl ModalContainer for WalletsContent {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -90,9 +89,9 @@ impl ModalContainer for WalletsContent {
} }
impl WalletsContent { impl WalletsContent {
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
// Setup wallet content flags. // Setup wallet content flags.
let empty_list = self.wallets.is_current_list_empty(); let empty_list = self.wallets.is_current_list_empty();
@ -106,7 +105,7 @@ impl WalletsContent {
let content_width = ui.available_width(); let content_width = ui.available_width();
// Show title panel. // Show title panel.
self.title_ui(ui, frame, dual_panel, create_wallet, show_wallet); self.title_ui(ui, dual_panel, create_wallet, show_wallet);
// Show wallet panel content. // Show wallet panel content.
egui::SidePanel::right("wallet_panel") egui::SidePanel::right("wallet_panel")
@ -132,7 +131,7 @@ impl WalletsContent {
} }
if create_wallet || !show_wallet { if create_wallet || !show_wallet {
// Show wallet creation content. // Show wallet creation content.
self.creation_content.ui(ui, frame, cb, |wallet| { self.creation_content.ui(ui, cb, |wallet| {
// Add created wallet to list. // Add created wallet to list.
self.wallets.add(wallet); self.wallets.add(wallet);
// Reset wallet content. // Reset wallet content.
@ -153,7 +152,7 @@ impl WalletsContent {
rect.set_width(width); rect.set_width(width);
// Show wallet content. // Show wallet content.
ui.allocate_ui_at_rect(rect, |ui| { ui.allocate_ui_at_rect(rect, |ui| {
self.wallet_content.ui(ui, frame, wallet, cb); self.wallet_content.ui(ui, wallet, cb);
}); });
break; break;
} }
@ -224,7 +223,6 @@ impl WalletsContent {
/// Draw [`TitlePanel`] content. /// Draw [`TitlePanel`] content.
fn title_ui(&mut self, fn title_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
dual_panel: bool, dual_panel: bool,
create_wallet: bool, create_wallet: bool,
show_wallet: bool) { show_wallet: bool) {
@ -263,7 +261,7 @@ impl WalletsContent {
}; };
// Draw title panel. // Draw title panel.
TitlePanel::ui(title_content, |ui, _| { TitlePanel::ui(title_content, |ui| {
if show_wallet && !dual_panel { if show_wallet && !dual_panel {
View::title_button(ui, ARROW_LEFT, || { View::title_button(ui, ARROW_LEFT, || {
self.wallets.select(None); self.wallets.select(None);
@ -287,7 +285,7 @@ impl WalletsContent {
Root::toggle_network_panel(); Root::toggle_network_panel();
}); });
}; };
}, |ui, _| { }, |ui| {
View::title_button(ui, GEAR, || { View::title_button(ui, GEAR, || {
// Show settings modal. // Show settings modal.
Modal::new(Root::SETTINGS_MODAL) Modal::new(Root::SETTINGS_MODAL)
@ -295,7 +293,7 @@ impl WalletsContent {
.title(t!("settings")) .title(t!("settings"))
.show(); .show();
}); });
}, ui, frame); }, ui);
} }
/// Calculate [`WalletContent`] panel width. /// Calculate [`WalletContent`] panel width.

View file

@ -66,7 +66,6 @@ impl WalletCreation {
/// Draw wallet creation content. /// Draw wallet creation content.
pub fn ui(&mut self, pub fn ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
cb: &dyn PlatformCallbacks, cb: &dyn PlatformCallbacks,
on_create: impl FnOnce(Wallet)) { on_create: impl FnOnce(Wallet)) {
// Show wallet creation step description and confirmation panel. // Show wallet creation step description and confirmation panel.
@ -125,7 +124,7 @@ impl WalletCreation {
Root::SIDE_PANEL_WIDTH * 2.0 Root::SIDE_PANEL_WIDTH * 2.0
}; };
View::max_width_ui(ui, max_width, |ui| { View::max_width_ui(ui, max_width, |ui| {
self.step_content_ui(ui, frame, cb); self.step_content_ui(ui, cb);
}); });
}); });
}); });
@ -312,10 +311,7 @@ impl WalletCreation {
} }
/// Draw wallet creation [`Step`] content. /// Draw wallet creation [`Step`] content.
fn step_content_ui(&mut self, fn step_content_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
frame: &mut eframe::Frame,
cb: &dyn PlatformCallbacks) {
match &self.step { match &self.step {
None => { None => {
// Show wallet creation message if step is empty. // Show wallet creation message if step is empty.
@ -339,14 +335,14 @@ impl WalletCreation {
} }
Some(step) => { Some(step) => {
match step { match step {
Step::EnterMnemonic => self.mnemonic_setup.ui(ui, frame, cb), Step::EnterMnemonic => self.mnemonic_setup.ui(ui, cb),
Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, frame, cb), Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, cb),
Step::SetupConnection => { Step::SetupConnection => {
// Redraw if node is running. // Redraw if node is running.
if Node::is_running() { if Node::is_running() {
ui.ctx().request_repaint_after(Node::STATS_UPDATE_DELAY); ui.ctx().request_repaint_after(Node::STATS_UPDATE_DELAY);
} }
self.network_setup.create_ui(ui, frame, cb) self.network_setup.create_ui(ui, cb)
} }
} }
} }

View file

@ -77,7 +77,6 @@ impl ModalContainer for MnemonicSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -90,9 +89,9 @@ impl ModalContainer for MnemonicSetup {
impl MnemonicSetup { impl MnemonicSetup {
/// Draw content for phrase input step. /// Draw content for phrase input step.
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) { pub fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
ui.add_space(10.0); ui.add_space(10.0);
@ -108,12 +107,9 @@ impl MnemonicSetup {
} }
/// Draw content for phrase confirmation step. /// Draw content for phrase confirmation step.
pub fn confirm_ui(&mut self, pub fn confirm_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
frame: &mut eframe::Frame,
cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
ui.add_space(4.0); ui.add_space(4.0);
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {

View file

@ -60,11 +60,7 @@ impl Default for CommonSetup {
} }
impl CommonSetup { impl CommonSetup {
pub fn ui(&mut self, pub fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
_: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
// Show modal content for this ui container. // Show modal content for this ui container.
self.modal_content_ui(ui, wallet, cb); self.modal_content_ui(ui, wallet, cb);

View file

@ -70,7 +70,6 @@ impl ModalContainer for ConnectionSetup {
fn modal_ui(&mut self, fn modal_ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
modal: &Modal, modal: &Modal,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
match modal.id { match modal.id {
@ -82,41 +81,34 @@ impl ModalContainer for ConnectionSetup {
impl ConnectionSetup { impl ConnectionSetup {
/// Draw wallet creation setup content. /// Draw wallet creation setup content.
pub fn create_ui(&mut self, pub fn create_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui, self.ui(ui, None, cb);
frame: &mut eframe::Frame,
cb: &dyn PlatformCallbacks) {
self.ui(ui, frame, None, cb);
} }
/// Draw existing wallet connection setup content. /// Draw existing wallet connection setup content.
pub fn wallet_ui(&mut self, pub fn wallet_ui(&mut self, ui: &mut egui::Ui, w: &mut Wallet, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
frame: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
// Setup connection value from provided wallet. // Setup connection value from provided wallet.
match wallet.get_config().ext_conn_id { match w.get_config().ext_conn_id {
None => self.method = ConnectionMethod::Integrated, None => self.method = ConnectionMethod::Integrated,
Some(id) => self.method = ConnectionMethod::External(id) Some(id) => self.method = ConnectionMethod::External(id)
} }
// Draw setup content. // Draw setup content.
self.ui(ui, frame, Some(wallet), cb); self.ui(ui, Some(w), cb);
// Setup wallet connection value after change. // Setup wallet connection value after change.
let changed = match self.method { let changed = match self.method {
ConnectionMethod::Integrated => { ConnectionMethod::Integrated => {
let changed = wallet.get_current_ext_conn().is_some(); let changed = w.get_current_ext_conn().is_some();
if changed { if changed {
wallet.update_ext_conn_id(None); w.update_ext_conn_id(None);
} }
changed changed
} }
ConnectionMethod::External(id) => { ConnectionMethod::External(id) => {
let changed = wallet.get_config().ext_conn_id != Some(id); let changed = w.get_config().ext_conn_id != Some(id);
if changed { if changed {
wallet.update_ext_conn_id(Some(id)); w.update_ext_conn_id(Some(id));
} }
changed changed
} }
@ -124,9 +116,9 @@ impl ConnectionSetup {
// Reopen wallet if connection changed. // Reopen wallet if connection changed.
if changed { if changed {
if !wallet.reopen_needed() { if !w.reopen_needed() {
wallet.set_reopen(true); w.set_reopen(true);
wallet.close(); w.close();
} }
} }
} }
@ -134,11 +126,10 @@ impl ConnectionSetup {
/// Draw connection setup content. /// Draw connection setup content.
fn ui(&mut self, fn ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
wallet: Option<&Wallet>, wallet: Option<&Wallet>,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
// Draw modal content for current ui container. // Draw modal content for current ui container.
self.current_modal_ui(ui, frame, cb); self.current_modal_ui(ui, cb);
ui.add_space(2.0); ui.add_space(2.0);
View::sub_title(ui, format!("{} {}", GLOBE, t!("wallets.conn_method"))); View::sub_title(ui, format!("{} {}", GLOBE, t!("wallets.conn_method")));

View file

@ -51,11 +51,7 @@ impl Default for RecoverySetup {
} }
impl RecoverySetup { impl RecoverySetup {
pub fn ui(&mut self, pub fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
_: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
// Show modal content for this ui container. // Show modal content for this ui container.
self.modal_content_ui(ui, wallet, cb); self.modal_content_ui(ui, wallet, cb);

View file

@ -75,7 +75,6 @@ impl WalletContent {
/// Draw wallet content. /// Draw wallet content.
pub fn ui(&mut self, pub fn ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
wallet: &mut Wallet, wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
// Show modal content for this ui container. // Show modal content for this ui container.
@ -153,7 +152,7 @@ impl WalletContent {
..Default::default() ..Default::default()
}) })
.show_inside(ui, |ui| { .show_inside(ui, |ui| {
self.current_tab.ui(ui, frame, wallet, cb); self.current_tab.ui(ui, wallet, cb);
}); });
// Refresh content after 1 second for synced wallet. // Refresh content after 1 second for synced wallet.

View file

@ -117,11 +117,7 @@ impl WalletTab for WalletMessages {
WalletTabType::Messages WalletTabType::Messages
} }
fn ui(&mut self, fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
_: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
if WalletContent::sync_ui(ui, wallet) { if WalletContent::sync_ui(ui, wallet) {
return; return;
} }

View file

@ -52,7 +52,6 @@ impl WalletTab for WalletSettings {
fn ui(&mut self, fn ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
wallet: &mut Wallet, wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
// Show loading progress if navigation is blocked. // Show loading progress if navigation is blocked.
@ -83,11 +82,11 @@ impl WalletTab for WalletSettings {
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| { View::max_width_ui(ui, Root::SIDE_PANEL_WIDTH * 1.3, |ui| {
// Show common wallet setup. // Show common wallet setup.
self.common_setup.ui(ui, frame, wallet, cb); self.common_setup.ui(ui, wallet, cb);
// Show wallet connections setup. // Show wallet connections setup.
self.conn_setup.wallet_ui(ui, frame, wallet, cb); self.conn_setup.wallet_ui(ui, wallet, cb);
// Show wallet recovery setup. // Show wallet recovery setup.
self.recovery_setup.ui(ui, frame, wallet, cb); self.recovery_setup.ui(ui, wallet, cb);
}); });
}); });
}); });

View file

@ -77,7 +77,6 @@ impl WalletTab for WalletTransport {
fn ui(&mut self, fn ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
_: &mut eframe::Frame,
wallet: &mut Wallet, wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) { cb: &dyn PlatformCallbacks) {
if WalletContent::sync_ui(ui, wallet) { if WalletContent::sync_ui(ui, wallet) {

View file

@ -97,11 +97,7 @@ impl WalletTab for WalletTransactions {
WalletTabType::Txs WalletTabType::Txs
} }
fn ui(&mut self, fn ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) {
ui: &mut egui::Ui,
_: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
if WalletContent::sync_ui(ui, wallet) { if WalletContent::sync_ui(ui, wallet) {
return; return;
} }

View file

@ -25,7 +25,6 @@ pub trait WalletTab {
fn get_type(&self) -> WalletTabType; fn get_type(&self) -> WalletTabType;
fn ui(&mut self, fn ui(&mut self,
ui: &mut egui::Ui, ui: &mut egui::Ui,
frame: &mut eframe::Frame,
wallet: &mut Wallet, wallet: &mut Wallet,
cb: &dyn PlatformCallbacks); cb: &dyn PlatformCallbacks);
} }

View file

@ -24,7 +24,7 @@ use winit::platform::android::activity::AndroidApp;
pub use settings::AppConfig; pub use settings::AppConfig;
pub use settings::Settings; pub use settings::Settings;
use crate::gui::{Colors, PlatformApp}; use crate::gui::{Colors, App};
use crate::gui::platform::PlatformCallbacks; use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::View; use crate::gui::views::View;
use crate::node::Node; use crate::node::Node;
@ -62,7 +62,7 @@ fn android_main(app: AndroidApp) {
// Setup system theme if not set. // Setup system theme if not set.
if let None = AppConfig::dark_theme() { if let None = AppConfig::dark_theme() {
let use_dark = system_dark_theme(&platform); let use_dark = use_dark_theme(&platform);
AppConfig::set_dark_theme(use_dark); AppConfig::set_dark_theme(use_dark);
} }
@ -89,21 +89,21 @@ fn android_main(app: AndroidApp) {
builder.with_android_app(app); builder.with_android_app(app);
})); }));
let app = PlatformApp::new(platform); let app = App::new(platform);
start(options, app_creator(app)).unwrap(); start(options, app_creator(app)).unwrap();
} }
/// Check if system is using dark theme. /// Check if system is using dark theme.
#[allow(dead_code)] #[allow(dead_code)]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
fn system_dark_theme(platform: &gui::platform::Android) -> bool { fn use_dark_theme(platform: &gui::platform::Android) -> bool {
let res = platform.call_java_method("useDarkTheme", "()Z", &[]).unwrap(); let res = platform.call_java_method("useDarkTheme", "()Z", &[]).unwrap();
unsafe { res.z != 0 } unsafe { res.z != 0 }
} }
/// [`PlatformApp`] setup for [`eframe`]. /// [`App`] setup for [`eframe`].
pub fn app_creator<T: 'static>(app: PlatformApp<T>) -> eframe::AppCreator pub fn app_creator<T: 'static>(app: App<T>) -> eframe::AppCreator
where PlatformApp<T>: eframe::App, T: PlatformCallbacks { where App<T>: eframe::App, T: PlatformCallbacks {
Box::new(|cc| { Box::new(|cc| {
// Setup images support. // Setup images support.
egui_extras::install_image_loaders(&cc.egui_ctx); egui_extras::install_image_loaders(&cc.egui_ctx);

View file

@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use grim::gui::App;
use grim::gui::platform::Desktop;
pub fn main() { pub fn main() {
#[allow(dead_code)] #[allow(dead_code)]
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
@ -28,7 +31,7 @@ fn real_main() {
.init(); .init();
use grim::gui::platform::Desktop; use grim::gui::platform::Desktop;
use grim::gui::PlatformApp; use grim::gui::App;
use grim::AppConfig; use grim::AppConfig;
use std::sync::Arc; use std::sync::Arc;
@ -69,12 +72,18 @@ fn real_main() {
..Default::default() ..Default::default()
}; };
options.renderer = eframe::Renderer::Wgpu; options.renderer = eframe::Renderer::Wgpu;
match grim::start(options.clone(), grim::app_creator(PlatformApp::new(platform.clone()))) {
match grim::start(options.clone(), grim::app_creator(App::new(platform.clone()))) {
Ok(_) => {} Ok(_) => {}
Err(_) => { Err(_) => {
// Start with Glow renderer on error. // Start with Glow renderer on error.
options.renderer = eframe::Renderer::Glow; options.renderer = eframe::Renderer::Glow;
grim::start(options, grim::app_creator(PlatformApp::new(platform))).unwrap(); match grim::start(options, grim::app_creator(App::new(platform))) {
Ok(_) => {}
Err(_) => {
panic!("Impossible to render");
}
}
} }
} }
} }