ui: fix list items paddings
This commit is contained in:
parent
5cd3994163
commit
6497d6798b
2 changed files with 98 additions and 91 deletions
|
@ -13,14 +13,14 @@
|
|||
// limitations under the License.
|
||||
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use egui::{RichText, Rounding, ScrollArea, Stroke};
|
||||
use egui::{RichText, Rounding, ScrollArea, Stroke, vec2};
|
||||
use grin_servers::DiffBlock;
|
||||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{AT, COINS, CUBE_TRANSPARENT, HASH, HOURGLASS_LOW, HOURGLASS_MEDIUM, TIMER};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::network::{NetworkTab, NetworkTabType};
|
||||
use crate::gui::views::{Modal, Network, View};
|
||||
use crate::gui::views::network::{NetworkTab, NetworkTabType};
|
||||
use crate::node::Node;
|
||||
|
||||
/// Chain metrics tab content.
|
||||
|
@ -131,7 +131,7 @@ impl NetworkTab for NetworkMetrics {
|
|||
.stick_to_bottom(true)
|
||||
.show_rows(
|
||||
ui,
|
||||
BLOCK_ITEM_HEIGHT,
|
||||
BLOCK_ITEM_HEIGHT - 1.0,
|
||||
blocks_size,
|
||||
|ui, row_range| {
|
||||
for index in row_range {
|
||||
|
@ -154,7 +154,7 @@ impl NetworkTab for NetworkMetrics {
|
|||
fn on_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks) {}
|
||||
}
|
||||
|
||||
const BLOCK_ITEM_HEIGHT: f32 = 74.90;
|
||||
const BLOCK_ITEM_HEIGHT: f32 = 77.0;
|
||||
|
||||
/// Draw block difficulty item.
|
||||
fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
||||
|
@ -163,12 +163,14 @@ fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
|||
ui.add_space(4.0);
|
||||
}
|
||||
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
rect.set_height(BLOCK_ITEM_HEIGHT);
|
||||
ui.allocate_ui_at_rect(rect, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
ui.vertical(|ui| {
|
||||
// Draw round background.
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
rect.set_height(BLOCK_ITEM_HEIGHT);
|
||||
rect.min += vec2(8.0, 0.0);
|
||||
ui.painter().rect(
|
||||
rect,
|
||||
Rounding {
|
||||
|
@ -182,44 +184,41 @@ fn block_item_ui(ui: &mut egui::Ui, db: &DiffBlock, rounding: [bool; 2]) {
|
|||
);
|
||||
|
||||
ui.add_space(2.0);
|
||||
|
||||
// Draw block hash.
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(5.0);
|
||||
// Draw block hash.
|
||||
ui.heading(RichText::new(format!("{} {}", HASH, db.block_hash))
|
||||
ui.label(RichText::new(format!("{} {}", HASH, db.block_hash))
|
||||
.color(Colors::BLACK)
|
||||
.size(17.0));
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
// Draw block difficulty and height.
|
||||
ui.heading(RichText::new(format!("{} {}", CUBE_TRANSPARENT, db.difficulty))
|
||||
.color(Colors::TITLE)
|
||||
.size(16.0));
|
||||
ui.add_space(2.0);
|
||||
ui.heading(RichText::new(AT).color(Colors::TITLE).size(16.0));
|
||||
ui.add_space(2.0);
|
||||
ui.heading(RichText::new(db.block_height.to_string())
|
||||
.color(Colors::TITLE)
|
||||
.size(16.0));
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
let diff_text = format!("{} {} {} {}",
|
||||
CUBE_TRANSPARENT,
|
||||
db.difficulty,
|
||||
AT,
|
||||
db.block_height);
|
||||
ui.label(RichText::new(diff_text).color(Colors::TITLE).size(16.0));
|
||||
});
|
||||
// Draw block date.
|
||||
ui.heading(RichText::new(format!("{} {}s", TIMER, db.duration))
|
||||
.color(Colors::GRAY)
|
||||
.size(16.0));
|
||||
ui.add_space(4.0);
|
||||
|
||||
ui.heading(RichText::new(HOURGLASS_LOW).color(Colors::GRAY).size(16.0));
|
||||
ui.add_space(2.0);
|
||||
// Draw block time.
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
let block_time = NaiveDateTime::from_timestamp_opt(db.time as i64, 0).unwrap();
|
||||
let block_datetime: DateTime<Utc> = DateTime::from_utc(block_time, Utc);
|
||||
ui.heading(RichText::new(block_datetime.format("%d/%m/%Y %H:%M:%S UTC").to_string())
|
||||
let block_date: DateTime<Utc> = DateTime::from_utc(block_time, Utc);
|
||||
let block_time_text = block_date.format("%d/%m/%Y %H:%M:%S UTC").to_string();
|
||||
ui.label(RichText::new(format!("{} {}s {} {}",
|
||||
TIMER,
|
||||
db.duration,
|
||||
HOURGLASS_LOW,
|
||||
block_time_text))
|
||||
.color(Colors::GRAY)
|
||||
.size(16.0));
|
||||
});
|
||||
|
||||
ui.add_space(2.0);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -188,10 +188,11 @@ impl NetworkTab for NetworkNode {
|
|||
|
||||
/// Draw connected peer info item.
|
||||
fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
rect.set_height(77.0);
|
||||
ui.allocate_ui_at_rect(rect, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
// Draw round background.
|
||||
let mut rect = ui.available_rect_before_wrap();
|
||||
rect.set_height(74.9);
|
||||
ui.painter().rect(
|
||||
rect,
|
||||
Rounding {
|
||||
|
@ -215,12 +216,12 @@ fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
|||
// Draw peer difficulty and height
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
let diff_text = format!("{} {}", PACKAGE, peer.total_difficulty);
|
||||
let diff_text = format!("{} {} {} {}",
|
||||
PACKAGE,
|
||||
peer.total_difficulty,
|
||||
AT,
|
||||
peer.height);
|
||||
ui.label(RichText::new(diff_text).color(Colors::TITLE).size(16.0));
|
||||
ui.add_space(2.0);
|
||||
ui.label(RichText::new(AT).color(Colors::TITLE).size(16.0));
|
||||
ui.add_space(2.0);
|
||||
ui.label(RichText::new(peer.height.to_string()).color(Colors::TITLE).size(16.0));
|
||||
});
|
||||
// Draw peer user-agent
|
||||
ui.horizontal(|ui| {
|
||||
|
@ -228,6 +229,13 @@ fn peer_item_ui(ui: &mut egui::Ui, peer: &PeerStats, rounding: [bool; 2]) {
|
|||
let agent_text = format!("{} {}", DEVICES, &peer.user_agent);
|
||||
ui.label(RichText::new(agent_text).color(Colors::GRAY).size(16.0));
|
||||
});
|
||||
|
||||
ui.add_space(2.0);
|
||||
});
|
||||
});
|
||||
|
||||
// Add space after the last item.
|
||||
if rounding[1] {
|
||||
ui.add_space(5.0);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue