mirror of
https://code.gri.mw/GUI/grim.git
synced 2026-07-13 18:28:55 +00:00
ui: update egui, fixes for new eframe version
This commit is contained in:
Generated
+720
-384
File diff suppressed because it is too large
Load Diff
+6
-9
@@ -31,10 +31,10 @@ openssl-sys = { version = "0.9.82", features = ["vendored"] }
|
||||
|
||||
## ui
|
||||
pollster = "0.3.0"
|
||||
wgpu = "0.14.0"
|
||||
egui = { version = "0.20.1", default-features = false }
|
||||
egui_extras = { version = "0.20.0" }
|
||||
eframe = { version = "0.20.1", features = [ "wgpu" ] }
|
||||
wgpu = "0.16.0"
|
||||
egui = { version = "0.22.0", default-features = false }
|
||||
egui_extras = { version = "0.22.0" }
|
||||
eframe = { version = "0.22.0", features = [ "wgpu", "android-game-activity" ] }
|
||||
|
||||
## grin_servers
|
||||
futures = "0.3"
|
||||
@@ -57,20 +57,17 @@ tokio = {version = "1.29.1", features = ["full"] }
|
||||
tokio-util = { version = "0.7.8", features = ["codec"] }
|
||||
rand = "0.8.5"
|
||||
|
||||
[patch.crates-io]
|
||||
winit = { git = "https://github.com/rib/winit", branch = "android-activity" }
|
||||
|
||||
[build-dependencies]
|
||||
built = { version = "0.6.0", features = ["git2"]}
|
||||
|
||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||
env_logger = "0.10.0"
|
||||
winit = { version = "0.27.2" }
|
||||
winit = { version = "0.28" }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
android_logger = "0.13.1"
|
||||
jni = "0.21.1"
|
||||
winit = { version = "0.27.2", features = [ "android-game-activity" ] }
|
||||
winit = { version = "0.28", features = [ "android-game-activity" ] }
|
||||
|
||||
[lib]
|
||||
name="grim"
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ fn start(mut options: NativeOptions, app_creator: AppCreator) {
|
||||
Node::start();
|
||||
}
|
||||
|
||||
eframe::run_native("Grim", options, app_creator);
|
||||
let _ = eframe::run_native("Grim", options, app_creator);
|
||||
}
|
||||
|
||||
fn setup_i18n() {
|
||||
|
||||
+5
-3
@@ -100,8 +100,9 @@ impl App {
|
||||
"../../fonts/phosphor.ttf"
|
||||
)).tweak(egui::FontTweak {
|
||||
scale: 1.0,
|
||||
y_offset_factor: 0.14,
|
||||
y_offset: 0.0
|
||||
y_offset_factor: -0.30,
|
||||
y_offset: 0.0,
|
||||
baseline_offset_factor: 0.30,
|
||||
}),
|
||||
);
|
||||
fonts
|
||||
@@ -117,7 +118,8 @@ impl App {
|
||||
)).tweak(egui::FontTweak {
|
||||
scale: 1.0,
|
||||
y_offset_factor: -0.25,
|
||||
y_offset: 0.0
|
||||
y_offset: 0.0,
|
||||
baseline_offset_factor: 0.17,
|
||||
}),
|
||||
);
|
||||
fonts
|
||||
|
||||
@@ -388,8 +388,12 @@ impl NodeSetup {
|
||||
// Setup spacing between buttons.
|
||||
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| {
|
||||
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"));
|
||||
View::button(ui, copy_title, Colors::WHITE, || {
|
||||
match modal.id {
|
||||
@@ -403,10 +407,8 @@ impl NodeSetup {
|
||||
|
||||
});
|
||||
});
|
||||
columns[1].with_layout(Layout::left_to_right(Align::TOP), |ui| {
|
||||
let paste_title = format!("{} {}",
|
||||
CLIPBOARD_TEXT,
|
||||
t!("network_settings.paste"));
|
||||
columns[1].with_layout(Layout::left_to_right(Align::Center), |ui| {
|
||||
let paste_title = format!("{} {}", CLIPBOARD_TEXT, t!("network_settings.paste"));
|
||||
View::button(ui, paste_title, Colors::WHITE, || {
|
||||
let text = cb.get_string_from_buffer();
|
||||
match modal.id {
|
||||
@@ -416,6 +418,8 @@ impl NodeSetup {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Show reminder to restart enabled node.
|
||||
|
||||
@@ -127,7 +127,7 @@ impl NetworkContainer {
|
||||
|
||||
egui::TopBottomPanel::bottom("network_tabs")
|
||||
.frame(egui::Frame {
|
||||
outer_margin: Margin::same(5.0),
|
||||
outer_margin: Margin::same(4.0),
|
||||
..Default::default()
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
@@ -150,9 +150,9 @@ impl NetworkContainer {
|
||||
fn tabs_ui(&mut self, ui: &mut egui::Ui) {
|
||||
ui.scope(|ui| {
|
||||
// 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.
|
||||
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| {
|
||||
columns[0].vertical_centered_justified(|ui| {
|
||||
@@ -244,7 +244,7 @@ impl NetworkContainer {
|
||||
};
|
||||
let (dark, bright) = (0.3, 1.0);
|
||||
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 {
|
||||
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) {}
|
||||
}
|
||||
|
||||
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]) {
|
||||
// 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.horizontal_top(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(5.0);
|
||||
ui.heading(RichText::new(HASH)
|
||||
.color(Colors::BLACK)
|
||||
.size(18.0));
|
||||
ui.add_space(2.0);
|
||||
|
||||
// Draw block hash.
|
||||
ui.heading(RichText::new(db.block_hash.to_string())
|
||||
ui.heading(RichText::new(format!("{} {}", HASH, db.block_hash))
|
||||
.color(Colors::BLACK)
|
||||
.size(18.0));
|
||||
});
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
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.
|
||||
ui.heading(RichText::new(db.difficulty.to_string())
|
||||
ui.heading(RichText::new(format!("{} {}", CUBE_TRANSPARENT, db.difficulty))
|
||||
.color(Colors::TITLE)
|
||||
.size(16.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)
|
||||
.size(16.0));
|
||||
});
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
ui.heading(RichText::new(TIMER)
|
||||
.color(Colors::GRAY)
|
||||
.size(16.0));
|
||||
ui.add_space(3.0);
|
||||
// Draw block date.
|
||||
ui.heading(RichText::new(format!("{}s", db.duration))
|
||||
ui.heading(RichText::new(format!("{} {}s", TIMER, db.duration))
|
||||
.color(Colors::GRAY)
|
||||
.size(16.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)
|
||||
.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]) {
|
||||
ui.vertical(|ui| {
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
rect.set_height(77.3);
|
||||
rect.set_height(78.3);
|
||||
|
||||
ui.painter().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.horizontal_top(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
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
|
||||
ui.heading(RichText::new(&peer.addr)
|
||||
ui.heading(RichText::new(format!("{} {}", PLUGS_CONNECTED, &peer.addr))
|
||||
.color(Colors::BLACK)
|
||||
.size(18.0));
|
||||
});
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
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
|
||||
ui.heading(RichText::new(peer.total_difficulty.to_string())
|
||||
ui.heading(RichText::new(format!("{} {}", PACKAGE, peer.total_difficulty))
|
||||
.color(Colors::TITLE)
|
||||
.size(16.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));
|
||||
});
|
||||
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
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
|
||||
ui.heading(RichText::new(&peer.user_agent)
|
||||
ui.heading(RichText::new(format!("{} {}", DEVICES, &peer.user_agent))
|
||||
.color(Colors::GRAY)
|
||||
.size(16.0));
|
||||
});
|
||||
ui.add_space(3.0);
|
||||
ui.add_space(4.0);
|
||||
});
|
||||
|
||||
// Add space after last item
|
||||
if rounding[1] {
|
||||
ui.add_space(2.0);
|
||||
}
|
||||
// if rounding[1] {
|
||||
// ui.add_space(2.0);
|
||||
// }
|
||||
}
|
||||
@@ -81,6 +81,7 @@ impl TitlePanel {
|
||||
}
|
||||
|
||||
fn draw_title(ui: &mut egui::Ui, title: String) {
|
||||
ui.add_space(2.0);
|
||||
ui.centered_and_justified(|ui| {
|
||||
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());
|
||||
// Clear pointer event if dragging is out of button area
|
||||
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() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user