From f1d2da20517df4b25b7f7216a4cd53e0e9898ec6 Mon Sep 17 00:00:00 2001 From: nandi Date: Fri, 31 Jul 2026 15:35:00 -0700 Subject: [PATCH] Lay out I/O gauges with vidya grid_cols row DSL Single grid row of fixed-width gauge tiles so cards share a baseline instead of staircasing via pack/horizontal_wrapped. --- src/app.rs | 79 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/src/app.rs b/src/app.rs index cd650f0..b85ac59 100644 --- a/src/app.rs +++ b/src/app.rs @@ -201,7 +201,7 @@ impl eframe::App for UsageApp { impl UsageApp { fn gauges_row(&self, ui: &mut egui::Ui, th: &Theme) { - // Compact fixed-size cards via vidya::pack — no window-width stretch. + // One grid row — equal baseline, no pack/wrap staircase. const GAUGE_SIZE: f32 = 148.0; let card_w = GAUGE_SIZE + th.spacing.md * 2.0; @@ -222,31 +222,26 @@ impl UsageApp { ("Network up", net_w, nw_max, "Net Up"), ]; - pack(ui, th, |ui| { - for (caption, value, max, label) in cards { - let frac = if max > 0.0 { - (value / max) as f32 - } else { - 0.0 - }; - let color = heat_color(th, frac); - compact_card(ui, th, card_w, |ui| { - ui.vertical_centered(|ui| { - dim_label(ui, th, caption); - arc_gauge( - ui, - th, - GAUGE_SIZE, - frac, - &format_bps(value), - label, - color, - ); - dim_label(ui, th, &format!("scale {}", format_bps(max))); - }); + grid_cols( + ui, + th, + "io_gauges", + &[ + ColSpec::Fixed(card_w), + ColSpec::Fixed(card_w), + ColSpec::Fixed(card_w), + ColSpec::Fixed(card_w), + ], + |g| { + g.row(|r| { + for &(caption, value, max, label) in &cards { + r.cell(|ui| { + gauge_tile(ui, th, card_w, GAUGE_SIZE, caption, value, max, label); + }); + } }); - } - }); + }, + ); } /// Compact Process | Time | Usage tables for abnormal disk I/O. @@ -365,6 +360,40 @@ impl UsageApp { } } +/// One compact gauge card (used inside the gauges grid row). +fn gauge_tile( + ui: &mut egui::Ui, + th: &Theme, + card_w: f32, + gauge_size: f32, + caption: &str, + value: f64, + max: f64, + label: &str, +) { + let frac = if max > 0.0 { + (value / max) as f32 + } else { + 0.0 + }; + let color = heat_color(th, frac); + compact_card(ui, th, card_w, |ui| { + ui.vertical_centered(|ui| { + dim_label(ui, th, caption); + arc_gauge( + ui, + th, + gauge_size, + frac, + &format_bps(value), + label, + color, + ); + dim_label(ui, th, &format!("scale {}", format_bps(max))); + }); + }); +} + /// Abnormal I/O list via vidya grid DSL. fn anomaly_table(ui: &mut egui::Ui, th: &Theme, hits: &[AnomalyHit], id: &str) { grid_cols( -- 2.51.2