fix: node info paddings

This commit is contained in:
ardocrat 2024-05-30 15:05:19 +03:00
parent 764a6eb787
commit ba3649a811
3 changed files with 18 additions and 24 deletions

View file

@ -17,7 +17,7 @@ use egui::scroll_area::ScrollBarVisibility;
use grin_servers::{DiffBlock, ServerStats};
use crate::gui::Colors;
use crate::gui::icons::{AT, COINS, CUBE_TRANSPARENT, HASH, HOURGLASS_LOW, HOURGLASS_MEDIUM, TIMER};
use crate::gui::icons::{AT, COINS, CUBE_TRANSPARENT, HOURGLASS_LOW, HOURGLASS_MEDIUM, TIMER};
use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::{NetworkContent, Root, View};
use crate::gui::views::network::types::{NetworkTab, NetworkTabType};
@ -77,7 +77,7 @@ impl NetworkTab for NetworkMetrics {
}
}
const BLOCK_ITEM_HEIGHT: f32 = 77.0;
const BLOCK_ITEM_HEIGHT: f32 = 79.0;
/// Draw emission and difficulty info.
fn info_ui(ui: &mut egui::Ui, stats: &ServerStats) {
@ -170,17 +170,17 @@ fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: Rounding) {
ui.horizontal(|ui| {
ui.add_space(6.0);
ui.vertical(|ui| {
ui.add_space(3.0);
// Draw round background.
rect.min += vec2(8.0, 0.0);
rect.max -= vec2(8.0, 0.0);
ui.painter().rect(rect, rounding, Colors::white_or_black(false), View::item_stroke());
ui.add_space(2.0);
// Draw block hash.
ui.horizontal(|ui| {
ui.add_space(5.0);
ui.label(RichText::new(format!("{} {}", HASH, db.block_hash))
ui.add_space(7.0);
ui.label(RichText::new(db.block_hash.to_string())
.color(Colors::white_or_black(true))
.size(17.0));
});
@ -207,9 +207,9 @@ fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: Rounding) {
.size(16.0));
});
ui.add_space(2.0);
ui.add_space(3.0);
});
ui.add_space(8.0);
ui.add_space(6.0);
});
});
}

View file

@ -17,7 +17,7 @@ use egui::scroll_area::ScrollBarVisibility;
use grin_servers::PeerStats;
use crate::gui::Colors;
use crate::gui::icons::{AT, CUBE, DEVICES, FLOW_ARROW, HANDSHAKE, PACKAGE, PLUGS_CONNECTED, SHARE_NETWORK};
use crate::gui::icons::{AT, CUBE, DEVICES, FLOW_ARROW, HANDSHAKE, PACKAGE, SHARE_NETWORK};
use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::{NetworkContent, Root, View};
use crate::gui::views::network::types::{NetworkTab, NetworkTabType};
@ -190,30 +190,26 @@ fn node_stats_ui(ui: &mut egui::Ui) {
let peers = &stats.peer_stats;
for (index, ps) in peers.iter().enumerate() {
peer_item_ui(ui, ps, View::item_rounding(index, peers.len(), false));
// Add space after the last item.
if index == peers.len() - 1 {
ui.add_space(5.0);
}
}
ui.add_space(5.0);
}
}
/// Draw connected peer info item.
fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: Rounding) {
let mut rect = ui.available_rect_before_wrap();
rect.set_height(77.0);
rect.set_height(79.0);
ui.allocate_ui_at_rect(rect, |ui| {
ui.vertical(|ui| {
ui.add_space(3.0);
// Draw round background.
ui.painter().rect(rect, rounding, Colors::white_or_black(false), View::item_stroke());
ui.add_space(2.0);
// Draw peer address
ui.horizontal(|ui| {
ui.add_space(5.0);
let addr_text = format!("{} {}", PLUGS_CONNECTED, &peer.addr);
ui.label(RichText::new(addr_text).color(Colors::white_or_black(true)).size(17.0));
ui.add_space(7.0);
ui.label(RichText::new(&peer.addr).color(Colors::white_or_black(true)).size(17.0));
});
// Draw peer difficulty and height
ui.horizontal(|ui| {
@ -232,7 +228,7 @@ fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: Rounding) {
ui.label(RichText::new(agent_text).color(Colors::gray()).size(16.0));
});
ui.add_space(2.0);
ui.add_space(3.0);
});
});
}

View file

@ -518,8 +518,7 @@ impl View {
// Draw box content.
let content_resp = ui.allocate_ui_at_rect(rect, |ui| {
ui.vertical_centered_justified(|ui| {
ui.add_space(2.0);
ui.add_space(3.0);
ui.scope(|ui| {
// Correct vertical spacing between items.
ui.style_mut().spacing.item_spacing.y = -3.0;
@ -541,8 +540,7 @@ impl View {
// Draw box label.
ui.label(RichText::new(label).color(Colors::gray()).size(15.0));
});
ui.add_space(2.0);
ui.add_space(3.0);
});
}).response;