Compare commits

..
2 Commits
Author SHA1 Message Date
swaitsandClaude Opus 5.5 3a2bcefd38 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>
2026-11-30 09:14:58 -07:00
swaitsandClaude Fable 5.2 06abc4de80 Speed panel: say the time is for one crate's compile, not a whole build
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-28 18:47:40 -07:00
9 changed files with 376 additions and 363 deletions

No files matched your search

+158 -177
View File
@@ -250,35 +250,48 @@ fn theme_labels() -> [&'static str; 3] {
ThemeChoice::ALL.map(|theme| theme.name()) 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. /// About how wide the row of actions is, from the width of its labels.
fn actions_width(ui: &egui::Ui) -> f32 { fn actions_width(ui: &egui::Ui) -> f32 {
let medium = theme::medium(theme::px::BODY); let medium = theme::medium(theme::px::BODY);
let label = |text: &str| style::text_width(ui, text, medium.clone()) + 22.0; let label = |text: &str| style::text_width(ui, text, medium.clone()) + 18.0;
let gaps = theme::space::PANEL_GAP; let gaps = theme::space::TOOL_GAP;
label(&fmt::refresh_label(30)) + label("Refresh") 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>() + 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") + label("Copy summary") + label("Export JSON") + label("Zero stats")
+ theme::space::TOOLBAR_NOTE_WIDTH + theme::space::TOOLBAR_NOTE_WIDTH
+ gaps * 7.0 + gaps * 7.0
} }
/// The row of controls that stays at the top of the page: the range as one /// The slim bar at the top of the page: the wordmark and the range at the left; the
/// segmented control at the left; the actions at the right, on their own lines /// actions at the right, on their own line where there is no room beside the range.
/// where there is no room beside the range.
fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) { fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
let ctx = ui.ctx().clone(); let ctx = ui.ctx().clone();
let now = Dashboard::now(&ctx); let now = Dashboard::now(&ctx);
let gap = theme::space::PANEL_GAP; let gap = theme::space::TOOL_GAP;
let margin = theme::space::PAGE_MARGIN; 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 width = ui.available_rect_before_wrap().width() - 2.0 * margin;
let medium = theme::medium(theme::px::BODY); let medium = theme::medium(theme::px::BODY);
let range_width: f32 = Range::ALL let range_width: f32 = Range::ALL
.iter() .iter()
.map(|range| style::text_width(ui, range.code(), medium.clone()) + 2.0 * theme::space::CONTROL_PAD) .map(|range| style::text_width(ui, range.code(), medium.clone()) + 2.0 * theme::space::CONTROL_PAD)
.sum(); .sum();
let beside = width >= theme::layout::TOOLBAR_TWO_LINES_BELOW; let left_width = wordmark_width(ui) + 2.0 * theme::space::PANEL_GAP + range_width;
let one_line = beside && range_width + gap + actions_width(ui) <= 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 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(); 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.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = gap; ui.spacing_mut().item_spacing.x = gap;
ui.add_space(margin); 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 let Some(index) = style::segmented(ui, "range", &labels, chosen) {
if index != chosen { if index != chosen {
dashboard.range = Range::ALL[index]; dashboard.range = Range::ALL[index];
@@ -294,7 +309,7 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
} }
} }
if one_line { 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( ui.allocate_ui_with_layout(
egui::vec2(actions_width(ui), theme::layout::TOOLBAR_HEIGHT), egui::vec2(actions_width(ui), theme::layout::TOOLBAR_HEIGHT),
egui::Layout::left_to_right(egui::Align::Center), egui::Layout::left_to_right(egui::Align::Center),
@@ -304,8 +319,8 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
}); });
if !one_line { if !one_line {
let height = theme::layout::TOOLBAR_HEIGHT; let height = theme::layout::TOOLBAR_HEIGHT;
ui.add_space(margin); ui.add_space(gap);
let room = ui.available_rect_before_wrap().width(); let room = ui.available_rect_before_wrap().width() - 2.0 * margin;
let group_width = if phone { room } else { actions_width(ui).min(room) }; 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 phone the actions wrap at the left; on a narrower window they sit
// on a second line, at the right. // on a second line, at the right.
@@ -314,6 +329,8 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
} else { } else {
egui::Layout::right_to_left(egui::Align::Center) egui::Layout::right_to_left(egui::Align::Center)
}; };
ui.horizontal(|ui| {
ui.add_space(margin);
ui.allocate_ui_with_layout(egui::vec2(room, height), layout, |ui| { ui.allocate_ui_with_layout(egui::vec2(room, height), layout, |ui| {
if !phone { if !phone {
ui.allocate_ui_with_layout( ui.allocate_ui_with_layout(
@@ -326,8 +343,16 @@ fn controls(dashboard: &mut Dashboard, ui: &mut egui::Ui) {
actions(dashboard, ui, &ctx, now, 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. /// 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. // 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 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 (rect, _) = ui.allocate_exact_size(egui::vec2(width, height), egui::Sense::hover());
let mut place = ui.new_child( let mut place = ui.new_child(
egui::UiBuilder::new() 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")) egui::Area::new(egui::Id::unique("lost-contact"))
.anchor( .anchor(
egui::Align2::RIGHT_TOP, 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) .order(egui::Order::Foreground)
.show(ctx, |ui| { .show(ctx, |ui| {
@@ -491,9 +516,9 @@ fn lost_contact(ctx: &egui::Context, error: &str, from: i64, page_width: f32) {
.fill(p.panel) .fill(p.panel)
.stroke(egui::Stroke::new(1.0, p.bad)) .stroke(egui::Stroke::new(1.0, p.bad))
.corner_radius(theme::space::PANEL_RADIUS) .corner_radius(theme::space::PANEL_RADIUS)
.inner_margin(theme::space::PANEL_PADDING) .inner_margin(theme::space::PANEL_PAD_Y)
.show(ui, |ui| { .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( ui.add(
egui::Label::new( egui::Label::new(
theme::strong(format!( theme::strong(format!(
@@ -529,16 +554,6 @@ fn table_height(fixed: f32, rows: usize) -> f32 {
fixed + rows as f32 * theme::space::ROW 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. /// How tall "Speed" is.
fn speed_height(view: &View) -> f32 { fn speed_height(view: &View) -> f32 {
use theme::layout as l; 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 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 /// The whole page below the controls: a grid of panels. Two columns of panels
/// wrapped to the panel. /// from the medium width up, one below it; the counter strip is six across,
fn problems_height(ui: &egui::Ui, view: &View, panel_width: f32) -> f32 { /// three across, or two.
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.
fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec<String>) { fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec<String>) {
let p = theme::ui(ui); let p = theme::ui(ui);
use theme::layout as l; 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); 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 { let per_row = match columns {
3 => 6, 3 => 6,
2 => 3, 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); cards::row(ui, view, per_row);
match columns { if columns >= 2 {
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]);
// "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 half = style::span_width(ui, 2, 1);
let reasons = where_went::reasons_height(ui, view, half); let languages_h = table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len() + 1);
let (where_h, languages_h) = ( let [a, b] = row(ui, l::WHERE_FIXED_HEIGHT.max(languages_h), &[1, 1]).try_into().expect("two panels");
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 (_, 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 (_, 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]);
let (_, d) = style::panel(ui, right, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
close_row(ui, &[a, b, c, d]); overtime::filter(ui, view, hidden_languages);
} else { ui.add_space(theme::space::ITEM);
let height = l::TRIPTYCH_HEIGHT.max(l::WHERE_FIXED_HEIGHT).max(reasons); 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, 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 (_, 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)); let (_, b) = style::panel(ui, b, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
close_row(ui, &[a, b]); close_row(ui, &[a, b]);
let height = l::TRIPTYCH_HEIGHT.max(languages_h).max(problems_h); } else {
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels"); // One column: each panel as tall as what it holds.
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, "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, "By language", |ui| where_went::languages(ui, view));
single(ui, "Over time", |ui| { overtime::filter(ui, view, hidden_languages);
overtime::section(ui, view, hidden_languages, theme::drawing::CHART_HEIGHT) 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, "Speed", |ui| speed::section(ui, view));
} single(ui, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
} }
extras(ui, view); extras(ui, view);
let open = ui let open = ui
.ctx() .ctx()
.data_mut(|data| data.get_temp::<bool>(egui::Id::unique("raw-counters-open"))) .data_mut(|data| data.get_temp::<bool>(egui::Id::new("raw-counters-open")))
.unwrap_or(true); .unwrap_or(false);
let full = style::span_width(ui, columns, columns); let full = style::span_width(ui, 1, 1);
let [rect] = row(ui, raw::height(view, full, open), &[columns]).try_into().expect("one panel"); let [rect] = row(ui, raw::height(view, full, open), &[1]).try_into().expect("one panel");
let taken = raw::section(ui, view, rect); let taken = raw::section(ui, view, rect);
close_row(ui, &[taken]); close_row(ui, &[taken]);
ui.add_space(theme::space::PAGE_MARGIN); ui.add_space(theme::space::PAGE_MARGIN);
@@ -704,12 +648,12 @@ fn extras(ui: &mut egui::Ui, view: &View) {
if view.extras.is_empty() { if view.extras.is_empty() {
return; 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); let per_row = columns.min(view.extras.len()).max(1);
for line in view.extras.chunks(per_row) { for line in view.extras.chunks(per_row) {
let spans: Vec<usize> = line.iter().map(|_| 1).collect(); 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 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 cells = style::cells(ui, height, &spans);
let mut taken = Vec::with_capacity(cells.len()); let mut taken = Vec::with_capacity(cells.len());
for (rect, extra) in cells.iter().zip(line) { for (rect, extra) in cells.iter().zip(line) {
@@ -734,9 +678,18 @@ struct Figure<'a> {
small2: String, small2: String,
/// A trend line and the value it is drawn against. /// A trend line and the value it is drawn against.
trend: Option<(&'a [Option<f64>], f64)>, trend: Option<(&'a [Option<f64>], f64)>,
/// Instead of a trend line and small print: the problems list.
problems: Option<&'a View>,
hover: Option<String>, 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<'_> { impl Figure<'_> {
/// Draw in a column `width` wide and always the same height. /// Draw in a column `width` wide and always the same height.
fn draw(self, ui: &mut egui::Ui, width: f32) { fn draw(self, ui: &mut egui::Ui, width: f32) {
@@ -747,14 +700,29 @@ impl Figure<'_> {
|ui| { |ui| {
ui.set_width(width); ui.set_width(width);
ui.spacing_mut().item_spacing = egui::vec2(gap, gap); ui.spacing_mut().item_spacing = egui::vec2(gap, gap);
// 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( let value = egui::Label::new(
egui::RichText::new(&self.value) egui::RichText::new(&self.value)
.font(theme::number_font(self.size)) .font(theme::number_font(size))
.color(self.color), .color(self.color),
) )
.truncate(); .truncate();
ui.add(value.sense(egui::Sense::hover())).on_hover_text(&self.value); ui.add(value.sense(egui::Sense::hover())).on_hover_text(&self.value);
ui.add(egui::Label::new(theme::small(ui, self.caption.clone())).truncate()); },
);
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 { match self.trend {
Some((values, top)) => style::sparkline(ui, theme::drawing::SPARKLINE, values, top, self.color), Some((values, top)) => style::sparkline(ui, theme::drawing::SPARKLINE, values, top, self.color),
None => ui.add_space(theme::drawing::SPARKLINE + gap), 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 saved_top = saved.iter().flatten().fold(0.0_f64, |top, seconds| top.max(*seconds));
let problems = view.problems.len(); 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!( let counts = format!(
"{} compiles · {} from cache · {} built", "{} 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 title_text = theme::title(ui, range.label()).text().to_owned();
let counts_text = counts.clone(); let counts_text = counts.clone();
let width = ui.available_rect_before_wrap().width(); let width = ui.available_rect_before_wrap().width();
let rect = egui::Rect::from_min_size( // Side by side where there is room; one under another on a phone.
ui.cursor().min, let side_by_side = width >= 600.0;
egui::vec2(width, theme::layout::HEADLINE_HEIGHT), 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( let (_, taken) = style::panel_titled(
ui, ui,
rect, rect,
@@ -821,20 +788,19 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
}, },
|ui| { |ui| {
let width = ui.available_rect_before_wrap().width(); 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 columns = if side_by_side { 3.0 } else { 1.0 };
let column = (width - spacing * (columns - 1.0)) / columns; 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); 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. // Timeouts, cache errors and forced recaches are inside the built count, as sccache counts them.
let first = Figure { let first = Figure {
value: fmt::percent(totals.hit_rate()), value: fmt::percent(totals.hit_rate()),
size: theme::px::HEADLINE, size: theme::px::HEADLINE,
color: theme::hit_rate_color(totals.hit_rate(), p), color: p.hero,
caption: "from cache".into(), caption: "from cache".into(),
small: format!("{} of all compiler calls", fmt::percent(totals.hit_rate_of_all())), small: format!("{} of all compiler calls", fmt::percent(totals.hit_rate_of_all())),
trend: Some((&rates, 1.0)), trend: Some((&rates, 1.0)),
problems: None,
hover: None, hover: None,
small2: String::new(), small2: String::new(),
}; };
@@ -871,46 +837,51 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
let second = Figure { let second = Figure {
value, value,
size, size,
color: p.text, color: p.hero,
caption: "saved (rough)".into(), caption: "saved (rough)".into(),
small, small,
small2, small2,
trend: Some((&saved, saved_top)), trend: Some((&saved, saved_top)),
problems: None,
hover: Some(view.time_saved.note.clone()), hover: Some(view.time_saved.note.clone()),
}; };
let third = Figure { let third = Figure {
value: if problems == 1 { value: fmt::count(problems as u64),
"1 problem".into() size: theme::px::HEADLINE,
} else if problems == 0 { color: if problems > 0 { p.bad } else { p.text },
"No problems".into() caption: if problems == 1 { "problem".into() } else { "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()),
small: String::new(), small: String::new(),
small2: String::new(), small2: String::new(),
trend: None, trend: None,
problems: Some(view),
hover: None, hover: None,
}; };
let top = ui.cursor().top();
let left = ui.cursor().left();
if side_by_side { if side_by_side {
ui.horizontal(|ui| { ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = spacing; ui.spacing_mut().item_spacing.x = spacing;
draw(ui, first); draw(ui, first);
draw(ui, second); draw(ui, second);
draw(ui, third); 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 { } else {
draw(ui, first); draw(ui, first);
ui.add_space(spacing);
draw(ui, second); draw(ui, second);
ui.add_space(spacing);
draw(ui, third); draw(ui, third);
} }
ui.add_space(theme::space::ITEM);
style::rule(ui); style::rule(ui);
ui.add_space(theme::space::PANEL_GAP); ui.add_space(theme::space::ITEM + 2.0);
let server = &view.server; let server = &view.server;
let mut parts = Vec::new(); 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. // sccache words it `Local disk: "/home/me/.cache/sccache"`; the kind is enough here.
let kind = location.split(':').next().unwrap_or(location); let kind = location.split(':').next().unwrap_or(location);
let kind = if kind.eq_ignore_ascii_case("LOCAL DISK") { let kind = if kind.eq_ignore_ascii_case("LOCAL DISK") {
"local disk".to_owned() "Local disk".to_owned()
} else { } else {
kind.to_owned() kind.to_owned()
}; };
@@ -938,15 +909,25 @@ fn headline(ui: &mut egui::Ui, view: &View, asked: Range) {
} }
.to_owned(), .to_owned(),
); );
let line = format!("Cache: {}", parts.join(" · ")); let line = parts.join(" · ");
let response = ui.add(egui::Label::new(theme::small(ui, line)).wrap()); // The meter first, then the text under it, in a box of fixed height.
if let Some(location) = &server.cache_location { let lines = if side_by_side { 1.0 } else { 2.0 };
response.on_hover_text(location.clone()); let text_height = STORAGE_LINE / 2.0 * lines;
}
if let (Some(size), Some(max)) = (server.cache_size, server.max_cache_size) { 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 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); 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());
} }
}, },
); );
+15 -8
View File
@@ -1,4 +1,4 @@
//! The six stat cards under the headline: all the same size, tops in a line. //! The six counters under the headline: one quiet strip, all cells the same size, tops in a line.
use eframe::egui::{self, Color32, Pos2, Rect, RichText}; use eframe::egui::{self, Color32, Pos2, Rect, RichText};
@@ -77,25 +77,32 @@ pub fn row(ui: &mut egui::Ui, view: &View, per_row: usize) {
let left = ui.cursor().left(); let left = ui.cursor().left();
let mut top = ui.cursor().top(); let mut top = ui.cursor().top();
let width = ui.available_rect_before_wrap().width(); let width = ui.available_rect_before_wrap().width();
let card_width = (width - theme::space::PANEL_GAP * (per_row - 1) as f32) / per_row as f32; let cell_width = width / per_row as f32;
for line in cards.chunks(per_row) { let height = theme::layout::STRIP_ROW_HEIGHT;
let mut x = left; let rule = egui::Stroke::new(1.0, p.border);
for card in line { ui.painter().hline(left..=left + width, top + 0.5, rule);
for (line_index, line) in cards.chunks(per_row).enumerate() {
if line_index > 0 {
ui.painter().hline(left..=left + width, top + 0.5, egui::Stroke::new(1.0, p.grid));
}
for (index, card) in line.iter().enumerate() {
let change = change(card.count, card.previous, range, card.good_when_up, p); let change = change(card.count, card.previous, range, card.good_when_up, p);
style::card( style::card(
ui, ui,
Rect::from_min_size(Pos2::new(x, top), egui::vec2(card_width, theme::layout::CARD_HEIGHT)), Rect::from_min_size(Pos2::new(left + index as f32 * cell_width, top), egui::vec2(cell_width, height)),
index == 0,
card.title, card.title,
&fmt::count(card.count), &fmt::count(card.count),
&card.detail, &card.detail,
change, change,
card.color.unwrap_or(p.text), card.color.unwrap_or(p.text),
); );
x += card_width + theme::space::PANEL_GAP;
} }
top += theme::layout::CARD_HEIGHT + theme::space::PANEL_GAP; top += height;
} }
ui.painter().hline(left..=left + width, top - 0.5, rule);
ui.add_space(top - ui.cursor().top()); ui.add_space(top - ui.cursor().top());
ui.add_space(theme::space::PANEL_GAP);
} }
struct Card { struct Card {
+14 -14
View File
@@ -18,25 +18,25 @@ pub fn hit_rate(hits: u64, misses: u64) -> Option<f64> {
(hits + misses > 0).then(|| hits as f64 / (hits + misses) as f64) (hits + misses > 0).then(|| hits as f64 / (hits + misses) as f64)
} }
pub fn section(ui: &mut Ui, view: &View, hidden: &mut Vec<String>, chart_height: f32) { fn axes_of(view: &View, dark: bool) -> Axes {
let p = theme::ui(ui);
filter(ui, view, hidden);
let tz = fmt::local_offset() as f64;
let step = bucket_step(&view.buckets, view.range); let step = bucket_step(&view.buckets, view.range);
let axes = Axes { Axes {
window: range_window(view, step), window: range_window(view, step),
step, step,
tz, tz: fmt::local_offset() as f64,
dark: p.dark, dark,
}; }
}
ui.add_space(theme::space::BETWEEN_PARTS); /// The body of the "Hit rate over time" panel.
part_title(ui, "Hit rate"); pub fn hit_rate_panel(ui: &mut Ui, view: &View, hidden: &[String], chart_height: f32) {
let axes = axes_of(view, theme::ui(ui).dark);
hit_rate_chart(ui, view, hidden, axes, chart_height); hit_rate_chart(ui, view, hidden, axes, chart_height);
}
ui.add_space(theme::space::BETWEEN_PARTS); /// The body of the "Compiles over time" panel.
part_title(ui, "Compiles"); pub fn volume_panel(ui: &mut Ui, view: &View, hidden: &[String], chart_height: f32) {
let axes = axes_of(view, theme::ui(ui).dark);
volume_chart(ui, view, hidden, axes, chart_height); volume_chart(ui, view, hidden, axes, chart_height);
} }
@@ -46,7 +46,7 @@ pub fn part_title(ui: &mut Ui, text: &str) {
} }
/// Checkboxes that narrow both charts to some languages. /// Checkboxes that narrow both charts to some languages.
fn filter(ui: &mut Ui, view: &View, hidden: &mut Vec<String>) { pub fn filter(ui: &mut Ui, view: &View, hidden: &mut Vec<String>) {
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing.x = theme::space::PANEL_GAP; ui.spacing_mut().item_spacing.x = theme::space::PANEL_GAP;
let mut all = hidden.is_empty(); let mut all = hidden.is_empty();
+60 -24
View File
@@ -1,41 +1,77 @@
//! Problems: what is wrong, most serious first. A dot for how serious, the //! Problems: what is wrong, most serious first, as the list under the hero's problem
//! title, and the detail in small print. //! count. Each problem is a line (a square for how serious, its title, a chevron); clicking
//! it shows the full explanation under it, as the reasons list does. The list scrolls inside
//! a fixed height, so a longer list or an open explanation never moves the page.
use eframe::egui::{self, Ui}; use eframe::egui::{self, Sense, Ui};
use sccache_dash_api::{Severity, View}; use sccache_dash_api::{Severity, View};
use crate::style;
use crate::theme; use crate::theme;
use crate::where_went::chevron;
pub fn section(ui: &mut Ui, view: &View) { const ROW: f32 = 22.0;
const GAP: f32 = 8.0;
const CHEVRON: f32 = 8.0;
fn open_id(title: &str) -> egui::Id {
egui::Id::new(("problem-open", title))
}
/// The problems of `view` in a list `height` tall.
pub fn hero_list(ui: &mut Ui, view: &View, height: f32) {
let p = theme::ui(ui); let p = theme::ui(ui);
if view.problems.is_empty() { if view.problems.is_empty() {
// Nothing to alarm: a calm dot in the good colour and the words. ui.add(egui::Label::new(theme::small(ui, "Nothing needs attention.")).truncate());
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = theme::space::ITEM + 2.0;
style::dot(ui, p.good);
ui.label(theme::body("No problems"));
});
ui.add(egui::Label::new(theme::small(ui, "Nothing needs attention.")).wrap());
return; return;
} }
for (index, problem) in view.problems.iter().enumerate() { egui::ScrollArea::vertical()
if index > 0 { .id_salt("hero-problems")
ui.add_space(theme::space::BETWEEN_PARTS); .max_height(height)
.auto_shrink([false, false])
.show(ui, |ui| {
ui.spacing_mut().item_spacing.y = 0.0;
let width = ui.available_width();
let indent = theme::drawing::SEVERITY_DOT + GAP;
for problem in &view.problems {
let id = open_id(&problem.title);
let open = ui.ctx().data(|data| data.get_temp::<bool>(id)).unwrap_or(false);
let (row, response) = ui.allocate_exact_size(egui::vec2(width, ROW), Sense::click());
let response = response.on_hover_cursor(egui::CursorIcon::PointingHand);
response.widget_info(|| {
egui::WidgetInfo::labeled(egui::WidgetType::Button, true, problem.title.as_str())
});
if response.clicked() {
ui.ctx().data_mut(|data| data.insert_temp(id, !open));
ui.ctx().request_repaint();
}
if response.hovered() {
ui.painter().rect_filled(row, theme::space::CONTROL_RADIUS, p.hover);
} }
let color = match problem.severity { let color = match problem.severity {
Severity::Error => p.bad, Severity::Error => p.bad,
Severity::Warning => p.warn, Severity::Warning => p.warn,
}; };
ui.horizontal(|ui| { let side = theme::drawing::SEVERITY_DOT;
ui.spacing_mut().item_spacing.x = theme::space::ITEM + 2.0; ui.painter().rect_filled(
style::dot(ui, color); egui::Rect::from_center_size(egui::pos2(row.left() + side / 2.0, row.center().y), egui::vec2(side, side)),
ui.add( 0.0,
egui::Label::new( color,
theme::strong(problem.title.clone()).color(color),
),
); );
}); let chevron_x = row.right() - CHEVRON;
ui.add(egui::Label::new(theme::small(ui, problem.detail.clone())).wrap()); chevron(ui.painter(), egui::pos2(chevron_x + CHEVRON / 2.0, row.center().y), open, p.muted);
let title = crate::style::galley(ui, theme::body(problem.title.clone()), false, f32::INFINITY);
let room = (chevron_x - GAP - row.left() - indent).max(10.0);
let place = egui::Rect::from_min_size(egui::pos2(row.left() + indent, row.top()), egui::vec2(room, ROW));
ui.painter().with_clip_rect(place).galley(
egui::pos2(place.left(), row.center().y - title.size().y / 2.0),
title,
p.text,
);
if open {
let detail = crate::style::galley(ui, theme::small(ui, problem.detail.clone()), true, width - indent);
let (place, _) = ui.allocate_exact_size(egui::vec2(width, detail.size().y + 6.0), Sense::hover());
ui.painter().galley(egui::pos2(place.left() + indent, place.top()), detail, p.muted);
} }
}
});
} }
+5 -5
View File
@@ -1,6 +1,6 @@
//! Raw counters: the sccache stats exactly as the server read them, as compact //! Raw counters: the sccache stats exactly as the server read them, as compact
//! key/value lines that flow in columns. The panel opens and closes; it starts //! key/value lines that flow in columns. The panel opens and closes; it starts
//! open. //! closed, as one line.
use std::cell::Cell; use std::cell::Cell;
@@ -44,7 +44,7 @@ fn columns(inner: f32) -> usize {
/// How tall the panel is when it is `width` wide: its title and, when open, /// How tall the panel is when it is `width` wide: its title and, when open,
/// its lines. /// its lines.
pub fn height(view: &View, width: f32, open: bool) -> f32 { pub fn height(view: &View, width: f32, open: bool) -> f32 {
let title = theme::space::ROW + theme::space::UNDER_TITLE + 2.0 * (theme::space::PANEL_PADDING + 1.0); let title = theme::space::ROW + theme::space::UNDER_TITLE + 2.0 * theme::space::PANEL_PAD_Y;
if !open { if !open {
return title - theme::space::UNDER_TITLE + theme::space::LINE; return title - theme::space::UNDER_TITLE + theme::space::LINE;
} }
@@ -54,14 +54,14 @@ pub fn height(view: &View, width: f32, open: bool) -> f32 {
leaves(&view.raw, String::new(), &mut out); leaves(&view.raw, String::new(), &mut out);
lines = out.len(); lines = out.len();
} }
let inner = width - 2.0 * (theme::space::PANEL_PADDING + 1.0); let inner = width - 2.0 * theme::space::PANEL_PADDING;
title + lines.div_ceil(columns(inner)) as f32 * theme::space::ROW title + lines.div_ceil(columns(inner)) as f32 * theme::space::ROW
} }
/// The panel at `rect`; its title opens and closes it. Returns the rect it took. /// The panel at `rect`; its title opens and closes it. Returns the rect it took.
pub fn section(ui: &mut Ui, view: &View, rect: Rect) -> Rect { pub fn section(ui: &mut Ui, view: &View, rect: Rect) -> Rect {
let id = egui::Id::unique("raw-counters-open"); let id = egui::Id::new("raw-counters-open");
let open = Cell::new(ui.ctx().data_mut(|data| data.get_temp::<bool>(id)).unwrap_or(true)); let open = Cell::new(ui.ctx().data_mut(|data| data.get_temp::<bool>(id)).unwrap_or(false));
let (_, taken) = style::panel_titled( let (_, taken) = style::panel_titled(
ui, ui,
rect, rect,
+8 -8
View File
@@ -19,8 +19,8 @@ pub fn section(ui: &mut Ui, view: &View) {
let timing = view.timing; let timing = view.timing;
let rows = [ let rows = [
("Cache fetch (a hit)", timing.avg_hit_read_ms, p.from_cache), ("Cache fetch (a hit)", timing.avg_hit_read_ms, p.from_cache),
("Cache write", timing.avg_cache_write_ms, p.built), ("Cache write", timing.avg_cache_write_ms, p.muted),
("Build (compile)", timing.avg_compile_ms, p.muted), ("Compile one crate", timing.avg_compile_ms, p.built),
]; ];
for (label, ms, color) in rows { for (label, ms, color) in rows {
ui.horizontal(|ui| { ui.horizontal(|ui| {
@@ -60,14 +60,14 @@ pub fn section(ui: &mut Ui, view: &View) {
let write = timing.avg_cache_write_ms; let write = timing.avg_cache_write_ms;
let build = timing.avg_compile_ms; let build = timing.avg_compile_ms;
let sentence = if let Some(times) = faster(build, hit) { let sentence = if let Some(times) = faster(build, hit) {
format!("A cache hit is about {times}x faster than building.") format!("A cache hit is about {times}x faster than compiling the crate.")
} else if let Some(times) = faster(build, write) { } else if let Some(times) = faster(build, write) {
format!("Writing to the cache is about {times}x faster than building.") format!("Writing to the cache is about {times}x faster than compiling the crate.")
} else { } else {
"There are no timings to compare in this range.".to_owned() "There are no timings to compare in this range.".to_owned()
}; };
ui.add_space(theme::space::ITEM); ui.add_space(theme::space::ITEM);
ui.add(egui::Label::new(theme::strong(sentence)).wrap()); ui.add(egui::Label::new(theme::strong(sentence).color(p.hero)).wrap());
ui.add( ui.add(
egui::Label::new( egui::Label::new(
theme::small( theme::small(
@@ -87,7 +87,7 @@ fn faster(slower: Option<f64>, faster: Option<f64>) -> Option<String> {
(slower > 0.0 && faster > 0.0).then(|| fmt::round_number(slower / faster)) (slower > 0.0 && faster > 0.0).then(|| fmt::round_number(slower / faster))
} }
/// "How long builds take, by language": one histogram per language, all on the /// "How long one crate takes to compile": one histogram per language, all on the
/// same log scale of build time, with the mean, median and p90 marked. /// same log scale of build time, with the mean, median and p90 marked.
fn build_times(ui: &mut Ui, view: &View) { fn build_times(ui: &mut Ui, view: &View) {
let p = theme::ui(ui); let p = theme::ui(ui);
@@ -100,7 +100,7 @@ fn build_times(ui: &mut Ui, view: &View) {
return; return;
} }
ui.add_space(theme::space::BETWEEN_PARTS); ui.add_space(theme::space::BETWEEN_PARTS);
crate::overtime::part_title(ui, "How long builds take, by language"); crate::overtime::part_title(ui, "How long one crate takes to compile");
// One shared axis, from a quarter step before the fastest bin to a quarter step after the slowest. // One shared axis, from a quarter step before the fastest bin to a quarter step after the slowest.
let (mut low, mut high) = (f64::MAX, 0.0_f64); let (mut low, mut high) = (f64::MAX, 0.0_f64);
@@ -118,7 +118,7 @@ fn build_times(ui: &mut Ui, view: &View) {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = theme::space::ITEM; ui.spacing_mut().item_spacing.x = theme::space::ITEM;
ui.add(egui::Label::new(theme::strong(times.language.clone())).truncate()); ui.add(egui::Label::new(theme::strong(times.language.clone())).truncate());
ui.add(egui::Label::new(theme::small(ui, format!("{} builds", fmt::count(times.compiles)))).truncate()); ui.add(egui::Label::new(theme::small(ui, format!("{} compiles", fmt::count(times.compiles)))).truncate());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.spacing_mut().item_spacing.x = theme::space::ITEM; ui.spacing_mut().item_spacing.x = theme::space::ITEM;
for (name, value, color) in [ for (name, value, color) in [
+33 -48
View File
@@ -92,7 +92,7 @@ pub fn rule(ui: &mut Ui) {
// ---- Panels and cards ---- // ---- Panels and cards ----
/// A panel with a title, at `rect`: panel colour, a 1 px border, 8 px corners. /// A panel with a title, at `rect`: no fill and no box, a hairline across its top.
/// It comes out at least as tall as `rect`; the rect it took is returned second. /// It comes out at least as tall as `rect`; the rect it took is returned second.
pub fn panel<R>(ui: &mut Ui, rect: Rect, title: &str, body: impl FnOnce(&mut Ui) -> R) -> (R, Rect) { pub fn panel<R>(ui: &mut Ui, rect: Rect, title: &str, body: impl FnOnce(&mut Ui) -> R) -> (R, Rect) {
let text = theme::title(ui, title).text().to_owned(); let text = theme::title(ui, title).text().to_owned();
@@ -114,29 +114,20 @@ pub fn panel_titled<R>(
body: impl FnOnce(&mut Ui) -> R, body: impl FnOnce(&mut Ui) -> R,
) -> (R, Rect) { ) -> (R, Rect) {
let p = p(ui); let p = p(ui);
let pad = space::PANEL_PADDING + 1.0; let pad = egui::vec2(space::PANEL_PADDING, space::PANEL_PAD_Y);
let mut inner = ui.new_child( let mut inner = ui.new_child(
egui::UiBuilder::new() egui::UiBuilder::new()
.max_rect(rect.shrink(pad)) .max_rect(rect.shrink2(pad))
.layout(Layout::top_down(Align::Min)), .layout(Layout::top_down(Align::Min)),
); );
inner.set_width((rect.width() - 2.0 * pad).max(0.0)); inner.set_width((rect.width() - 2.0 * pad.x).max(0.0));
inner.set_min_height((rect.height() - 2.0 * pad).max(0.0)); inner.set_min_height((rect.height() - 2.0 * pad.y).max(0.0));
inner.spacing_mut().item_spacing = egui::vec2(space::ITEM, space::LINE); inner.spacing_mut().item_spacing = egui::vec2(space::ITEM, space::LINE);
// A placeholder goes under the content now and is filled with the panel once
// its height is known, so a body that needs more room still sits on it.
let background = ui.painter().add(Shape::Noop);
title(&mut inner); title(&mut inner);
inner.add_space(space::UNDER_TITLE); inner.add_space(space::UNDER_TITLE);
let value = body(&mut inner); let value = body(&mut inner);
let taken = inner.min_rect().expand(pad); let taken = inner.min_rect().expand2(pad);
ui.painter().set( ui.painter().hline(taken.x_range(), taken.top() + 0.5, Stroke::new(1.0, p.border));
background,
Shape::Vec(vec![
Shape::rect_filled(taken, space::PANEL_RADIUS, p.panel),
Shape::rect_stroke(taken, space::PANEL_RADIUS, Stroke::new(1.0, p.border), StrokeKind::Inside),
]),
);
(value, taken) (value, taken)
} }
@@ -204,25 +195,22 @@ pub fn toggling_title(ui: &mut Ui, title: &str, open: &mut bool) -> bool {
*open *open
} }
/// One stat card: a small upper-case label, the number in mono, one line of /// One cell of the counter strip: a small upper-case label, the number in mono, one line of
/// small print and the change against the period before. Exactly `rect`. /// small print and the change against the period before. Exactly `rect`; a hairline stands at
pub fn card(ui: &mut Ui, rect: Rect, label: &str, number: &str, detail: &str, change: RichText, color: Color32) { /// its left unless it is the first of its row.
pub fn card(ui: &mut Ui, rect: Rect, first: bool, label: &str, number: &str, detail: &str, change: RichText, color: Color32) {
let p = p(ui); let p = p(ui);
ui.allocate_rect(rect, Sense::hover()); ui.allocate_rect(rect, Sense::hover());
let painter = ui.painter(); let inset = if first { 0.0 } else { 16.0 };
painter.rect( if !first {
rect, ui.painter().vline(rect.left() + 0.5, rect.y_range().shrink(10.0), Stroke::new(1.0, p.grid));
space::PANEL_RADIUS, }
p.panel, let inner_rect = Rect::from_min_max(
Stroke::new(1.0, p.border), Pos2::new(rect.left() + inset, rect.top() + 10.0),
StrokeKind::Inside, Pos2::new(rect.right() - 8.0, rect.bottom() - 6.0),
); );
let mut inner = ui.new_child( let mut inner = ui.new_child(egui::UiBuilder::new().max_rect(inner_rect).layout(Layout::top_down(Align::Min)));
egui::UiBuilder::new() inner.set_width(inner_rect.width());
.max_rect(rect.shrink(space::CARD_PADDING + 1.0))
.layout(Layout::top_down(Align::Min)),
);
inner.set_width(rect.width() - 2.0 * (space::CARD_PADDING + 1.0));
inner.spacing_mut().item_spacing = egui::vec2(space::ITEM, 1.0); inner.spacing_mut().item_spacing = egui::vec2(space::ITEM, 1.0);
inner.add(egui::Label::new(theme::title(ui, label)).truncate()); inner.add(egui::Label::new(theme::title(ui, label)).truncate());
inner.add( inner.add(
@@ -353,8 +341,11 @@ pub fn table(ui: &mut Ui, head: &[&str], rows: &[Vec<Cell>]) {
} }
// The label column takes the slack, and gives first when the table is too // The label column takes the slack, and gives first when the table is too
// wide (after a bar column, which can shrink to a stub). // wide (after a bar column, which can shrink to a stub).
// The table reaches `pad` past both edges, so the first column's text and the last
// column's numbers line up with the panel's own edges.
let width_cells = width + 2.0 * pad;
let whole: f32 = natural.iter().sum(); let whole: f32 = natural.iter().sum();
let slack = width - whole; let slack = width_cells - whole;
if slack >= 0.0 { if slack >= 0.0 {
natural[0] += slack; natural[0] += slack;
} else { } else {
@@ -378,7 +369,7 @@ pub fn table(ui: &mut Ui, head: &[&str], rows: &[Vec<Cell>]) {
} }
let lefts: Vec<f32> = natural let lefts: Vec<f32> = natural
.iter() .iter()
.scan(ui.cursor().left(), |left, size| { .scan(ui.cursor().left() - pad, |left, size| {
let at = *left; let at = *left;
*left += size; *left += size;
Some(at) Some(at)
@@ -441,7 +432,7 @@ pub fn table(ui: &mut Ui, head: &[&str], rows: &[Vec<Cell>]) {
Pos2::new(place.left() + pad + side / 2.0, place.center().y), Pos2::new(place.left() + pad + side / 2.0, place.center().y),
egui::vec2(side, side), egui::vec2(side, side),
); );
ui.painter().rect_filled(square, 2.0, *color); ui.painter().rect_filled(square, 0.0, *color);
let (galley, text) = &line[column]; let (galley, text) = &line[column];
if let Some(galley) = galley { if let Some(galley) = galley {
let text_place = Rect::from_min_max( let text_place = Rect::from_min_max(
@@ -476,12 +467,12 @@ pub fn meter(ui: &mut Ui, height: f32, fraction: f64, fill: Color32) {
pub fn fill_bar(ui: &mut Ui, rect: Rect, fraction: f64, fill: Color32) { pub fn fill_bar(ui: &mut Ui, rect: Rect, fraction: f64, fill: Color32) {
let p = p(ui); let p = p(ui);
let painter = ui.painter(); let painter = ui.painter();
painter.rect_filled(rect, rect.height() / 2.0, p.track); painter.rect_filled(rect, 0.0, p.track);
let width = rect.width() * fraction.clamp(0.0, 1.0) as f32; let width = rect.width() * fraction.clamp(0.0, 1.0) as f32;
if width > 0.5 { if width > 0.5 {
painter.rect_filled( painter.rect_filled(
Rect::from_min_max(rect.min, Pos2::new(rect.left() + width, rect.bottom())), Rect::from_min_max(rect.min, Pos2::new(rect.left() + width, rect.bottom())),
rect.height() / 2.0, 0.0,
fill, fill,
); );
} }
@@ -498,14 +489,14 @@ pub fn stacked_bar(ui: &mut Ui, parts: &[(&'static str, u64, Color32)], total: u
Sense::hover(), Sense::hover(),
); );
let painter = ui.painter(); let painter = ui.painter();
painter.rect_filled(rect, 3.0, p.track); painter.rect_filled(rect, 0.0, p.track);
let mut x = rect.left(); let mut x = rect.left();
let mut tip = String::new(); let mut tip = String::new();
for (name, part, color) in parts { for (name, part, color) in parts {
let width = if total > 0 { rect.width() * *part as f64 as f32 / total as f32 } else { 0.0 }; let width = if total > 0 { rect.width() * *part as f64 as f32 / total as f32 } else { 0.0 };
if width > 0.0 { if width > 0.0 {
let part_rect = Rect::from_min_max(Pos2::new(x, rect.top()), Pos2::new(x + width, rect.bottom())); let part_rect = Rect::from_min_max(Pos2::new(x, rect.top()), Pos2::new(x + width, rect.bottom()));
painter.rect_filled(part_rect, 3.0, *color); painter.rect_filled(part_rect, 0.0, *color);
x += width; x += width;
tip.push_str(&format!( tip.push_str(&format!(
"{name}: {} ({})\n", "{name}: {} ({})\n",
@@ -523,24 +514,18 @@ pub fn stacked_bar(ui: &mut Ui, parts: &[(&'static str, u64, Color32)], total: u
pub fn hit_bar(ui: &mut Ui, rect: Rect, hits: u64, misses: u64) { pub fn hit_bar(ui: &mut Ui, rect: Rect, hits: u64, misses: u64) {
let p = p(ui); let p = p(ui);
let painter = ui.painter(); let painter = ui.painter();
painter.rect_filled(rect, rect.height() / 2.0, p.track); painter.rect_filled(rect, 0.0, p.track);
let total = hits + misses; let total = hits + misses;
if total > 0 { if total > 0 {
let hit_width = rect.width() * hits as f32 / total as f32; let hit_width = rect.width() * hits as f32 / total as f32;
painter.rect_filled( painter.rect_filled(
Rect::from_min_max(rect.min, Pos2::new(rect.left() + hit_width, rect.bottom())), Rect::from_min_max(rect.min, Pos2::new(rect.left() + hit_width, rect.bottom())),
rect.height() / 2.0, 0.0,
p.from_cache, p.from_cache,
); );
} }
} }
pub fn dot(ui: &mut Ui, color: Color32) {
let side = theme::drawing::SEVERITY_DOT;
let (rect, _) = ui.allocate_exact_size(egui::vec2(side, side), Sense::hover());
ui.painter().circle_filled(rect.center(), side / 2.0, color);
}
/// A trend line one point per bucket, drawn in a strip `height` tall. `None` /// A trend line one point per bucket, drawn in a strip `height` tall. `None`
/// points break the line, so a gap never looks like a zero. `top` is the value /// points break the line, so a gap never looks like a zero. `top` is the value
/// drawn at the top of the strip. /// drawn at the top of the strip.
@@ -635,7 +620,7 @@ pub fn key(ui: &mut Ui, mark: Mark) {
/// The key to a chart, drawn under it so it never sits on the data. /// The key to a chart, drawn under it so it never sits on the data.
pub fn legend(ui: &mut Ui, entries: Vec<(Mark, String)>) { pub fn legend(ui: &mut Ui, entries: Vec<(Mark, String)>) {
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing.x = space::PANEL_GAP + 2.0; ui.spacing_mut().item_spacing.x = 14.0;
for (mark, text) in entries { for (mark, text) in entries {
key(ui, mark); key(ui, mark);
let response = ui.add(egui::Label::new(theme::small(ui, text.clone())).truncate()); let response = ui.add(egui::Label::new(theme::small(ui, text.clone())).truncate());
+80 -76
View File
@@ -44,6 +44,8 @@ pub struct Palette {
pub accent: Color32, pub accent: Color32,
/// Text on the accent: what a selected control says. /// Text on the accent: what a selected control says.
pub on_accent: Color32, pub on_accent: Color32,
/// Amber as text and lines: the hero figures and key lines (darker in the light theme to pass contrast).
pub hero: Color32,
/// The tint over time nothing was recorded in. /// The tint over time nothing was recorded in.
pub unrecorded: Color32, pub unrecorded: Color32,
/// The line of the mean, the median and the p90 on a build-time histogram. /// The line of the mean, the median and the p90 on a build-time histogram.
@@ -54,54 +56,56 @@ pub struct Palette {
pub const DARK: Palette = Palette { pub const DARK: Palette = Palette {
dark: true, dark: true,
page: rgb(0x0e1116), page: rgb(0x0f0f10),
panel: rgb(0x161a22), panel: rgb(0x161617),
border: rgb(0x232936), border: rgb(0x2a2a2c),
text: rgb(0xe6e9ef), text: rgb(0xe8e6e1),
muted: rgb(0x8a93a5), muted: rgb(0x8f8d87),
grid: rgb(0x1f2530), grid: rgb(0x1f1f21),
track: rgb(0x0b0e13), track: rgb(0x1b1b1d),
hover: rgb(0x1f2530), hover: rgb(0x1f1f21),
good: rgb(0x3fb950), good: rgb(0x3ecf8e),
warn: rgb(0xd29922), warn: rgb(0xffb000),
bad: rgb(0xf85149), bad: rgb(0xff5f56),
from_cache: rgb(0x4cc38a), from_cache: rgb(0x3ecf8e),
built: rgb(0x5b8def), built: rgb(0x5b8def),
not_cacheable: rgb(0x8a93a5), not_cacheable: rgb(0x8a8a8f),
unsupported: rgb(0xb08cf0), unsupported: rgb(0x5f5f64),
not_compile: rgb(0x4fb3bf), not_compile: rgb(0x424246),
accent: rgb(0x5b8def), accent: rgb(0xffb000),
on_accent: rgb(0xffffff), on_accent: rgb(0x0f0f10),
hero: rgb(0xffb000),
unrecorded: Color32::from_rgba_premultiplied(14, 14, 14, 14), unrecorded: Color32::from_rgba_premultiplied(14, 14, 14, 14),
mean: rgb(0xe6e9ef), mean: rgb(0xe8e6e1),
median: rgb(0xb08cf0), median: rgb(0xffb000),
p90: rgb(0x4fb3bf), p90: rgb(0x8a8a8f),
}; };
pub const LIGHT: Palette = Palette { pub const LIGHT: Palette = Palette {
dark: false, dark: false,
page: rgb(0xf5f6f8), page: rgb(0xf6f3ec),
panel: rgb(0xffffff), panel: rgb(0xfffdf8),
border: rgb(0xdfe3ea), border: rgb(0xd5cfc1),
text: rgb(0x1b2029), text: rgb(0x1d1b17),
muted: rgb(0x5d6675), muted: rgb(0x6a655b),
grid: rgb(0xeceff4), grid: rgb(0xe6e1d6),
track: rgb(0xeef0f4), track: rgb(0xebe6da),
hover: rgb(0xf0f2f6), hover: rgb(0xe9e4d8),
good: rgb(0x1a7f37), good: rgb(0x1a8f5a),
warn: rgb(0x9a6700), warn: rgb(0xb87400),
bad: rgb(0xcf222e), bad: rgb(0xc62f26),
from_cache: rgb(0x2a9150), from_cache: rgb(0x1f9d63),
built: rgb(0x3a6fd8), built: rgb(0x2f63d0),
not_cacheable: rgb(0x6b7484), not_cacheable: rgb(0x7a766c),
unsupported: rgb(0x7c5cd6), unsupported: rgb(0xa39f94),
not_compile: rgb(0x1f8a9b), not_compile: rgb(0xc2beb2),
accent: rgb(0x3a6fd8), accent: rgb(0xffb000),
on_accent: rgb(0xffffff), on_accent: rgb(0x1d1b17),
unrecorded: Color32::from_rgba_premultiplied(0, 0, 0, 18), hero: rgb(0x8a5600),
mean: rgb(0x1b2029), unrecorded: Color32::from_rgba_premultiplied(0, 0, 0, 16),
median: rgb(0x7c5cd6), mean: rgb(0x1d1b17),
p90: rgb(0x1f8a9b), median: rgb(0x8a5600),
p90: rgb(0x7a766c),
}; };
/// The palette of the theme being drawn. /// The palette of the theme being drawn.
@@ -138,20 +142,24 @@ pub mod px {
/// Small print. /// Small print.
pub const SMALL: f32 = 11.0; pub const SMALL: f32 = 11.0;
/// The number on a stat card. /// The number on a stat card.
pub const CARD_NUMBER: f32 = 24.0; pub const CARD_NUMBER: f32 = 22.0;
/// The three figures of the headline panel. /// The three figures of the headline panel.
pub const HEADLINE: f32 = 40.0; pub const HEADLINE: f32 = 56.0;
} }
/// Space in pixels. /// Space in pixels.
pub mod space { pub mod space {
pub const PAGE_MARGIN: f32 = 16.0; pub const PAGE_MARGIN: f32 = 16.0;
/// Between panels, and between cards. /// Between panels, and between cards.
pub const PANEL_GAP: f32 = 12.0; pub const PANEL_GAP: f32 = 24.0;
pub const PANEL_PADDING: f32 = 16.0; /// Between the controls of the top bar.
pub const CARD_PADDING: f32 = 12.0; pub const TOOL_GAP: f32 = 8.0;
pub const PANEL_RADIUS: f32 = 8.0; /// Panels have no side padding: their content lines up with the hairline above it.
pub const CONTROL_RADIUS: f32 = 6.0; pub const PANEL_PADDING: f32 = 0.0;
/// Room between a panel's top hairline and its title, and under its content.
pub const PANEL_PAD_Y: f32 = 12.0;
pub const PANEL_RADIUS: f32 = 0.0;
pub const CONTROL_RADIUS: f32 = 2.0;
/// Between items that follow each other in a panel. /// Between items that follow each other in a panel.
pub const ITEM: f32 = 8.0; pub const ITEM: f32 = 8.0;
/// Between lines of one paragraph. /// Between lines of one paragraph.
@@ -162,8 +170,8 @@ pub mod space {
pub const CELL_PAD: f32 = 8.0; pub const CELL_PAD: f32 = 8.0;
/// The narrowest the label column of a table gets before its text is cut. /// The narrowest the label column of a table gets before its text is cut.
pub const LABEL_MIN: f32 = 72.0; pub const LABEL_MIN: f32 = 72.0;
pub const CONTROL_HEIGHT: f32 = 28.0; pub const CONTROL_HEIGHT: f32 = 24.0;
pub const CONTROL_PAD: f32 = 10.0; pub const CONTROL_PAD: f32 = 9.0;
pub const TITLE_SPACING: f32 = 0.8; pub const TITLE_SPACING: f32 = 0.8;
pub const TOOLBAR_NOTE_WIDTH: f32 = 150.0; pub const TOOLBAR_NOTE_WIDTH: f32 = 150.0;
/// Between a raw counter's key and its value. /// Between a raw counter's key and its value.
@@ -180,47 +188,42 @@ pub mod layout {
pub const THREE_COLUMNS_FROM: f32 = 1100.0; pub const THREE_COLUMNS_FROM: f32 = 1100.0;
/// From this width it has two; below it, one. /// From this width it has two; below it, one.
pub const TWO_COLUMNS_FROM: f32 = 700.0; pub const TWO_COLUMNS_FROM: f32 = 700.0;
/// Below this width the toolbar's actions go on a second line.
pub const TOOLBAR_TWO_LINES_BELOW: f32 = 1240.0;
/// How many columns of key/value lines the raw counters run in, per page column. /// How many columns of key/value lines the raw counters run in, per page column.
pub const RAW_LINE_WIDTH: f32 = 400.0; pub const RAW_LINE_WIDTH: f32 = 400.0;
pub const TOOLBAR_HEIGHT: f32 = 28.0; pub const TOOLBAR_HEIGHT: f32 = 24.0;
pub const HEADLINE_HEIGHT: f32 = 216.0; /// The hero band on a wide page: caption row, one row of figures and the storage line.
/// A headline figure: the number, its caption, the trend line and two lines of small print. pub const HEADLINE_HEIGHT: f32 = 296.0;
pub const FIGURE_HEIGHT: f32 = 124.0; /// A hero figure: the number, its caption, the trend line and two lines of small print.
pub const CARD_HEIGHT: f32 = 104.0; pub const FIGURE_HEIGHT: f32 = 176.0;
/// The row of "Where compiles went", "By language" and "Problems". It grows /// One row of the counter strip.
/// only when the tables have more rows than this height holds. pub const STRIP_ROW_HEIGHT: f32 = 92.0;
pub const TRIPTYCH_HEIGHT: f32 = 232.0;
/// The row of "Over time" and "Speed".
pub const CHARTS_HEIGHT: f32 = 516.0;
/// "Where compiles went": its bar, legend and the "of the built" line. /// "Where compiles went": its bar, legend and the "of the built" line.
pub const WHERE_FIXED_HEIGHT: f32 = 244.0; pub const WHERE_FIXED_HEIGHT: f32 = 212.0;
/// "Why compiles were not cacheable" needs this much beside its reasons: padding, title and the room under it. /// "Why compiles were not cacheable" needs this much beside its reasons: padding, title and the room under it.
pub const REASONS_FIXED_HEIGHT: f32 = 66.0; pub const REASONS_FIXED_HEIGHT: f32 = 56.0;
/// From this panel width the "By language" table has room for its hit-rate bars. /// From this panel width the "By language" table has room for its hit-rate bars.
pub const LANGUAGE_BARS_FROM: f32 = 380.0; pub const LANGUAGE_BARS_FROM: f32 = 380.0;
/// "By language" needs this much beside its rows. /// "By language" needs this much beside its rows.
pub const LANGUAGES_FIXED_HEIGHT: f32 = 60.0; pub const LANGUAGES_FIXED_HEIGHT: f32 = 50.0;
/// "Speed" needs this much beside its histograms. /// "Speed" needs this much beside its histograms.
pub const SPEED_FIXED_HEIGHT: f32 = 250.0; pub const SPEED_FIXED_HEIGHT: f32 = 240.0;
/// "Problems" needs this much beside its problems.
pub const PROBLEMS_FIXED_HEIGHT: f32 = 60.0;
/// "Speed" needs this much per language with a histogram. /// "Speed" needs this much per language with a histogram.
pub const HISTOGRAM_HEIGHT: f32 = 85.0; pub const HISTOGRAM_HEIGHT: f32 = 85.0;
/// A panel of one time chart: padding, title, plot and legend.
pub const CHART_PANEL_HEIGHT: f32 = 306.0;
} }
/// Drawings inside panels, in pixels. /// Drawings inside panels, in pixels.
pub mod drawing { pub mod drawing {
pub const CHART_HEIGHT: f32 = 170.0; pub const CHART_HEIGHT: f32 = 240.0;
/// The trend line under a headline figure. /// The trend line under a headline figure.
pub const SPARKLINE: f32 = 28.0; pub const SPARKLINE: f32 = 36.0;
pub const BUILD_HISTOGRAM: f32 = 44.0; pub const BUILD_HISTOGRAM: f32 = 44.0;
pub const BUILD_AXIS: f32 = 14.0; pub const BUILD_AXIS: f32 = 14.0;
pub const STACKED_BAR: f32 = 22.0; pub const STACKED_BAR: f32 = 22.0;
pub const SPEED_BAR: f32 = 10.0; pub const SPEED_BAR: f32 = 10.0;
pub const USAGE_BAR: f32 = 6.0; pub const USAGE_BAR: f32 = 4.0;
pub const HIT_BAR: f32 = 72.0; pub const HIT_BAR: f32 = 72.0;
pub const HIT_BAR_HEIGHT: f32 = 6.0; pub const HIT_BAR_HEIGHT: f32 = 6.0;
pub const LEGEND_SWATCH: f32 = 10.0; pub const LEGEND_SWATCH: f32 = 10.0;
@@ -369,10 +372,10 @@ fn visuals(p: &Palette) -> egui::Visuals {
expansion: 0.0, expansion: 0.0,
}; };
visuals.widgets.noninteractive = control(p.track, p.border, p.muted); visuals.widgets.noninteractive = control(p.track, p.border, p.muted);
visuals.widgets.inactive = control(p.track, p.border, p.text); visuals.widgets.inactive = control(Color32::TRANSPARENT, p.border, p.text);
visuals.widgets.hovered = control(p.hover, p.accent, p.text); visuals.widgets.hovered = control(p.hover, p.muted, p.text);
visuals.widgets.active = control(tint(p.accent, 0.25), p.accent, p.text); visuals.widgets.active = control(tint(p.accent, 0.25), p.accent, p.text);
visuals.widgets.open = control(p.hover, p.accent, p.text); visuals.widgets.open = control(p.hover, p.muted, p.text);
visuals visuals
} }
@@ -382,7 +385,8 @@ pub fn install(ctx: &egui::Context) {
ctx.all_styles_mut(|style| { ctx.all_styles_mut(|style| {
style.text_styles = text_styles(); style.text_styles = text_styles();
style.spacing.item_spacing = egui::vec2(space::ITEM, space::LINE); style.spacing.item_spacing = egui::vec2(space::ITEM, space::LINE);
style.spacing.button_padding = egui::vec2(10.0, 4.0); style.spacing.button_padding = egui::vec2(8.0, 2.0);
style.spacing.interact_size.y = space::CONTROL_HEIGHT;
style.spacing.indent = 12.0; style.spacing.indent = 12.0;
style.visuals = visuals(of(style.visuals.dark_mode)); style.visuals = visuals(of(style.visuals.dark_mode));
}); });
+3 -3
View File
@@ -135,7 +135,7 @@ fn blocks(ui: &Ui, view: &View, width: f32) -> Vec<Block> {
} }
/// A triangle in the muted colour: pointing right when closed, down when open. /// A triangle in the muted colour: pointing right when closed, down when open.
fn chevron(painter: &egui::Painter, center: egui::Pos2, open: bool, color: Color32) { pub(crate) fn chevron(painter: &egui::Painter, center: egui::Pos2, open: bool, color: Color32) {
let h = CHEVRON / 2.0; let h = CHEVRON / 2.0;
let points = if open { let points = if open {
vec![center + egui::vec2(-h, -h / 2.0), center + egui::vec2(h, -h / 2.0), center + egui::vec2(0.0, h / 2.0 + 1.0)] vec![center + egui::vec2(-h, -h / 2.0), center + egui::vec2(h, -h / 2.0), center + egui::vec2(0.0, h / 2.0 + 1.0)]
@@ -184,7 +184,7 @@ pub fn reasons(ui: &mut Ui, view: &View) {
let side = theme::drawing::SEVERITY_DOT; let side = theme::drawing::SEVERITY_DOT;
let dot = if reason.fixable { p.warn } else { p.not_cacheable }; let dot = if reason.fixable { p.warn } else { p.not_cacheable };
let name_top = row.top() + (block.row - block.name.size().y) / 2.0; let name_top = row.top() + (block.row - block.name.size().y) / 2.0;
painter.circle_filled(egui::pos2(row.left() + side / 2.0, row.center().y), side / 2.0, dot); painter.rect_filled(egui::Rect::from_center_size(egui::pos2(row.left() + side / 2.0, row.center().y), egui::vec2(side, side)), 0.0, dot);
painter.galley(egui::pos2(row.left() + indent, name_top), block.name.clone(), p.text); painter.galley(egui::pos2(row.left() + indent, name_top), block.name.clone(), p.text);
let chevron_left = row.right() - CHEVRON; let chevron_left = row.right() - CHEVRON;
chevron(painter, egui::pos2(chevron_left + CHEVRON / 2.0, row.center().y), block.open, p.muted); chevron(painter, egui::pos2(chevron_left + CHEVRON / 2.0, row.center().y), block.open, p.muted);
@@ -210,7 +210,7 @@ pub fn reasons(ui: &mut Ui, view: &View) {
/// How tall "Why compiles were not cacheable" is in a panel `panel_width` wide. /// How tall "Why compiles were not cacheable" is in a panel `panel_width` wide.
pub fn reasons_height(ui: &Ui, view: &View, panel_width: f32) -> f32 { pub fn reasons_height(ui: &Ui, view: &View, panel_width: f32) -> f32 {
let inner = panel_width - 2.0 * (theme::space::PANEL_PADDING + 1.0); let inner = panel_width - 2.0 * theme::space::PANEL_PADDING;
let entries: Vec<_> = blocks(ui, view, inner).iter().map(Block::entry).collect(); let entries: Vec<_> = blocks(ui, view, inner).iter().map(Block::entry).collect();
let list = disclosure::list_height(&entries, theme::space::LINE, theme::space::ITEM, SEPARATOR); let list = disclosure::list_height(&entries, theme::space::LINE, theme::space::ITEM, SEPARATOR);
theme::layout::REASONS_FIXED_HEIGHT + list.max(theme::space::ROW) theme::layout::REASONS_FIXED_HEIGHT + list.max(theme::space::ROW)