From 75e8bc313a57c4010cc0c9f3b03ea654f4e66a79 Mon Sep 17 00:00:00 2001 From: nandi Date: Fri, 31 Jul 2026 14:41:42 -0700 Subject: [PATCH] Right-align process Write/Write freq so rates don't staircase Label::halign did not pin text in sized cells; use right_to_left layout and monospace metrics so column edges stay vertical. --- src/app.rs | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/app.rs b/src/app.rs index da56295..1bfc50f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -539,7 +539,7 @@ fn proc_row( ) { const NAME_W: f32 = 140.0; const WRITE_W: f32 = 100.0; - const FREQ_W: f32 = 90.0; + const FREQ_W: f32 = 80.0; let name_style = |s: &str| { if is_header { @@ -565,17 +565,22 @@ fn proc_row( .color(th.palette.text_secondary) } }; - let metric_style = |s: &str| { + // Monospace metrics so column edges stay vertical (no length "waterfall"). + let metric = |s: &str, secondary: bool| { + let color = if is_header { + th.palette.text_secondary + } else if secondary { + th.palette.text_secondary + } else { + th.palette.text + }; + let mut rt = RichText::new(s).size(th.type_scale.caption).color(color); if is_header { - RichText::new(s) - .size(th.type_scale.caption) - .strong() - .color(th.palette.text_secondary) + rt = rt.strong(); } else { - RichText::new(s) - .size(th.type_scale.body) - .color(th.palette.text) + rt = rt.monospace(); } + rt }; let name_label = if is_header { @@ -601,22 +606,23 @@ fn proc_row( egui::Label::new(path_style(&path_label)).truncate(), ); - ui.add_sized( - [WRITE_W, row_h], - egui::Label::new(metric_style(write)).halign(Align::RIGHT), + // Right-to-left layout actually pins text to the column's right edge; + // Label::halign alone does not (text stayed left → staircase edge). + ui.allocate_ui_with_layout( + egui::vec2(WRITE_W, row_h), + Layout::right_to_left(Align::Center), + |ui| { + ui.set_min_width(WRITE_W); + ui.label(metric(write, false)); + }, ); - ui.add_sized( - [FREQ_W, row_h], - egui::Label::new( - if is_header { - metric_style(freq) - } else { - RichText::new(freq) - .size(th.type_scale.body) - .color(th.palette.text_secondary) - }, - ) - .halign(Align::RIGHT), + ui.allocate_ui_with_layout( + egui::vec2(FREQ_W, row_h), + Layout::right_to_left(Align::Center), + |ui| { + ui.set_min_width(FREQ_W); + ui.label(metric(freq, true)); + }, ); } -- 2.51.2