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:
1 parent
06abc4de80
commit
3a2bcefd38
9 files changed
+403
-390
No files matched your search
+184
-203
@@ -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());
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
+15
-8
@@ -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};
|
||||
|
||||
@@ -77,25 +77,32 @@ pub fn row(ui: &mut egui::Ui, view: &View, per_row: usize) {
|
||||
let left = ui.cursor().left();
|
||||
let mut top = ui.cursor().top();
|
||||
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;
|
||||
for line in cards.chunks(per_row) {
|
||||
let mut x = left;
|
||||
for card in line {
|
||||
let cell_width = width / per_row as f32;
|
||||
let height = theme::layout::STRIP_ROW_HEIGHT;
|
||||
let rule = egui::Stroke::new(1.0, p.border);
|
||||
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);
|
||||
style::card(
|
||||
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,
|
||||
&fmt::count(card.count),
|
||||
&card.detail,
|
||||
change,
|
||||
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(theme::space::PANEL_GAP);
|
||||
}
|
||||
|
||||
struct Card {
|
||||
|
||||
+14
-14
@@ -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)
|
||||
}
|
||||
|
||||
pub fn section(ui: &mut Ui, view: &View, hidden: &mut Vec<String>, chart_height: f32) {
|
||||
let p = theme::ui(ui);
|
||||
filter(ui, view, hidden);
|
||||
|
||||
let tz = fmt::local_offset() as f64;
|
||||
fn axes_of(view: &View, dark: bool) -> Axes {
|
||||
let step = bucket_step(&view.buckets, view.range);
|
||||
let axes = Axes {
|
||||
Axes {
|
||||
window: range_window(view, step),
|
||||
step,
|
||||
tz,
|
||||
dark: p.dark,
|
||||
};
|
||||
tz: fmt::local_offset() as f64,
|
||||
dark,
|
||||
}
|
||||
}
|
||||
|
||||
ui.add_space(theme::space::BETWEEN_PARTS);
|
||||
part_title(ui, "Hit rate");
|
||||
/// The body of the "Hit rate over time" panel.
|
||||
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);
|
||||
}
|
||||
|
||||
ui.add_space(theme::space::BETWEEN_PARTS);
|
||||
part_title(ui, "Compiles");
|
||||
/// The body of the "Compiles over time" panel.
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ pub fn part_title(ui: &mut Ui, text: &str) {
|
||||
}
|
||||
|
||||
/// 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.spacing_mut().item_spacing.x = theme::space::PANEL_GAP;
|
||||
let mut all = hidden.is_empty();
|
||||
|
||||
+66
-30
@@ -1,41 +1,77 @@
|
||||
//! Problems: what is wrong, most serious first. A dot for how serious, the
|
||||
//! title, and the detail in small print.
|
||||
//! Problems: what is wrong, most serious first, as the list under the hero's problem
|
||||
//! 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 crate::style;
|
||||
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);
|
||||
if view.problems.is_empty() {
|
||||
// Nothing to alarm: a calm dot in the good colour and the words.
|
||||
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());
|
||||
ui.add(egui::Label::new(theme::small(ui, "Nothing needs attention.")).truncate());
|
||||
return;
|
||||
}
|
||||
for (index, problem) in view.problems.iter().enumerate() {
|
||||
if index > 0 {
|
||||
ui.add_space(theme::space::BETWEEN_PARTS);
|
||||
}
|
||||
let color = match problem.severity {
|
||||
Severity::Error => p.bad,
|
||||
Severity::Warning => p.warn,
|
||||
};
|
||||
ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = theme::space::ITEM + 2.0;
|
||||
style::dot(ui, color);
|
||||
ui.add(
|
||||
egui::Label::new(
|
||||
theme::strong(problem.title.clone()).color(color),
|
||||
),
|
||||
);
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt("hero-problems")
|
||||
.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 {
|
||||
Severity::Error => p.bad,
|
||||
Severity::Warning => p.warn,
|
||||
};
|
||||
let side = theme::drawing::SEVERITY_DOT;
|
||||
ui.painter().rect_filled(
|
||||
egui::Rect::from_center_size(egui::pos2(row.left() + side / 2.0, row.center().y), egui::vec2(side, side)),
|
||||
0.0,
|
||||
color,
|
||||
);
|
||||
let chevron_x = row.right() - CHEVRON;
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.add(egui::Label::new(theme::small(ui, problem.detail.clone())).wrap());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//! 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
|
||||
//! open.
|
||||
//! closed, as one line.
|
||||
|
||||
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,
|
||||
/// its lines.
|
||||
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 {
|
||||
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);
|
||||
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
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
let id = egui::Id::unique("raw-counters-open");
|
||||
let open = Cell::new(ui.ctx().data_mut(|data| data.get_temp::<bool>(id)).unwrap_or(true));
|
||||
let id = egui::Id::new("raw-counters-open");
|
||||
let open = Cell::new(ui.ctx().data_mut(|data| data.get_temp::<bool>(id)).unwrap_or(false));
|
||||
let (_, taken) = style::panel_titled(
|
||||
ui,
|
||||
rect,
|
||||
|
||||
@@ -19,8 +19,8 @@ pub fn section(ui: &mut Ui, view: &View) {
|
||||
let timing = view.timing;
|
||||
let rows = [
|
||||
("Cache fetch (a hit)", timing.avg_hit_read_ms, p.from_cache),
|
||||
("Cache write", timing.avg_cache_write_ms, p.built),
|
||||
("Compile one crate", timing.avg_compile_ms, p.muted),
|
||||
("Cache write", timing.avg_cache_write_ms, p.muted),
|
||||
("Compile one crate", timing.avg_compile_ms, p.built),
|
||||
];
|
||||
for (label, ms, color) in rows {
|
||||
ui.horizontal(|ui| {
|
||||
@@ -67,7 +67,7 @@ pub fn section(ui: &mut Ui, view: &View) {
|
||||
"There are no timings to compare in this range.".to_owned()
|
||||
};
|
||||
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(
|
||||
egui::Label::new(
|
||||
theme::small(
|
||||
|
||||
+33
-48
@@ -92,7 +92,7 @@ pub fn rule(ui: &mut Ui) {
|
||||
|
||||
// ---- 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.
|
||||
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();
|
||||
@@ -114,29 +114,20 @@ pub fn panel_titled<R>(
|
||||
body: impl FnOnce(&mut Ui) -> R,
|
||||
) -> (R, Rect) {
|
||||
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(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(rect.shrink(pad))
|
||||
.max_rect(rect.shrink2(pad))
|
||||
.layout(Layout::top_down(Align::Min)),
|
||||
);
|
||||
inner.set_width((rect.width() - 2.0 * pad).max(0.0));
|
||||
inner.set_min_height((rect.height() - 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.y).max(0.0));
|
||||
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);
|
||||
inner.add_space(space::UNDER_TITLE);
|
||||
let value = body(&mut inner);
|
||||
let taken = inner.min_rect().expand(pad);
|
||||
ui.painter().set(
|
||||
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),
|
||||
]),
|
||||
);
|
||||
let taken = inner.min_rect().expand2(pad);
|
||||
ui.painter().hline(taken.x_range(), taken.top() + 0.5, Stroke::new(1.0, p.border));
|
||||
(value, taken)
|
||||
}
|
||||
|
||||
@@ -204,25 +195,22 @@ pub fn toggling_title(ui: &mut Ui, title: &str, open: &mut bool) -> bool {
|
||||
*open
|
||||
}
|
||||
|
||||
/// One stat card: a small upper-case label, the number in mono, one line of
|
||||
/// small print and the change against the period before. Exactly `rect`.
|
||||
pub fn card(ui: &mut Ui, rect: Rect, label: &str, number: &str, detail: &str, change: RichText, color: Color32) {
|
||||
/// 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`; a hairline stands at
|
||||
/// 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);
|
||||
ui.allocate_rect(rect, Sense::hover());
|
||||
let painter = ui.painter();
|
||||
painter.rect(
|
||||
rect,
|
||||
space::PANEL_RADIUS,
|
||||
p.panel,
|
||||
Stroke::new(1.0, p.border),
|
||||
StrokeKind::Inside,
|
||||
let inset = if first { 0.0 } else { 16.0 };
|
||||
if !first {
|
||||
ui.painter().vline(rect.left() + 0.5, rect.y_range().shrink(10.0), Stroke::new(1.0, p.grid));
|
||||
}
|
||||
let inner_rect = Rect::from_min_max(
|
||||
Pos2::new(rect.left() + inset, rect.top() + 10.0),
|
||||
Pos2::new(rect.right() - 8.0, rect.bottom() - 6.0),
|
||||
);
|
||||
let mut inner = ui.new_child(
|
||||
egui::UiBuilder::new()
|
||||
.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));
|
||||
let mut inner = ui.new_child(egui::UiBuilder::new().max_rect(inner_rect).layout(Layout::top_down(Align::Min)));
|
||||
inner.set_width(inner_rect.width());
|
||||
inner.spacing_mut().item_spacing = egui::vec2(space::ITEM, 1.0);
|
||||
inner.add(egui::Label::new(theme::title(ui, label)).truncate());
|
||||
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
|
||||
// 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 slack = width - whole;
|
||||
let slack = width_cells - whole;
|
||||
if slack >= 0.0 {
|
||||
natural[0] += slack;
|
||||
} else {
|
||||
@@ -378,7 +369,7 @@ pub fn table(ui: &mut Ui, head: &[&str], rows: &[Vec<Cell>]) {
|
||||
}
|
||||
let lefts: Vec<f32> = natural
|
||||
.iter()
|
||||
.scan(ui.cursor().left(), |left, size| {
|
||||
.scan(ui.cursor().left() - pad, |left, size| {
|
||||
let at = *left;
|
||||
*left += size;
|
||||
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),
|
||||
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];
|
||||
if let Some(galley) = galley {
|
||||
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) {
|
||||
let p = p(ui);
|
||||
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;
|
||||
if width > 0.5 {
|
||||
painter.rect_filled(
|
||||
Rect::from_min_max(rect.min, Pos2::new(rect.left() + width, rect.bottom())),
|
||||
rect.height() / 2.0,
|
||||
0.0,
|
||||
fill,
|
||||
);
|
||||
}
|
||||
@@ -498,14 +489,14 @@ pub fn stacked_bar(ui: &mut Ui, parts: &[(&'static str, u64, Color32)], total: u
|
||||
Sense::hover(),
|
||||
);
|
||||
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 tip = String::new();
|
||||
for (name, part, color) in parts {
|
||||
let width = if total > 0 { rect.width() * *part as f64 as f32 / total as f32 } else { 0.0 };
|
||||
if width > 0.0 {
|
||||
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;
|
||||
tip.push_str(&format!(
|
||||
"{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) {
|
||||
let p = p(ui);
|
||||
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;
|
||||
if total > 0 {
|
||||
let hit_width = rect.width() * hits as f32 / total as f32;
|
||||
painter.rect_filled(
|
||||
Rect::from_min_max(rect.min, Pos2::new(rect.left() + hit_width, rect.bottom())),
|
||||
rect.height() / 2.0,
|
||||
0.0,
|
||||
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`
|
||||
/// points break the line, so a gap never looks like a zero. `top` is the value
|
||||
/// 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.
|
||||
pub fn legend(ui: &mut Ui, entries: Vec<(Mark, String)>) {
|
||||
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 {
|
||||
key(ui, mark);
|
||||
let response = ui.add(egui::Label::new(theme::small(ui, text.clone())).truncate());
|
||||
|
||||
+80
-76
@@ -44,6 +44,8 @@ pub struct Palette {
|
||||
pub accent: Color32,
|
||||
/// Text on the accent: what a selected control says.
|
||||
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.
|
||||
pub unrecorded: Color32,
|
||||
/// 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 {
|
||||
dark: true,
|
||||
page: rgb(0x0e1116),
|
||||
panel: rgb(0x161a22),
|
||||
border: rgb(0x232936),
|
||||
text: rgb(0xe6e9ef),
|
||||
muted: rgb(0x8a93a5),
|
||||
grid: rgb(0x1f2530),
|
||||
track: rgb(0x0b0e13),
|
||||
hover: rgb(0x1f2530),
|
||||
good: rgb(0x3fb950),
|
||||
warn: rgb(0xd29922),
|
||||
bad: rgb(0xf85149),
|
||||
from_cache: rgb(0x4cc38a),
|
||||
page: rgb(0x0f0f10),
|
||||
panel: rgb(0x161617),
|
||||
border: rgb(0x2a2a2c),
|
||||
text: rgb(0xe8e6e1),
|
||||
muted: rgb(0x8f8d87),
|
||||
grid: rgb(0x1f1f21),
|
||||
track: rgb(0x1b1b1d),
|
||||
hover: rgb(0x1f1f21),
|
||||
good: rgb(0x3ecf8e),
|
||||
warn: rgb(0xffb000),
|
||||
bad: rgb(0xff5f56),
|
||||
from_cache: rgb(0x3ecf8e),
|
||||
built: rgb(0x5b8def),
|
||||
not_cacheable: rgb(0x8a93a5),
|
||||
unsupported: rgb(0xb08cf0),
|
||||
not_compile: rgb(0x4fb3bf),
|
||||
accent: rgb(0x5b8def),
|
||||
on_accent: rgb(0xffffff),
|
||||
not_cacheable: rgb(0x8a8a8f),
|
||||
unsupported: rgb(0x5f5f64),
|
||||
not_compile: rgb(0x424246),
|
||||
accent: rgb(0xffb000),
|
||||
on_accent: rgb(0x0f0f10),
|
||||
hero: rgb(0xffb000),
|
||||
unrecorded: Color32::from_rgba_premultiplied(14, 14, 14, 14),
|
||||
mean: rgb(0xe6e9ef),
|
||||
median: rgb(0xb08cf0),
|
||||
p90: rgb(0x4fb3bf),
|
||||
mean: rgb(0xe8e6e1),
|
||||
median: rgb(0xffb000),
|
||||
p90: rgb(0x8a8a8f),
|
||||
};
|
||||
|
||||
pub const LIGHT: Palette = Palette {
|
||||
dark: false,
|
||||
page: rgb(0xf5f6f8),
|
||||
panel: rgb(0xffffff),
|
||||
border: rgb(0xdfe3ea),
|
||||
text: rgb(0x1b2029),
|
||||
muted: rgb(0x5d6675),
|
||||
grid: rgb(0xeceff4),
|
||||
track: rgb(0xeef0f4),
|
||||
hover: rgb(0xf0f2f6),
|
||||
good: rgb(0x1a7f37),
|
||||
warn: rgb(0x9a6700),
|
||||
bad: rgb(0xcf222e),
|
||||
from_cache: rgb(0x2a9150),
|
||||
built: rgb(0x3a6fd8),
|
||||
not_cacheable: rgb(0x6b7484),
|
||||
unsupported: rgb(0x7c5cd6),
|
||||
not_compile: rgb(0x1f8a9b),
|
||||
accent: rgb(0x3a6fd8),
|
||||
on_accent: rgb(0xffffff),
|
||||
unrecorded: Color32::from_rgba_premultiplied(0, 0, 0, 18),
|
||||
mean: rgb(0x1b2029),
|
||||
median: rgb(0x7c5cd6),
|
||||
p90: rgb(0x1f8a9b),
|
||||
page: rgb(0xf6f3ec),
|
||||
panel: rgb(0xfffdf8),
|
||||
border: rgb(0xd5cfc1),
|
||||
text: rgb(0x1d1b17),
|
||||
muted: rgb(0x6a655b),
|
||||
grid: rgb(0xe6e1d6),
|
||||
track: rgb(0xebe6da),
|
||||
hover: rgb(0xe9e4d8),
|
||||
good: rgb(0x1a8f5a),
|
||||
warn: rgb(0xb87400),
|
||||
bad: rgb(0xc62f26),
|
||||
from_cache: rgb(0x1f9d63),
|
||||
built: rgb(0x2f63d0),
|
||||
not_cacheable: rgb(0x7a766c),
|
||||
unsupported: rgb(0xa39f94),
|
||||
not_compile: rgb(0xc2beb2),
|
||||
accent: rgb(0xffb000),
|
||||
on_accent: rgb(0x1d1b17),
|
||||
hero: rgb(0x8a5600),
|
||||
unrecorded: Color32::from_rgba_premultiplied(0, 0, 0, 16),
|
||||
mean: rgb(0x1d1b17),
|
||||
median: rgb(0x8a5600),
|
||||
p90: rgb(0x7a766c),
|
||||
};
|
||||
|
||||
/// The palette of the theme being drawn.
|
||||
@@ -138,20 +142,24 @@ pub mod px {
|
||||
/// Small print.
|
||||
pub const SMALL: f32 = 11.0;
|
||||
/// 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.
|
||||
pub const HEADLINE: f32 = 40.0;
|
||||
pub const HEADLINE: f32 = 56.0;
|
||||
}
|
||||
|
||||
/// Space in pixels.
|
||||
pub mod space {
|
||||
pub const PAGE_MARGIN: f32 = 16.0;
|
||||
/// Between panels, and between cards.
|
||||
pub const PANEL_GAP: f32 = 12.0;
|
||||
pub const PANEL_PADDING: f32 = 16.0;
|
||||
pub const CARD_PADDING: f32 = 12.0;
|
||||
pub const PANEL_RADIUS: f32 = 8.0;
|
||||
pub const CONTROL_RADIUS: f32 = 6.0;
|
||||
pub const PANEL_GAP: f32 = 24.0;
|
||||
/// Between the controls of the top bar.
|
||||
pub const TOOL_GAP: f32 = 8.0;
|
||||
/// Panels have no side padding: their content lines up with the hairline above it.
|
||||
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.
|
||||
pub const ITEM: f32 = 8.0;
|
||||
/// Between lines of one paragraph.
|
||||
@@ -162,8 +170,8 @@ pub mod space {
|
||||
pub const CELL_PAD: f32 = 8.0;
|
||||
/// The narrowest the label column of a table gets before its text is cut.
|
||||
pub const LABEL_MIN: f32 = 72.0;
|
||||
pub const CONTROL_HEIGHT: f32 = 28.0;
|
||||
pub const CONTROL_PAD: f32 = 10.0;
|
||||
pub const CONTROL_HEIGHT: f32 = 24.0;
|
||||
pub const CONTROL_PAD: f32 = 9.0;
|
||||
pub const TITLE_SPACING: f32 = 0.8;
|
||||
pub const TOOLBAR_NOTE_WIDTH: f32 = 150.0;
|
||||
/// Between a raw counter's key and its value.
|
||||
@@ -180,47 +188,42 @@ pub mod layout {
|
||||
pub const THREE_COLUMNS_FROM: f32 = 1100.0;
|
||||
/// From this width it has two; below it, one.
|
||||
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.
|
||||
pub const RAW_LINE_WIDTH: f32 = 400.0;
|
||||
|
||||
pub const TOOLBAR_HEIGHT: f32 = 28.0;
|
||||
pub const HEADLINE_HEIGHT: f32 = 216.0;
|
||||
/// A headline figure: the number, its caption, the trend line and two lines of small print.
|
||||
pub const FIGURE_HEIGHT: f32 = 124.0;
|
||||
pub const CARD_HEIGHT: f32 = 104.0;
|
||||
/// The row of "Where compiles went", "By language" and "Problems". It grows
|
||||
/// only when the tables have more rows than this height holds.
|
||||
pub const TRIPTYCH_HEIGHT: f32 = 232.0;
|
||||
/// The row of "Over time" and "Speed".
|
||||
pub const CHARTS_HEIGHT: f32 = 516.0;
|
||||
pub const TOOLBAR_HEIGHT: f32 = 24.0;
|
||||
/// The hero band on a wide page: caption row, one row of figures and the storage line.
|
||||
pub const HEADLINE_HEIGHT: f32 = 296.0;
|
||||
/// A hero figure: the number, its caption, the trend line and two lines of small print.
|
||||
pub const FIGURE_HEIGHT: f32 = 176.0;
|
||||
/// One row of the counter strip.
|
||||
pub const STRIP_ROW_HEIGHT: f32 = 92.0;
|
||||
/// "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.
|
||||
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.
|
||||
pub const LANGUAGE_BARS_FROM: f32 = 380.0;
|
||||
/// "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.
|
||||
pub const SPEED_FIXED_HEIGHT: f32 = 250.0;
|
||||
/// "Problems" needs this much beside its problems.
|
||||
pub const PROBLEMS_FIXED_HEIGHT: f32 = 60.0;
|
||||
pub const SPEED_FIXED_HEIGHT: f32 = 240.0;
|
||||
/// "Speed" needs this much per language with a histogram.
|
||||
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.
|
||||
pub mod drawing {
|
||||
pub const CHART_HEIGHT: f32 = 170.0;
|
||||
pub const CHART_HEIGHT: f32 = 240.0;
|
||||
/// 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_AXIS: f32 = 14.0;
|
||||
pub const STACKED_BAR: f32 = 22.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_HEIGHT: f32 = 6.0;
|
||||
pub const LEGEND_SWATCH: f32 = 10.0;
|
||||
@@ -369,10 +372,10 @@ fn visuals(p: &Palette) -> egui::Visuals {
|
||||
expansion: 0.0,
|
||||
};
|
||||
visuals.widgets.noninteractive = control(p.track, p.border, p.muted);
|
||||
visuals.widgets.inactive = control(p.track, p.border, p.text);
|
||||
visuals.widgets.hovered = control(p.hover, p.accent, p.text);
|
||||
visuals.widgets.inactive = control(Color32::TRANSPARENT, p.border, 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.open = control(p.hover, p.accent, p.text);
|
||||
visuals.widgets.open = control(p.hover, p.muted, p.text);
|
||||
visuals
|
||||
}
|
||||
|
||||
@@ -382,7 +385,8 @@ pub fn install(ctx: &egui::Context) {
|
||||
ctx.all_styles_mut(|style| {
|
||||
style.text_styles = text_styles();
|
||||
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.visuals = visuals(of(style.visuals.dark_mode));
|
||||
});
|
||||
|
||||
@@ -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.
|
||||
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 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)]
|
||||
@@ -184,7 +184,7 @@ pub fn reasons(ui: &mut Ui, view: &View) {
|
||||
let side = theme::drawing::SEVERITY_DOT;
|
||||
let dot = if reason.fixable { p.warn } else { p.not_cacheable };
|
||||
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);
|
||||
let chevron_left = row.right() - CHEVRON;
|
||||
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.
|
||||
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 list = disclosure::list_height(&entries, theme::space::LINE, theme::space::ITEM, SEPARATOR);
|
||||
theme::layout::REASONS_FIXED_HEIGHT + list.max(theme::space::ROW)
|
||||
|
||||
Reference in new issue
Block a user