ui: update egui, fixes for new eframe version
This commit is contained in:
parent
ebe7bee344
commit
3e03f1a014
10 changed files with 766 additions and 454 deletions
1104
Cargo.lock
generated
1104
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
15
Cargo.toml
15
Cargo.toml
|
@ -31,10 +31,10 @@ openssl-sys = { version = "0.9.82", features = ["vendored"] }
|
||||||
|
|
||||||
## ui
|
## ui
|
||||||
pollster = "0.3.0"
|
pollster = "0.3.0"
|
||||||
wgpu = "0.14.0"
|
wgpu = "0.16.0"
|
||||||
egui = { version = "0.20.1", default-features = false }
|
egui = { version = "0.22.0", default-features = false }
|
||||||
egui_extras = { version = "0.20.0" }
|
egui_extras = { version = "0.22.0" }
|
||||||
eframe = { version = "0.20.1", features = [ "wgpu" ] }
|
eframe = { version = "0.22.0", features = [ "wgpu", "android-game-activity" ] }
|
||||||
|
|
||||||
## grin_servers
|
## grin_servers
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
@ -57,20 +57,17 @@ tokio = {version = "1.29.1", features = ["full"] }
|
||||||
tokio-util = { version = "0.7.8", features = ["codec"] }
|
tokio-util = { version = "0.7.8", features = ["codec"] }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
winit = { git = "https://github.com/rib/winit", branch = "android-activity" }
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
built = { version = "0.6.0", features = ["git2"]}
|
built = { version = "0.6.0", features = ["git2"]}
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
winit = { version = "0.27.2" }
|
winit = { version = "0.28" }
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
android_logger = "0.13.1"
|
android_logger = "0.13.1"
|
||||||
jni = "0.21.1"
|
jni = "0.21.1"
|
||||||
winit = { version = "0.27.2", features = [ "android-game-activity" ] }
|
winit = { version = "0.28", features = [ "android-game-activity" ] }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name="grim"
|
name="grim"
|
||||||
|
|
|
@ -78,7 +78,7 @@ fn start(mut options: NativeOptions, app_creator: AppCreator) {
|
||||||
Node::start();
|
Node::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
eframe::run_native("Grim", options, app_creator);
|
let _ = eframe::run_native("Grim", options, app_creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_i18n() {
|
fn setup_i18n() {
|
||||||
|
|
|
@ -100,8 +100,9 @@ impl App {
|
||||||
"../../fonts/phosphor.ttf"
|
"../../fonts/phosphor.ttf"
|
||||||
)).tweak(egui::FontTweak {
|
)).tweak(egui::FontTweak {
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
y_offset_factor: 0.14,
|
y_offset_factor: -0.30,
|
||||||
y_offset: 0.0
|
y_offset: 0.0,
|
||||||
|
baseline_offset_factor: 0.30,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
fonts
|
fonts
|
||||||
|
@ -117,7 +118,8 @@ impl App {
|
||||||
)).tweak(egui::FontTweak {
|
)).tweak(egui::FontTweak {
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
y_offset_factor: -0.25,
|
y_offset_factor: -0.25,
|
||||||
y_offset: 0.0
|
y_offset: 0.0,
|
||||||
|
baseline_offset_factor: 0.17,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
fonts
|
fonts
|
||||||
|
|
|
@ -388,8 +388,12 @@ impl NodeSetup {
|
||||||
// Setup spacing between buttons.
|
// Setup spacing between buttons.
|
||||||
ui.spacing_mut().item_spacing = egui::Vec2::new(12.0, 0.0);
|
ui.spacing_mut().item_spacing = egui::Vec2::new(12.0, 0.0);
|
||||||
|
|
||||||
|
let mut buttons_rect = ui.available_rect_before_wrap();
|
||||||
|
buttons_rect.set_height(46.0);
|
||||||
|
ui.allocate_ui_at_rect(buttons_rect, |ui| {
|
||||||
|
|
||||||
ui.columns(2, |columns| {
|
ui.columns(2, |columns| {
|
||||||
columns[0].with_layout(Layout::right_to_left(Align::TOP), |ui| {
|
columns[0].with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||||
let copy_title = format!("{} {}", COPY, t!("network_settings.copy"));
|
let copy_title = format!("{} {}", COPY, t!("network_settings.copy"));
|
||||||
View::button(ui, copy_title, Colors::WHITE, || {
|
View::button(ui, copy_title, Colors::WHITE, || {
|
||||||
match modal.id {
|
match modal.id {
|
||||||
|
@ -403,10 +407,8 @@ impl NodeSetup {
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
columns[1].with_layout(Layout::left_to_right(Align::TOP), |ui| {
|
columns[1].with_layout(Layout::left_to_right(Align::Center), |ui| {
|
||||||
let paste_title = format!("{} {}",
|
let paste_title = format!("{} {}", CLIPBOARD_TEXT, t!("network_settings.paste"));
|
||||||
CLIPBOARD_TEXT,
|
|
||||||
t!("network_settings.paste"));
|
|
||||||
View::button(ui, paste_title, Colors::WHITE, || {
|
View::button(ui, paste_title, Colors::WHITE, || {
|
||||||
let text = cb.get_string_from_buffer();
|
let text = cb.get_string_from_buffer();
|
||||||
match modal.id {
|
match modal.id {
|
||||||
|
@ -418,6 +420,8 @@ impl NodeSetup {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// Show reminder to restart enabled node.
|
// Show reminder to restart enabled node.
|
||||||
NetworkSettings::node_restart_required_ui(ui);
|
NetworkSettings::node_restart_required_ui(ui);
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl NetworkContainer {
|
||||||
|
|
||||||
egui::TopBottomPanel::bottom("network_tabs")
|
egui::TopBottomPanel::bottom("network_tabs")
|
||||||
.frame(egui::Frame {
|
.frame(egui::Frame {
|
||||||
outer_margin: Margin::same(5.0),
|
outer_margin: Margin::same(4.0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.show_inside(ui, |ui| {
|
.show_inside(ui, |ui| {
|
||||||
|
@ -150,9 +150,9 @@ impl NetworkContainer {
|
||||||
fn tabs_ui(&mut self, ui: &mut egui::Ui) {
|
fn tabs_ui(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.scope(|ui| {
|
ui.scope(|ui| {
|
||||||
// Setup spacing between tabs.
|
// Setup spacing between tabs.
|
||||||
ui.style_mut().spacing.item_spacing = egui::vec2(5.0, 0.0);
|
ui.style_mut().spacing.item_spacing = egui::vec2(4.0, 0.0);
|
||||||
// Setup vertical padding inside tab button.
|
// Setup vertical padding inside tab button.
|
||||||
ui.style_mut().spacing.button_padding = egui::vec2(0.0, 3.0);
|
ui.style_mut().spacing.button_padding = egui::vec2(0.0, 8.0);
|
||||||
|
|
||||||
ui.columns(4, |columns| {
|
ui.columns(4, |columns| {
|
||||||
columns[0].vertical_centered_justified(|ui| {
|
columns[0].vertical_centered_justified(|ui| {
|
||||||
|
@ -244,7 +244,7 @@ impl NetworkContainer {
|
||||||
};
|
};
|
||||||
let (dark, bright) = (0.3, 1.0);
|
let (dark, bright) = (0.3, 1.0);
|
||||||
let color_factor = if !idle {
|
let color_factor = if !idle {
|
||||||
lerp(dark..=bright, ui.input().time.cos().abs()) as f32
|
lerp(dark..=bright, ui.input(|i| i.time).cos().abs()) as f32
|
||||||
} else {
|
} else {
|
||||||
bright as f32
|
bright as f32
|
||||||
};
|
};
|
||||||
|
|
|
@ -153,7 +153,7 @@ impl NetworkTab for NetworkMetrics {
|
||||||
fn on_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {}
|
fn on_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DIFF_BLOCK_UI_HEIGHT: f32 = 76.60;
|
const DIFF_BLOCK_UI_HEIGHT: f32 = 78.30;
|
||||||
|
|
||||||
fn draw_diff_block(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
fn draw_diff_block(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
||||||
// Add space before the first item.
|
// Add space before the first item.
|
||||||
|
@ -179,26 +179,17 @@ fn draw_diff_block(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
||||||
);
|
);
|
||||||
|
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
ui.heading(RichText::new(HASH)
|
|
||||||
.color(Colors::BLACK)
|
|
||||||
.size(18.0));
|
|
||||||
ui.add_space(2.0);
|
|
||||||
|
|
||||||
// Draw block hash.
|
// Draw block hash.
|
||||||
ui.heading(RichText::new(db.block_hash.to_string())
|
ui.heading(RichText::new(format!("{} {}", HASH, db.block_hash))
|
||||||
.color(Colors::BLACK)
|
.color(Colors::BLACK)
|
||||||
.size(18.0));
|
.size(18.0));
|
||||||
});
|
});
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
ui.heading(RichText::new(CUBE_TRANSPARENT)
|
|
||||||
.color(Colors::TITLE)
|
|
||||||
.size(16.0));
|
|
||||||
ui.add_space(3.0);
|
|
||||||
// Draw block difficulty and height.
|
// Draw block difficulty and height.
|
||||||
ui.heading(RichText::new(db.difficulty.to_string())
|
ui.heading(RichText::new(format!("{} {}", CUBE_TRANSPARENT, db.difficulty))
|
||||||
.color(Colors::TITLE)
|
.color(Colors::TITLE)
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
|
@ -208,14 +199,10 @@ fn draw_diff_block(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
||||||
.color(Colors::TITLE)
|
.color(Colors::TITLE)
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
});
|
});
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
ui.heading(RichText::new(TIMER)
|
|
||||||
.color(Colors::GRAY)
|
|
||||||
.size(16.0));
|
|
||||||
ui.add_space(3.0);
|
|
||||||
// Draw block date.
|
// Draw block date.
|
||||||
ui.heading(RichText::new(format!("{}s", db.duration))
|
ui.heading(RichText::new(format!("{} {}s", TIMER, db.duration))
|
||||||
.color(Colors::GRAY)
|
.color(Colors::GRAY)
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
ui.add_space(4.0);
|
ui.add_space(4.0);
|
||||||
|
@ -229,7 +216,7 @@ fn draw_diff_block(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
||||||
.color(Colors::GRAY)
|
.color(Colors::GRAY)
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
});
|
});
|
||||||
ui.add_space(2.0);
|
ui.add_space(4.0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -189,7 +189,7 @@ impl NetworkTab for NetworkNode {
|
||||||
fn draw_peer_stats(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
fn draw_peer_stats(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
let mut rect = ui.available_rect_before_wrap();
|
let mut rect = ui.available_rect_before_wrap();
|
||||||
rect.set_height(77.3);
|
rect.set_height(78.3);
|
||||||
|
|
||||||
ui.painter().rect(
|
ui.painter().rect(
|
||||||
rect,
|
rect,
|
||||||
|
@ -204,27 +204,17 @@ fn draw_peer_stats(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
||||||
);
|
);
|
||||||
|
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
ui.heading(RichText::new(PLUGS_CONNECTED)
|
|
||||||
.color(Colors::BLACK)
|
|
||||||
.size(18.0));
|
|
||||||
ui.add_space(3.0);
|
|
||||||
|
|
||||||
// Draw peer address
|
// Draw peer address
|
||||||
ui.heading(RichText::new(&peer.addr)
|
ui.heading(RichText::new(format!("{} {}", PLUGS_CONNECTED, &peer.addr))
|
||||||
.color(Colors::BLACK)
|
.color(Colors::BLACK)
|
||||||
.size(18.0));
|
.size(18.0));
|
||||||
});
|
});
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
ui.heading(RichText::new(PACKAGE)
|
|
||||||
.color(Colors::TITLE)
|
|
||||||
.size(16.0));
|
|
||||||
ui.add_space(4.0);
|
|
||||||
|
|
||||||
// Draw peer difficulty and height
|
// Draw peer difficulty and height
|
||||||
ui.heading(RichText::new(peer.total_difficulty.to_string())
|
ui.heading(RichText::new(format!("{} {}", PACKAGE, peer.total_difficulty))
|
||||||
.color(Colors::TITLE)
|
.color(Colors::TITLE)
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
|
@ -235,23 +225,18 @@ fn draw_peer_stats(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
ui.heading(RichText::new(DEVICES)
|
|
||||||
.color(Colors::GRAY)
|
|
||||||
.size(16.0));
|
|
||||||
ui.add_space(4.0);
|
|
||||||
|
|
||||||
// Draw peer user-agent
|
// Draw peer user-agent
|
||||||
ui.heading(RichText::new(&peer.user_agent)
|
ui.heading(RichText::new(format!("{} {}", DEVICES, &peer.user_agent))
|
||||||
.color(Colors::GRAY)
|
.color(Colors::GRAY)
|
||||||
.size(16.0));
|
.size(16.0));
|
||||||
});
|
});
|
||||||
ui.add_space(3.0);
|
ui.add_space(4.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add space after last item
|
// Add space after last item
|
||||||
if rounding[1] {
|
// if rounding[1] {
|
||||||
ui.add_space(2.0);
|
// ui.add_space(2.0);
|
||||||
}
|
// }
|
||||||
}
|
}
|
|
@ -81,6 +81,7 @@ impl TitlePanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_title(ui: &mut egui::Ui, title: String) {
|
fn draw_title(ui: &mut egui::Ui, title: String) {
|
||||||
|
ui.add_space(2.0);
|
||||||
ui.centered_and_justified(|ui| {
|
ui.centered_and_justified(|ui| {
|
||||||
View::ellipsize_text(ui, title.to_uppercase(), 20.0, Colors::TITLE);
|
View::ellipsize_text(ui, title.to_uppercase(), 20.0, Colors::TITLE);
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl View {
|
||||||
let drag_resp = resp.interact(Sense::click_and_drag());
|
let drag_resp = resp.interact(Sense::click_and_drag());
|
||||||
// Clear pointer event if dragging is out of button area
|
// Clear pointer event if dragging is out of button area
|
||||||
if drag_resp.dragged() && !ui.rect_contains_pointer(drag_resp.rect) {
|
if drag_resp.dragged() && !ui.rect_contains_pointer(drag_resp.rect) {
|
||||||
ui.input_mut().pointer = PointerState::default();
|
ui.input_mut(|i| i.pointer = PointerState::default());
|
||||||
}
|
}
|
||||||
if drag_resp.drag_released() || drag_resp.clicked() {
|
if drag_resp.drag_released() || drag_resp.clicked() {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue