Redesign the page as an instrument panel: hairline panels, amber hero band, counter strip, two-column grid

Dark charcoal with one amber accent, a derived light theme, the problems list (click to open) inside the hero, raw counters collapsed by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-11-30 09:14:58 -07:00
1 parent 06abc4de80
commit 3a2bcefd38
9 files changed
+403 -390

No files matched your search

+184 -203
View File
@@ -250,35 +250,48 @@ fn theme_labels() -> [&'static str; 3] {
ThemeChoice::ALL.map(|theme| theme.name())
}
/// The wordmark at the left of the top bar.
fn wordmark(ui: &mut egui::Ui) {
ui.add(egui::Label::new(
egui::RichText::new("sccache dash")
.font(theme::number_font(15.0))
.color(theme::ui(ui).text),
));
}
fn wordmark_width(ui: &egui::Ui) -> f32 {
style::text_width(ui, "sccache dash", theme::number_font(15.0))
}
/// About how wide the row of actions is, from the width of its labels.
fn actions_width(ui: &egui::Ui) -> f32 {
let medium = theme::medium(theme::px::BODY);
let label = |text: &str| style::text_width(ui, text, medium.clone()) + 22.0;
let gaps = theme::space::PANEL_GAP;
label(&fmt::refresh_label(30)) + label("Refresh")
let label = |text: &str| style::text_width(ui, text, medium.clone()) + 18.0;
let gaps = theme::space::TOOL_GAP;
label(&fmt::refresh_label(30)) + 20.0 + label("Refresh")
+ theme_labels().iter().map(|text| style::text_width(ui, text, medium.clone()) + 2.0 * theme::space::CONTROL_PAD).sum::<f32>()
+ label("Copy summary") + label("Export JSON") + label("Zero stats")
+ theme::space::TOOLBAR_NOTE_WIDTH
+ gaps * 7.0
}
/// The row of controls that stays at the top of the page: the range as one
/// segmented control at the left; the actions at the right, on their own lines
/// where there is no room beside the range.
/// The slim bar at the top of the page: the wordmark and the range at the left; the
/// actions at the right, on their own line where there is no room beside the range.
fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
let ctx = ui.ctx().clone();
let now = Dashboard::now(&ctx);
let gap = theme::space::PANEL_GAP;
let gap = theme::space::TOOL_GAP;
let margin = theme::space::PAGE_MARGIN;
ui.add_space(margin);
let vertical = 10.0;
ui.add_space(vertical);
let width = ui.available_rect_before_wrap().width() - 2.0 * margin;
let medium = theme::medium(theme::px::BODY);
let range_width: f32 = Range::ALL
.iter()
.map(|range| style::text_width(ui, range.code(), medium.clone()) + 2.0 * theme::space::CONTROL_PAD)
.sum();
let beside = width >= theme::layout::TOOLBAR_TWO_LINES_BELOW;
let one_line = beside && range_width + gap + actions_width(ui) <= width;
let left_width = wordmark_width(ui) + 2.0 * theme::space::PANEL_GAP + range_width;
let one_line = left_width + gap + actions_width(ui) <= width;
let phone = width + 2.0 * theme::space::PAGE_MARGIN < theme::layout::TWO_COLUMNS_FROM;
let labels: Vec<&str> = Range::ALL.iter().map(|range| range.code()).collect();
@@ -286,6 +299,8 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = gap;
ui.add_space(margin);
wordmark(ui);
ui.add_space(theme::space::PANEL_GAP - gap);
if let Some(index) = style::segmented(ui, "range", &labels, chosen) {
if index != chosen {
dashboard.range = Range::ALL[index];
@@ -294,7 +309,7 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
}
}
if one_line {
ui.add_space((ui.available_width() - actions_width(ui)).max(0.0));
ui.add_space((ui.available_width() - actions_width(ui) - margin).max(0.0));
ui.allocate_ui_with_layout(
egui::vec2(actions_width(ui), theme::layout::TOOLBAR_HEIGHT),
egui::Layout::left_to_right(egui::Align::Center),
@@ -304,8 +319,8 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
});
if !one_line {
let height = theme::layout::TOOLBAR_HEIGHT;
ui.add_space(margin);
let room = ui.available_rect_before_wrap().width();
ui.add_space(gap);
let room = ui.available_rect_before_wrap().width() - 2.0 * margin;
let group_width = if phone { room } else { actions_width(ui).min(room) };
// On a phone the actions wrap at the left; on a narrower window they sit
// on a second line, at the right.
@@ -314,20 +329,30 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
} else {
egui::Layout::right_to_left(egui::Align::Center)
};
ui.allocate_ui_with_layout(egui::vec2(room, height), layout, |ui| {
if !phone {
ui.allocate_ui_with_layout(
egui::vec2(group_width, height),
egui::Layout::left_to_right(egui::Align::Center),
|ui| actions(dashboard, ui, &ctx, now, gap),
);
} else {
ui.spacing_mut().item_spacing = egui::vec2(gap, gap);
actions(dashboard, ui, &ctx, now, gap);
}
ui.horizontal(|ui| {
ui.add_space(margin);
ui.allocate_ui_with_layout(egui::vec2(room, height), layout, |ui| {
if !phone {
ui.allocate_ui_with_layout(
egui::vec2(group_width, height),
egui::Layout::left_to_right(egui::Align::Center),
|ui| actions(dashboard, ui, &ctx, now, gap),
);
} else {
ui.spacing_mut().item_spacing = egui::vec2(gap, gap);
actions(dashboard, ui, &ctx, now, gap);
}
});
});
}
ui.add_space(gap - theme::space::LINE);
ui.add_space(vertical);
let rule = ui.available_rect_before_wrap();
ui.painter().hline(
rule.x_range(),
rule.top() + 0.5,
egui::Stroke::new(1.0, theme::ctx(&ctx).border),
);
ui.add_space(1.0);
}
/// Refresh, theme, Copy summary, Export JSON, Zero stats, and the message slot.
@@ -461,7 +486,7 @@ fn waiting(ui: &mut egui::Ui, error: Option<&str>, refresh_secs: u64) {
};
// The same height the headline and cards take, so the page doesn't jump when they arrive.
let width = ui.available_rect_before_wrap().width();
let height = theme::layout::HEADLINE_HEIGHT + theme::space::PANEL_GAP + theme::layout::CARD_HEIGHT * 2.0;
let height = theme::layout::HEADLINE_HEIGHT + theme::space::PANEL_GAP + theme::layout::STRIP_ROW_HEIGHT * 2.0;
let (rect, _) = ui.allocate_exact_size(egui::vec2(width, height), egui::Sense::hover());
let mut place = ui.new_child(
egui::UiBuilder::new()
@@ -482,7 +507,7 @@ fn lost_contact(ctx: &egui::Context, error: &str, from: i64, page_width: f32) {
egui::Area::new(egui::Id::unique("lost-contact"))
.anchor(
egui::Align2::RIGHT_TOP,
egui::vec2(-theme::space::PAGE_MARGIN, theme::layout::TOOLBAR_HEIGHT + 2.0 * theme::space::PAGE_MARGIN),
egui::vec2(-theme::space::PAGE_MARGIN, theme::layout::TOOLBAR_HEIGHT + 3.0 * theme::space::PAGE_MARGIN),
)
.order(egui::Order::Foreground)
.show(ctx, |ui| {
@@ -491,9 +516,9 @@ fn lost_contact(ctx: &egui::Context, error: &str, from: i64, page_width: f32) {
.fill(p.panel)
.stroke(egui::Stroke::new(1.0, p.bad))
.corner_radius(theme::space::PANEL_RADIUS)
.inner_margin(theme::space::PANEL_PADDING)
.inner_margin(theme::space::PANEL_PAD_Y)
.show(ui, |ui| {
ui.set_max_width(width - 2.0 * theme::space::PANEL_PADDING);
ui.set_max_width(width - 2.0 * theme::space::PANEL_PAD_Y);
ui.add(
egui::Label::new(
theme::strong(format!(
@@ -529,16 +554,6 @@ fn table_height(fixed: f32, rows: usize) -> f32 {
fixed + rows as f32 * theme::space::ROW
}
/// How tall the row of "Where compiles went", "By language" and "Problems" is:
/// enough for the tallest of the three, and never less than the usual height.
fn triptych_height(ui: &egui::Ui, view: &View, panel_width: f32) -> f32 {
use theme::layout as l;
l::TRIPTYCH_HEIGHT
.max(l::WHERE_FIXED_HEIGHT)
.max(table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len()))
.max(problems_height(ui, view, panel_width))
}
/// How tall "Speed" is.
fn speed_height(view: &View) -> f32 {
use theme::layout as l;
@@ -550,41 +565,9 @@ fn speed_height(view: &View) -> f32 {
table_height(l::SPEED_FIXED_HEIGHT, 0) + with_histograms as f32 * l::HISTOGRAM_HEIGHT
}
/// How tall "Problems" is in a panel `panel_width` wide: each problem's title, and its detail
/// wrapped to the panel.
fn problems_height(ui: &egui::Ui, view: &View, panel_width: f32) -> f32 {
use theme::layout as l;
if view.problems.is_empty() {
return 88.0;
}
let inner = panel_width - 2.0 * (theme::space::PANEL_PADDING + 1.0);
let details: f32 = view
.problems
.iter()
.map(|problem| style::galley(ui, theme::small(ui, problem.detail.clone()), true, inner).size().y + 21.0)
.sum();
let gaps = (view.problems.len() - 1) as f32 * (theme::space::BETWEEN_PARTS + theme::space::LINE);
l::PROBLEMS_FIXED_HEIGHT + details + gaps
}
/// How tall the row of "Over time" is when "Speed" and "Why compiles were not
/// cacheable" are stacked beside it: the taller of the two sides.
fn charts_height(ui: &egui::Ui, view: &View, side_width: f32) -> f32 {
use theme::layout as l;
let stacked = speed_height(view)
+ theme::space::PANEL_GAP
+ where_went::reasons_height(ui, view, side_width);
l::CHARTS_HEIGHT.max(stacked)
}
/// How tall each chart of "Over time" is in a row `height` tall: the usual
/// height, plus the room a taller row leaves.
fn chart_height(height: f32) -> f32 {
let extra = (height - theme::layout::CHARTS_HEIGHT).max(0.0);
theme::drawing::CHART_HEIGHT + (extra / 2.0 - 2.0 * theme::space::LINE).max(0.0)
}
/// The whole page below the controls: a grid of panels.
/// The whole page below the controls: a grid of panels. Two columns of panels
/// from the medium width up, one below it; the counter strip is six across,
/// three across, or two.
fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec<String>) {
let p = theme::ui(ui);
use theme::layout as l;
@@ -597,7 +580,7 @@ fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec
headline(ui, view, asked);
// Six cards in one row on a wide screen; three in the two-column layout; two on a phone.
// Six counters in one row on a wide screen; three in the medium layout; two on a phone.
let per_row = match columns {
3 => 6,
2 => 3,
@@ -605,95 +588,56 @@ fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec
};
cards::row(ui, view, per_row);
match columns {
3 => {
let third = style::span_width(ui, 3, 1);
let [a, b, c] = row(ui, triptych_height(ui, view, third), &[1, 1, 1]).try_into().expect("three panels");
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
let (_, b) = style::panel(ui, b, "By language", |ui| where_went::languages(ui, view));
let (_, c) = style::panel(ui, c, "Problems", |ui| problems::section(ui, view));
close_row(ui, &[a, b, c]);
if columns >= 2 {
let half = style::span_width(ui, 2, 1);
let languages_h = table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len() + 1);
let [a, b] = row(ui, l::WHERE_FIXED_HEIGHT.max(languages_h), &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
let (_, b) = style::panel(ui, b, "By language", |ui| where_went::languages(ui, view));
close_row(ui, &[a, b]);
// "Over time" over two columns; "Speed" and the reasons stacked in the third, together as tall.
let height = charts_height(ui, view, third);
let [wide, side] = row(ui, height, &[2, 1]).try_into().expect("two panels");
let speed = speed_height(view);
let speed_rect = egui::Rect::from_min_max(side.min, egui::pos2(side.right(), side.top() + speed));
let reasons_rect = egui::Rect::from_min_max(egui::pos2(side.left(), side.top() + speed + gap), side.max);
let (_, wide) = style::panel(ui, wide, "Over time", |ui| {
overtime::section(ui, view, hidden_languages, chart_height(height))
});
let (_, speed) = style::panel(ui, speed_rect, "Speed", |ui| speed::section(ui, view));
let (_, reasons) = style::panel(ui, reasons_rect, "Why compiles were not cacheable", |ui| {
where_went::reasons(ui, view)
});
close_row(ui, &[wide, speed, reasons]);
}
2 => {
let half = style::span_width(ui, 2, 1);
let reasons = where_went::reasons_height(ui, view, half);
let (where_h, languages_h) = (
l::TRIPTYCH_HEIGHT.max(l::WHERE_FIXED_HEIGHT),
table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len()),
);
let problems_h = problems_height(ui, view, half);
// Stacked, "By language" is its own row, so it also holds its head line.
let languages_h = languages_h.max(table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len() + 1));
let stacked = where_h + languages_h + problems_h + 2.0 * gap;
if disclosure::stack_beside(where_h, stacked, reasons) {
// The reasons are tall: the three small panels stack beside them, the last one filling what is left.
let [left, right] = row(ui, stacked.max(reasons), &[1, 1]).try_into().expect("two panels");
let cut = |top: f32, bottom: f32| {
egui::Rect::from_min_max(egui::pos2(left.left(), top), egui::pos2(left.right(), bottom))
};
let a = cut(left.top(), left.top() + where_h);
let b = cut(a.bottom() + gap, a.bottom() + gap + languages_h);
let c = cut(b.bottom() + gap, left.bottom());
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
let (_, b) = style::panel(ui, b, "By language", |ui| where_went::languages(ui, view));
let (_, c) = style::panel(ui, c, "Problems", |ui| problems::section(ui, view));
let (_, d) = style::panel(ui, right, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
close_row(ui, &[a, b, c, d]);
} else {
let height = l::TRIPTYCH_HEIGHT.max(l::WHERE_FIXED_HEIGHT).max(reasons);
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
let (_, b) = style::panel(ui, b, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
close_row(ui, &[a, b]);
let height = l::TRIPTYCH_HEIGHT.max(languages_h).max(problems_h);
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "By language", |ui| where_went::languages(ui, view));
let (_, b) = style::panel(ui, b, "Problems", |ui| problems::section(ui, view));
close_row(ui, &[a, b]);
}
let [a] = row(ui, l::CHARTS_HEIGHT, &[2]).try_into().expect("one panel");
let (_, a) = style::panel(ui, a, "Over time", |ui| {
overtime::section(ui, view, hidden_languages, theme::drawing::CHART_HEIGHT)
});
close_row(ui, &[a]);
single(ui, "Speed", |ui| speed::section(ui, view));
}
_ => {
// One column: the phone's order, each panel as tall as what it holds.
single(ui, "Problems", |ui| problems::section(ui, view));
single(ui, "Where compiles went", |ui| where_went::section(ui, view));
single(ui, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
single(ui, "By language", |ui| where_went::languages(ui, view));
single(ui, "Over time", |ui| {
overtime::section(ui, view, hidden_languages, theme::drawing::CHART_HEIGHT)
});
single(ui, "Speed", |ui| speed::section(ui, view));
}
overtime::filter(ui, view, hidden_languages);
ui.add_space(theme::space::ITEM);
let hidden: &[String] = hidden_languages;
let [a, b] = row(ui, l::CHART_PANEL_HEIGHT, &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "Hit rate over time", |ui| {
overtime::hit_rate_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
});
let (_, b) = style::panel(ui, b, "Compiles over time", |ui| {
overtime::volume_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
});
close_row(ui, &[a, b]);
let height = speed_height(view).max(where_went::reasons_height(ui, view, half));
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "Speed", |ui| speed::section(ui, view));
let (_, b) = style::panel(ui, b, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
close_row(ui, &[a, b]);
} else {
// One column: each panel as tall as what it holds.
single(ui, "Where compiles went", |ui| where_went::section(ui, view));
single(ui, "By language", |ui| where_went::languages(ui, view));
overtime::filter(ui, view, hidden_languages);
ui.add_space(theme::space::ITEM);
let hidden: &[String] = hidden_languages;
single(ui, "Hit rate over time", |ui| {
overtime::hit_rate_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
});
single(ui, "Compiles over time", |ui| {
overtime::volume_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
});
single(ui, "Speed", |ui| speed::section(ui, view));
single(ui, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
}
extras(ui, view);
let open = ui
.ctx()
.data_mut(|data| data.get_temp::<bool>(egui::Id::unique("raw-counters-open")))
.unwrap_or(true);
let full = style::span_width(ui, columns, columns);
let [rect] = row(ui, raw::height(view, full, open), &[columns]).try_into().expect("one panel");
.data_mut(|data| data.get_temp::<bool>(egui::Id::new("raw-counters-open")))
.unwrap_or(false);
let full = style::span_width(ui, 1, 1);
let [rect] = row(ui, raw::height(view, full, open), &[1]).try_into().expect("one panel");
let taken = raw::section(ui, view, rect);
close_row(ui, &[taken]);
ui.add_space(theme::space::PAGE_MARGIN);
@@ -704,12 +648,12 @@ fn extras(ui: &mut egui::Ui, view: &View) {
if view.extras.is_empty() {
return;
}
let columns = theme::columns(ui.available_rect_before_wrap().width());
let columns = theme::columns(ui.available_rect_before_wrap().width()).min(2);
let per_row = columns.min(view.extras.len()).max(1);
for line in view.extras.chunks(per_row) {
let spans: Vec<usize> = line.iter().map(|_| 1).collect();
let height = theme::space::ROW * (line.iter().map(|extra| extra.rows.len()).max().unwrap_or(0) + 1) as f32
+ theme::space::PANEL_PADDING * 2.0 + theme::space::UNDER_TITLE + 12.0;
+ theme::space::PANEL_PAD_Y * 2.0 + theme::space::UNDER_TITLE + 12.0;
let cells = style::cells(ui, height, &spans);
let mut taken = Vec::with_capacity(cells.len());
for (rect, extra) in cells.iter().zip(line) {
@@ -734,9 +678,18 @@ struct Figure<'a> {
small2: String,
/// A trend line and the value it is drawn against.
trend: Option<(&'a [Option<f64>], f64)>,
/// Instead of a trend line and small print: the problems list.
problems: Option<&'a View>,
hover: Option<String>,
}
/// The line the figure's number sits on: every figure's number has this much room, so all
/// the captions below start at the same height whatever size the number is drawn at.
const VALUE_ROW: f32 = theme::px::HEADLINE * 1.25;
/// The room the storage line (meter and text) is given under the figures; a phone has a second text line.
const STORAGE_LINE: f32 = 30.0;
impl Figure<'_> {
/// Draw in a column `width` wide and always the same height.
fn draw(self, ui: &mut egui::Ui, width: f32) {
@@ -747,14 +700,29 @@ impl Figure<'_> {
|ui| {
ui.set_width(width);
ui.spacing_mut().item_spacing = egui::vec2(gap, gap);
let value = egui::Label::new(
egui::RichText::new(&self.value)
.font(theme::number_font(self.size))
.color(self.color),
)
.truncate();
ui.add(value.sense(egui::Sense::hover())).on_hover_text(&self.value);
ui.add(egui::Label::new(theme::small(ui, self.caption.clone())).truncate());
// Shrink a long figure to the column instead of cutting it.
let natural = style::text_width(ui, &self.value, theme::number_font(self.size));
let size = if natural > width { (self.size * width / natural).max(20.0) } else { self.size };
ui.allocate_ui_with_layout(
egui::vec2(width, VALUE_ROW),
egui::Layout::left_to_right(egui::Align::Max),
|ui| {
let value = egui::Label::new(
egui::RichText::new(&self.value)
.font(theme::number_font(size))
.color(self.color),
)
.truncate();
ui.add(value.sense(egui::Sense::hover())).on_hover_text(&self.value);
},
);
ui.add(egui::Label::new(theme::title(ui, self.caption.clone())).truncate());
ui.add_space(gap * 2.0);
if let Some(view) = self.problems {
let room = ui.available_height();
problems::hero_list(ui, view, room);
return;
}
match self.trend {
Some((values, top)) => style::sparkline(ui, theme::drawing::SPARKLINE, values, top, self.color),
None => ui.add_space(theme::drawing::SPARKLINE + gap),
@@ -788,12 +756,6 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
let saved_top = saved.iter().flatten().fold(0.0_f64, |top, seconds| top.max(*seconds));
let problems = view.problems.len();
let worst = view.problems.first();
let problem_color = match worst.map(|problem| problem.severity) {
Some(sccache_dash_api::Severity::Error) => p.bad,
Some(sccache_dash_api::Severity::Warning) => p.warn,
None => p.text,
};
let counts = format!(
"{} compiles · {} from cache · {} built",
@@ -804,10 +766,15 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
let title_text = theme::title(ui, range.label()).text().to_owned();
let counts_text = counts.clone();
let width = ui.available_rect_before_wrap().width();
let rect = egui::Rect::from_min_size(
ui.cursor().min,
egui::vec2(width, theme::layout::HEADLINE_HEIGHT),
);
// Side by side where there is room; one under another on a phone.
let side_by_side = width >= 600.0;
let spacing = theme::space::PANEL_GAP;
let height = if side_by_side {
theme::layout::HEADLINE_HEIGHT
} else {
theme::layout::HEADLINE_HEIGHT + 2.0 * (theme::layout::FIGURE_HEIGHT + spacing) + STORAGE_LINE / 2.0
};
let rect = egui::Rect::from_min_size(ui.cursor().min, egui::vec2(width, height));
let (_, taken) = style::panel_titled(
ui,
rect,
@@ -821,20 +788,19 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
},
|ui| {
let width = ui.available_rect_before_wrap().width();
let spacing = theme::space::PANEL_GAP;
// Side by side where there is room; one under another on a phone.
let side_by_side = width >= 600.0;
let columns = if side_by_side { 3.0 } else { 1.0 };
let column = (width - spacing * (columns - 1.0)) / columns;
ui.add_space(theme::space::ITEM);
let draw = |ui: &mut egui::Ui, figure: Figure<'_>| figure.draw(ui, column);
// Timeouts, cache errors and forced recaches are inside the built count, as sccache counts them.
let first = Figure {
value: fmt::percent(totals.hit_rate()),
size: theme::px::HEADLINE,
color: theme::hit_rate_color(totals.hit_rate(), p),
color: p.hero,
caption: "from cache".into(),
small: format!("{} of all compiler calls", fmt::percent(totals.hit_rate_of_all())),
trend: Some((&rates, 1.0)),
problems: None,
hover: None,
small2: String::new(),
};
@@ -871,46 +837,51 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
let second = Figure {
value,
size,
color: p.text,
color: p.hero,
caption: "saved (rough)".into(),
small,
small2,
trend: Some((&saved, saved_top)),
problems: None,
hover: Some(view.time_saved.note.clone()),
};
let third = Figure {
value: if problems == 1 {
"1 problem".into()
} else if problems == 0 {
"No problems".into()
} else {
format!("{} problems", fmt::count(problems as u64))
},
size: theme::px::CARD_NUMBER,
color: problem_color,
caption: worst
.map(|problem| problem.title.clone())
.unwrap_or_else(|| "Nothing needs attention".into()),
value: fmt::count(problems as u64),
size: theme::px::HEADLINE,
color: if problems > 0 { p.bad } else { p.text },
caption: if problems == 1 { "problem".into() } else { "problems".into() },
small: String::new(),
small2: String::new(),
trend: None,
problems: Some(view),
hover: None,
};
let top = ui.cursor().top();
let left = ui.cursor().left();
if side_by_side {
ui.horizontal(|ui| {
ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = spacing;
draw(ui, first);
draw(ui, second);
draw(ui, third);
});
// A hairline in the middle of each gutter between figures.
let y = top..=top + theme::layout::FIGURE_HEIGHT;
for index in 1..3 {
let x = left + index as f32 * column + (index as f32 - 0.5) * spacing;
ui.painter().vline(x.round() + 0.5, y.clone(), egui::Stroke::new(1.0, p.grid));
}
} else {
draw(ui, first);
ui.add_space(spacing);
draw(ui, second);
ui.add_space(spacing);
draw(ui, third);
}
ui.add_space(theme::space::ITEM);
style::rule(ui);
ui.add_space(theme::space::PANEL_GAP);
ui.add_space(theme::space::ITEM + 2.0);
let server = &view.server;
let mut parts = Vec::new();
@@ -918,7 +889,7 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
// sccache words it `Local disk: "/home/me/.cache/sccache"`; the kind is enough here.
let kind = location.split(':').next().unwrap_or(location);
let kind = if kind.eq_ignore_ascii_case("LOCAL DISK") {
"local disk".to_owned()
"Local disk".to_owned()
} else {
kind.to_owned()
};
@@ -938,15 +909,25 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
}
.to_owned(),
);
let line = format!("Cache: {}", parts.join(" · "));
let response = ui.add(egui::Label::new(theme::small(ui, line)).wrap());
if let Some(location) = &server.cache_location {
response.on_hover_text(location.clone());
}
let line = parts.join(" · ");
// The meter first, then the text under it, in a box of fixed height.
let lines = if side_by_side { 1.0 } else { 2.0 };
let text_height = STORAGE_LINE / 2.0 * lines;
if let (Some(size), Some(max)) = (server.cache_size, server.max_cache_size) {
let full = if max > 0 { size as f64 / max as f64 } else { 0.0 };
let color = if full >= theme::state::CACHE_FULL { p.bad } else { p.from_cache };
let color = if full >= theme::state::CACHE_FULL { p.bad } else { p.hero };
style::meter(ui, theme::drawing::USAGE_BAR, full, color);
ui.add_space(theme::space::ITEM);
}
let response = ui
.allocate_ui_with_layout(
egui::vec2(width, text_height),
egui::Layout::top_down(egui::Align::Min),
|ui| ui.add(egui::Label::new(theme::small(ui, line)).wrap()),
)
.inner;
if let Some(location) = &server.cache_location {
response.on_hover_text(location.clone());
}
},
);