Compare commits
8
Commits
f08f4655e4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a2bcefd38 | ||
|
|
06abc4de80 | ||
|
|
e3b56cb213 | ||
|
|
c2b07734c6 | ||
|
|
30643390a7 | ||
|
|
0759cbaa25 | ||
|
|
29e5103648 | ||
|
|
9630b96c1b |
No files matched your search
@@ -74,8 +74,14 @@ reading ever is a baseline and counts for nothing.
|
|||||||
|
|
||||||
## Notes on sccache
|
## Notes on sccache
|
||||||
|
|
||||||
When no sccache server is running, sccache-dash starts one (`sccache --start-server`); if that
|
sccache-dash never starts or stops sccache's server by itself. When none is running it shows
|
||||||
fails it shows "not running" with the error and tries again a minute later.
|
"not running"; sccache starts its own server on your next build, with your build's settings.
|
||||||
|
|
||||||
|
To have sccache-dash start the server when none is running, set `SCCACHE_DASH_START_SCCACHE=1`
|
||||||
|
in its environment. Be careful with this: a server started that way gets sccache-dash's
|
||||||
|
environment, not your build's. If your cache size or folder is set only in your build's
|
||||||
|
environment, the server comes up with sccache's defaults, and sccache deletes cache entries
|
||||||
|
until the cache fits the 10 GB default.
|
||||||
|
|
||||||
While sccache-dash runs, sccache's server stays up: being asked for its stats every 10 seconds
|
While sccache-dash runs, sccache's server stays up: being asked for its stats every 10 seconds
|
||||||
keeps it from shutting itself down after 10 idle minutes.
|
keeps it from shutting itself down after 10 idle minutes.
|
||||||
|
|||||||
@@ -34,10 +34,16 @@ pub struct Config {
|
|||||||
pub sccache: OsString,
|
pub sccache: OsString,
|
||||||
/// The SQLite file the history is saved in.
|
/// The SQLite file the history is saved in.
|
||||||
pub history: PathBuf,
|
pub history: PathBuf,
|
||||||
|
/// Whether to start sccache's server when none is listening. Off unless asked for: a
|
||||||
|
/// server started from here has this program's environment, not the builds', so it can
|
||||||
|
/// come up with another cache size or folder, and sccache trims the cache to the size
|
||||||
|
/// it is started with.
|
||||||
|
pub start_sccache: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/// `SCCACHE_DASH_SCCACHE` names the sccache command (`sccache` when unset); the history
|
/// `SCCACHE_DASH_SCCACHE` names the sccache command (`sccache` when unset);
|
||||||
|
/// `SCCACHE_DASH_START_SCCACHE=1` lets it start sccache's server; the history
|
||||||
/// lives in `$XDG_DATA_HOME/sccache-dash/history.db`.
|
/// lives in `$XDG_DATA_HOME/sccache-dash/history.db`.
|
||||||
pub fn from_env() -> Result<Config, String> {
|
pub fn from_env() -> Result<Config, String> {
|
||||||
let sccache = std::env::var_os("SCCACHE_DASH_SCCACHE").unwrap_or_else(|| "sccache".into());
|
let sccache = std::env::var_os("SCCACHE_DASH_SCCACHE").unwrap_or_else(|| "sccache".into());
|
||||||
@@ -46,6 +52,7 @@ impl Config {
|
|||||||
Ok(Config {
|
Ok(Config {
|
||||||
sccache,
|
sccache,
|
||||||
history: dir.join("sccache-dash").join("history.db"),
|
history: dir.join("sccache-dash").join("history.db"),
|
||||||
|
start_sccache: std::env::var_os("SCCACHE_DASH_START_SCCACHE").is_some_and(|v| v == "1"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,9 +306,12 @@ impl Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Starts sccache's server when none is listening, at most once a minute. `Err` says why
|
/// Starts sccache's server when none is listening and that was asked for, at most once a minute. `Err` says why
|
||||||
/// there is none, including when an earlier attempt is still being waited out.
|
/// there is none, including when an earlier attempt is still being waited out.
|
||||||
fn start_server(&mut self, app: &App, now: i64) -> Result<(), String> {
|
fn start_server(&mut self, app: &App, now: i64) -> Result<(), String> {
|
||||||
|
if !app.cfg.start_sccache {
|
||||||
|
return Err("no sccache server is running; your next build starts it".to_owned());
|
||||||
|
}
|
||||||
if let Some(when) = self.started_at {
|
if let Some(when) = self.started_at {
|
||||||
if now - when < START_EVERY {
|
if now - when < START_EVERY {
|
||||||
return Err(self
|
return Err(self
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ esac
|
|||||||
Config {
|
Config {
|
||||||
sccache: self.script.clone().into(),
|
sccache: self.script.clone().into(),
|
||||||
history: self.history.clone(),
|
history: self.history.clone(),
|
||||||
|
start_sccache: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,6 +445,30 @@ fn old_rows_are_deleted_at_startup() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_missing_sccache_server_is_left_alone_unless_starting_was_asked_for() {
|
||||||
|
let fake = Fake::new();
|
||||||
|
fake.down();
|
||||||
|
let app = App::with_probe(
|
||||||
|
Config {
|
||||||
|
start_sccache: false,
|
||||||
|
..fake.config()
|
||||||
|
},
|
||||||
|
fake.probe(),
|
||||||
|
);
|
||||||
|
let mut task = Task::memory();
|
||||||
|
|
||||||
|
task.poll(&app, NOW);
|
||||||
|
task.poll(&app, NOW + 120);
|
||||||
|
let calls = fake.calls();
|
||||||
|
assert!(!calls.iter().any(|c| c == "--start-server"), "{calls:?}");
|
||||||
|
assert!(app
|
||||||
|
.lock()
|
||||||
|
.error
|
||||||
|
.as_deref()
|
||||||
|
.is_some_and(|e| e.contains("your next build starts it")));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_missing_sccache_server_is_started_once_then_read() {
|
fn a_missing_sccache_server_is_started_once_then_read() {
|
||||||
let fake = Fake::new();
|
let fake = Fake::new();
|
||||||
|
|||||||
+185
-181
@@ -5,6 +5,7 @@ use std::time::Duration;
|
|||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use sccache_dash_api::{Range, View};
|
use sccache_dash_api::{Range, View};
|
||||||
|
|
||||||
|
use crate::disclosure;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::{cards, extras, net, overtime, problems, raw, speed, style, where_went};
|
use crate::{cards, extras, net, overtime, problems, raw, speed, style, where_went};
|
||||||
@@ -249,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();
|
||||||
@@ -285,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];
|
||||||
@@ -293,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),
|
||||||
@@ -303,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.
|
||||||
@@ -313,20 +329,30 @@ 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.allocate_ui_with_layout(egui::vec2(room, height), layout, |ui| {
|
ui.horizontal(|ui| {
|
||||||
if !phone {
|
ui.add_space(margin);
|
||||||
ui.allocate_ui_with_layout(
|
ui.allocate_ui_with_layout(egui::vec2(room, height), layout, |ui| {
|
||||||
egui::vec2(group_width, height),
|
if !phone {
|
||||||
egui::Layout::left_to_right(egui::Align::Center),
|
ui.allocate_ui_with_layout(
|
||||||
|ui| actions(dashboard, ui, &ctx, now, gap),
|
egui::vec2(group_width, height),
|
||||||
);
|
egui::Layout::left_to_right(egui::Align::Center),
|
||||||
} else {
|
|ui| actions(dashboard, ui, &ctx, now, gap),
|
||||||
ui.spacing_mut().item_spacing = egui::vec2(gap, gap);
|
);
|
||||||
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.
|
/// Refresh, theme, Copy summary, Export JSON, Zero stats, and the message slot.
|
||||||
@@ -460,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()
|
||||||
@@ -481,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| {
|
||||||
@@ -490,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!(
|
||||||
@@ -528,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;
|
||||||
@@ -549,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;
|
||||||
@@ -596,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,
|
||||||
@@ -604,73 +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 half = style::span_width(ui, 2, 1);
|
||||||
let third = style::span_width(ui, 3, 1);
|
let languages_h = table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len() + 1);
|
||||||
let [a, b, c] = row(ui, triptych_height(ui, view, third), &[1, 1, 1]).try_into().expect("three panels");
|
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 (_, 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]);
|
||||||
close_row(ui, &[a, b, c]);
|
|
||||||
|
|
||||||
// "Over time" over two columns; "Speed" and the reasons stacked in the third, together as tall.
|
overtime::filter(ui, view, hidden_languages);
|
||||||
let height = charts_height(ui, view, third);
|
ui.add_space(theme::space::ITEM);
|
||||||
let [wide, side] = row(ui, height, &[2, 1]).try_into().expect("two panels");
|
let hidden: &[String] = hidden_languages;
|
||||||
let speed = speed_height(view);
|
let [a, b] = row(ui, l::CHART_PANEL_HEIGHT, &[1, 1]).try_into().expect("two panels");
|
||||||
let speed_rect = egui::Rect::from_min_max(side.min, egui::pos2(side.right(), side.top() + speed));
|
let (_, a) = style::panel(ui, a, "Hit rate over time", |ui| {
|
||||||
let reasons_rect = egui::Rect::from_min_max(egui::pos2(side.left(), side.top() + speed + gap), side.max);
|
overtime::hit_rate_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
|
||||||
let (_, wide) = style::panel(ui, wide, "Over time", |ui| {
|
});
|
||||||
overtime::section(ui, view, hidden_languages, chart_height(height))
|
let (_, b) = style::panel(ui, b, "Compiles over time", |ui| {
|
||||||
});
|
overtime::volume_panel(ui, view, hidden, theme::drawing::CHART_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| {
|
close_row(ui, &[a, b]);
|
||||||
where_went::reasons(ui, view)
|
|
||||||
});
|
let height = speed_height(view).max(where_went::reasons_height(ui, view, half));
|
||||||
close_row(ui, &[wide, speed, reasons]);
|
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));
|
||||||
2 => {
|
let (_, b) = style::panel(ui, b, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
|
||||||
let half = style::span_width(ui, 2, 1);
|
close_row(ui, &[a, b]);
|
||||||
let reasons = where_went::reasons_height(ui, view, half);
|
} else {
|
||||||
let height = l::TRIPTYCH_HEIGHT.max(l::WHERE_FIXED_HEIGHT).max(reasons);
|
// One column: each panel as tall as what it holds.
|
||||||
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels");
|
single(ui, "Where compiles went", |ui| where_went::section(ui, view));
|
||||||
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
|
single(ui, "By language", |ui| where_went::languages(ui, view));
|
||||||
let (_, b) = style::panel(ui, b, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
|
overtime::filter(ui, view, hidden_languages);
|
||||||
close_row(ui, &[a, b]);
|
ui.add_space(theme::space::ITEM);
|
||||||
let height = l::TRIPTYCH_HEIGHT
|
let hidden: &[String] = hidden_languages;
|
||||||
.max(table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len()))
|
single(ui, "Hit rate over time", |ui| {
|
||||||
.max(problems_height(ui, view, half));
|
overtime::hit_rate_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
|
||||||
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));
|
single(ui, "Compiles over time", |ui| {
|
||||||
let (_, b) = style::panel(ui, b, "Problems", |ui| problems::section(ui, view));
|
overtime::volume_panel(ui, view, hidden, theme::drawing::CHART_HEIGHT)
|
||||||
close_row(ui, &[a, b]);
|
});
|
||||||
let [a] = row(ui, l::CHARTS_HEIGHT, &[2]).try_into().expect("one panel");
|
single(ui, "Speed", |ui| speed::section(ui, view));
|
||||||
let (_, a) = style::panel(ui, a, "Over time", |ui| {
|
single(ui, "Why compiles were not cacheable", |ui| where_went::reasons(ui, view));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@@ -681,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) {
|
||||||
@@ -711,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) {
|
||||||
@@ -724,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);
|
||||||
let value = egui::Label::new(
|
// Shrink a long figure to the column instead of cutting it.
|
||||||
egui::RichText::new(&self.value)
|
let natural = style::text_width(ui, &self.value, theme::number_font(self.size));
|
||||||
.font(theme::number_font(self.size))
|
let size = if natural > width { (self.size * width / natural).max(20.0) } else { self.size };
|
||||||
.color(self.color),
|
ui.allocate_ui_with_layout(
|
||||||
)
|
egui::vec2(width, VALUE_ROW),
|
||||||
.truncate();
|
egui::Layout::left_to_right(egui::Align::Max),
|
||||||
ui.add(value.sense(egui::Sense::hover())).on_hover_text(&self.value);
|
|ui| {
|
||||||
ui.add(egui::Label::new(theme::small(ui, self.caption.clone())).truncate());
|
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 {
|
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),
|
||||||
@@ -765,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",
|
||||||
@@ -781,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,
|
||||||
@@ -798,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(),
|
||||||
};
|
};
|
||||||
@@ -848,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();
|
||||||
@@ -895,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()
|
||||||
};
|
};
|
||||||
@@ -915,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
@@ -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 {
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
//! The arithmetic of a list of lines that open: which start open, how tall the
|
||||||
|
//! list is, and whether stacking panels beside it wastes less room. No drawing
|
||||||
|
//! here, so it is tested natively.
|
||||||
|
|
||||||
|
/// A line that opens to show a text beneath it, laid out for a width.
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
|
pub struct Entry {
|
||||||
|
/// The line itself.
|
||||||
|
pub row: f32,
|
||||||
|
pub open: bool,
|
||||||
|
/// The first paragraph's height; used only when open.
|
||||||
|
pub meaning: f32,
|
||||||
|
/// The second paragraph's height, `None` when there is none; used only when open.
|
||||||
|
pub action: Option<f32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether a line is open: what was clicked, else open when `fixable`.
|
||||||
|
pub fn is_open(stored: Option<bool>, fixable: bool) -> bool {
|
||||||
|
stored.unwrap_or(fixable)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How tall one line is: `gap` between its parts, `pad` under the open text.
|
||||||
|
pub fn entry_height(entry: &Entry, gap: f32, pad: f32) -> f32 {
|
||||||
|
if !entry.open {
|
||||||
|
return entry.row;
|
||||||
|
}
|
||||||
|
let action = entry.action.map_or(0.0, |height| gap + height);
|
||||||
|
entry.row + gap + entry.meaning + action + pad
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How tall the whole list is: its lines and a hairline `separator` tall between them.
|
||||||
|
pub fn list_height(entries: &[Entry], gap: f32, pad: f32, separator: f32) -> f32 {
|
||||||
|
let lines: f32 = entries.iter().map(|entry| entry_height(entry, gap, pad)).sum();
|
||||||
|
lines + entries.len().saturating_sub(1) as f32 * separator
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether to stack the panels (`stacked` tall in all) beside a panel `beside` tall rather
|
||||||
|
/// than put the one `single` panel there: yes when that leaves less empty room.
|
||||||
|
pub fn stack_beside(single: f32, stacked: f32, beside: f32) -> bool {
|
||||||
|
(stacked - beside).abs() < (single - beside).abs()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn entry(open: bool) -> Entry {
|
||||||
|
Entry { row: 28.0, open, meaning: 45.0, action: Some(30.0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn only_fixable_lines_start_open() {
|
||||||
|
assert!(is_open(None, true));
|
||||||
|
assert!(!is_open(None, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_click_wins_over_the_default() {
|
||||||
|
assert!(!is_open(Some(false), true));
|
||||||
|
assert!(is_open(Some(true), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_closed_line_is_one_row_and_an_open_one_adds_its_text() {
|
||||||
|
assert_eq!(entry_height(&entry(false), 3.0, 8.0), 28.0);
|
||||||
|
assert_eq!(entry_height(&entry(true), 3.0, 8.0), 28.0 + 3.0 + 45.0 + 3.0 + 30.0 + 8.0);
|
||||||
|
let no_action = Entry { action: None, ..entry(true) };
|
||||||
|
assert_eq!(entry_height(&no_action, 3.0, 8.0), 28.0 + 3.0 + 45.0 + 8.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_list_is_its_lines_and_the_hairlines_between() {
|
||||||
|
let list = [entry(true), entry(false), entry(false)];
|
||||||
|
assert_eq!(list_height(&list, 3.0, 8.0, 1.0), 117.0 + 28.0 + 28.0 + 2.0);
|
||||||
|
assert_eq!(list_height(&[], 3.0, 8.0, 1.0), 0.0);
|
||||||
|
assert_eq!(list_height(&[entry(false)], 3.0, 8.0, 1.0), 28.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stacking_is_chosen_only_when_it_fills_the_room_better() {
|
||||||
|
// Everything closed: the lone panel (244) is close to the list (300); three stacked (500) are not.
|
||||||
|
assert!(!stack_beside(244.0, 500.0, 300.0));
|
||||||
|
// Two open: the list (520) is nearer the stack.
|
||||||
|
assert!(stack_beside(244.0, 500.0, 520.0));
|
||||||
|
// A tie keeps the simple layout.
|
||||||
|
assert!(!stack_beside(200.0, 400.0, 300.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,13 @@ pub fn previous_label(range: Range) -> String {
|
|||||||
format!("previous {}", label.strip_prefix("last ").unwrap_or(label))
|
format!("previous {}", label.strip_prefix("last ").unwrap_or(label))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The lowest edge of a row of panels: the largest of their `bottoms`, or
|
||||||
|
/// `empty` when there are none. The bottoms are screen positions, so they are
|
||||||
|
/// negative while the row is scrolled above the top of the window.
|
||||||
|
pub fn lowest(bottoms: impl IntoIterator<Item = f32>, empty: f32) -> f32 {
|
||||||
|
bottoms.into_iter().reduce(f32::max).unwrap_or(empty)
|
||||||
|
}
|
||||||
|
|
||||||
/// Whole-number percentages of `parts` that add up to exactly 100, giving the
|
/// Whole-number percentages of `parts` that add up to exactly 100, giving the
|
||||||
/// leftovers of rounding to the largest shares. All zero when nothing is counted.
|
/// leftovers of rounding to the largest shares. All zero when nothing is counted.
|
||||||
pub fn shares(parts: &[u64]) -> Vec<u64> {
|
pub fn shares(parts: &[u64]) -> Vec<u64> {
|
||||||
@@ -229,6 +236,15 @@ pub fn hidden_after_all<'a>(ticked: bool, languages: impl Iterator<Item = &'a st
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_row_scrolled_above_the_window_still_ends_at_its_own_bottom() {
|
||||||
|
// Rows closed by their lowest panel: the same answer wherever the page is scrolled.
|
||||||
|
assert_eq!(lowest([260.0, 300.0, 280.0], 0.0), 300.0);
|
||||||
|
assert_eq!(lowest([-340.0, -300.0, -320.0], 0.0), -300.0);
|
||||||
|
assert_eq!(lowest([-17250.0, -17210.5], 0.0), -17210.5);
|
||||||
|
assert_eq!(lowest([], 42.0), 42.0);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn counts_have_thousands_separators() {
|
fn counts_have_thousands_separators() {
|
||||||
assert_eq!(count(0), "0");
|
assert_eq!(count(0), "0");
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//! The sccache-dash dashboard page. `trunk` compiles this to WebAssembly and
|
//! The sccache-dash dashboard page. `trunk` compiles this to WebAssembly and
|
||||||
//! the sccache-dash server serves it at http://127.0.0.1:8226.
|
//! the sccache-dash server serves it at http://127.0.0.1:8226.
|
||||||
|
|
||||||
|
pub mod disclosure;
|
||||||
pub mod fmt;
|
pub mod fmt;
|
||||||
|
|
||||||
// Drawing needs eframe, which is only built for the browser so far; the rest
|
// Drawing needs eframe, which is only built for the browser so far; the rest
|
||||||
|
|||||||
+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)
|
(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();
|
||||||
|
|||||||
+66
-30
@@ -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])
|
||||||
let color = match problem.severity {
|
.show(ui, |ui| {
|
||||||
Severity::Error => p.bad,
|
ui.spacing_mut().item_spacing.y = 0.0;
|
||||||
Severity::Warning => p.warn,
|
let width = ui.available_width();
|
||||||
};
|
let indent = theme::drawing::SEVERITY_DOT + GAP;
|
||||||
ui.horizontal(|ui| {
|
for problem in &view.problems {
|
||||||
ui.spacing_mut().item_spacing.x = theme::space::ITEM + 2.0;
|
let id = open_id(&problem.title);
|
||||||
style::dot(ui, color);
|
let open = ui.ctx().data(|data| data.get_temp::<bool>(id)).unwrap_or(false);
|
||||||
ui.add(
|
let (row, response) = ui.allocate_exact_size(egui::vec2(width, ROW), Sense::click());
|
||||||
egui::Label::new(
|
let response = response.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||||
theme::strong(problem.title.clone()).color(color),
|
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
|
//! 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,
|
||||||
|
|||||||
@@ -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 [
|
||||||
|
|||||||
+34
-49
@@ -71,7 +71,7 @@ pub fn cells(ui: &Ui, height: f32, spans: &[usize]) -> Vec<Rect> {
|
|||||||
|
|
||||||
/// Close a row of panels drawn at `rects`: the cursor moves below the tallest.
|
/// Close a row of panels drawn at `rects`: the cursor moves below the tallest.
|
||||||
pub fn end_row(ui: &mut Ui, rects: &[Rect]) {
|
pub fn end_row(ui: &mut Ui, rects: &[Rect]) {
|
||||||
let bottom = rects.iter().map(|rect| rect.bottom()).fold(0.0, f32::max);
|
let bottom = crate::fmt::lowest(rects.iter().map(|rect| rect.bottom()), ui.cursor().top());
|
||||||
let left = rects.first().map_or(ui.cursor().left(), |rect| rect.left());
|
let left = rects.first().map_or(ui.cursor().left(), |rect| rect.left());
|
||||||
ui.allocate_rect(
|
ui.allocate_rect(
|
||||||
Rect::from_min_max(Pos2::new(left, ui.cursor().top()), Pos2::new(ui.cursor().right(), bottom)),
|
Rect::from_min_max(Pos2::new(left, ui.cursor().top()), Pos2::new(ui.cursor().right(), bottom)),
|
||||||
@@ -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
@@ -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));
|
||||||
});
|
});
|
||||||
|
|||||||
+94
-39
@@ -6,8 +6,9 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use eframe::egui::{self, Color32, Sense, Stroke, Ui};
|
use eframe::egui::{self, Color32, Sense, Stroke, Ui};
|
||||||
use eframe::epaint::text::Galley;
|
use eframe::epaint::text::Galley;
|
||||||
use sccache_dash_api::View;
|
use sccache_dash_api::{NotCached, View};
|
||||||
|
|
||||||
|
use crate::disclosure;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::style::{self, Cell};
|
use crate::style::{self, Cell};
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
@@ -57,32 +58,47 @@ pub fn section(ui: &mut Ui, view: &View) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One reason laid out for a width: its name, numbers and the two small paragraphs.
|
/// One reason laid out for a width: its line, and the two small paragraphs when it is open.
|
||||||
struct Block {
|
struct Block {
|
||||||
name: Arc<Galley>,
|
name: Arc<Galley>,
|
||||||
count: Arc<Galley>,
|
count: Arc<Galley>,
|
||||||
share: Arc<Galley>,
|
share: Arc<Galley>,
|
||||||
meaning: Arc<Galley>,
|
/// `None` while the reason is closed.
|
||||||
/// `None` when sccache gives nothing to do.
|
meaning: Option<Arc<Galley>>,
|
||||||
|
/// `None` when closed, or when sccache gives nothing to do.
|
||||||
action: Option<Arc<Galley>>,
|
action: Option<Arc<Galley>>,
|
||||||
/// The first line: the name, or as tall as the name when it wraps.
|
/// The line: at least a control tall, taller when the name wraps.
|
||||||
row: f32,
|
row: f32,
|
||||||
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Block {
|
impl Block {
|
||||||
/// Its height, counting the room each part is given.
|
fn entry(&self) -> disclosure::Entry {
|
||||||
fn height(&self) -> f32 {
|
disclosure::Entry {
|
||||||
let line = theme::space::LINE;
|
row: self.row,
|
||||||
let mut height = self.row + line + self.meaning.size().y + line;
|
open: self.open,
|
||||||
if let Some(action) = &self.action {
|
meaning: self.meaning.as_ref().map_or(0.0, |g| g.size().y),
|
||||||
height += action.size().y + line;
|
action: self.action.as_ref().map(|g| g.size().y),
|
||||||
}
|
}
|
||||||
height
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How far the name is from the numbers, and from the dot.
|
/// How far the name is from the numbers, and from the dot.
|
||||||
const NAME_GAP: f32 = 8.0;
|
const NAME_GAP: f32 = 8.0;
|
||||||
|
/// The side of the chevron's triangle box.
|
||||||
|
const CHEVRON: f32 = 8.0;
|
||||||
|
/// The hairline between two lines.
|
||||||
|
const SEPARATOR: f32 = 1.0;
|
||||||
|
|
||||||
|
/// Where a reason remembers whether it is open.
|
||||||
|
fn open_id(reason: &str) -> egui::Id {
|
||||||
|
egui::Id::new(("reason-open", reason))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_open(ctx: &egui::Context, reason: &NotCached) -> bool {
|
||||||
|
let stored = ctx.data(|data| data.get_temp::<bool>(open_id(&reason.reason)));
|
||||||
|
disclosure::is_open(stored, reason.fixable)
|
||||||
|
}
|
||||||
|
|
||||||
/// Lay every reason out in `width`; counts and shares line up in columns, the name takes the rest.
|
/// Lay every reason out in `width`; counts and shares line up in columns, the name takes the rest.
|
||||||
fn blocks(ui: &Ui, view: &View, width: f32) -> Vec<Block> {
|
fn blocks(ui: &Ui, view: &View, width: f32) -> Vec<Block> {
|
||||||
@@ -96,29 +112,43 @@ fn blocks(ui: &Ui, view: &View, width: f32) -> Vec<Block> {
|
|||||||
numbers.iter().map(|n| pick(n).size().x).fold(0.0, f32::max)
|
numbers.iter().map(|n| pick(n).size().x).fold(0.0, f32::max)
|
||||||
};
|
};
|
||||||
let (count_width, share_width) = (widest(|n| &n.0), widest(|n| &n.1));
|
let (count_width, share_width) = (widest(|n| &n.0), widest(|n| &n.1));
|
||||||
let dot = theme::drawing::SEVERITY_DOT + NAME_GAP;
|
let indent = theme::drawing::SEVERITY_DOT + NAME_GAP;
|
||||||
let name_width = (width - dot - count_width - share_width - 2.0 * NAME_GAP).max(40.0);
|
let name_width = (width - indent - count_width - share_width - CHEVRON - 3.0 * NAME_GAP).max(40.0);
|
||||||
view.not_cached
|
view.not_cached
|
||||||
.iter()
|
.iter()
|
||||||
.zip(numbers)
|
.zip(numbers)
|
||||||
.map(|(r, (count, share))| {
|
.map(|(r, (count, share))| {
|
||||||
let name = style::galley(ui, theme::body(r.name.clone()), true, name_width);
|
let name = style::galley(ui, theme::body(r.name.clone()), true, name_width);
|
||||||
let small = |text: &str| style::galley(ui, theme::small(ui, text), true, width);
|
let open = is_open(ui.ctx(), r);
|
||||||
|
let small = |text: &str| style::galley(ui, theme::small(ui, text), true, width - indent);
|
||||||
Block {
|
Block {
|
||||||
row: theme::space::ROW.max(name.size().y + 6.0),
|
row: theme::space::CONTROL_HEIGHT.max(name.size().y + 2.0 * theme::space::ITEM),
|
||||||
name,
|
name,
|
||||||
count,
|
count,
|
||||||
share,
|
share,
|
||||||
meaning: small(&r.meaning),
|
meaning: open.then(|| small(&r.meaning)),
|
||||||
action: (!r.action.is_empty()).then(|| small(&r.action)),
|
action: (open && !r.action.is_empty()).then(|| small(&r.action)),
|
||||||
|
open,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "Why compiles were not cacheable": each reason with a dot (the warning colour when a
|
/// A triangle in the muted colour: pointing right when closed, down when open.
|
||||||
/// setting would fix it, the muted one when it is expected), its plain name, its count and
|
pub(crate) fn chevron(painter: &egui::Painter, center: egui::Pos2, open: bool, color: Color32) {
|
||||||
/// share, and under it, in small print, what it means and what to do.
|
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)]
|
||||||
|
} else {
|
||||||
|
vec![center + egui::vec2(-h / 2.0, -h), center + egui::vec2(-h / 2.0, h), center + egui::vec2(h / 2.0 + 1.0, 0.0)]
|
||||||
|
};
|
||||||
|
painter.add(egui::Shape::convex_polygon(points, color, Stroke::NONE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "Why compiles were not cacheable": one line per reason, each with a dot (the warning
|
||||||
|
/// colour when a setting would fix it, the muted one when it is expected), its plain name,
|
||||||
|
/// its count and share, and a chevron. Clicking the line shows, in small print under it,
|
||||||
|
/// what it means and what to do; the reasons a setting would fix start open.
|
||||||
pub fn reasons(ui: &mut Ui, view: &View) {
|
pub fn reasons(ui: &mut Ui, view: &View) {
|
||||||
if view.not_cached.is_empty() {
|
if view.not_cached.is_empty() {
|
||||||
ui.label(theme::small(ui, "Every compile could be cached in this range."));
|
ui.label(theme::small(ui, "Every compile could be cached in this range."));
|
||||||
@@ -127,38 +157,63 @@ pub fn reasons(ui: &mut Ui, view: &View) {
|
|||||||
let p = theme::ui(ui);
|
let p = theme::ui(ui);
|
||||||
let width = ui.available_width();
|
let width = ui.available_width();
|
||||||
let blocks = blocks(ui, view, width);
|
let blocks = blocks(ui, view, width);
|
||||||
|
let indent = theme::drawing::SEVERITY_DOT + NAME_GAP;
|
||||||
|
// Every height is added by hand, so the list is as tall as `reasons_height` says.
|
||||||
|
ui.spacing_mut().item_spacing.y = 0.0;
|
||||||
for (index, (reason, block)) in view.not_cached.iter().zip(&blocks).enumerate() {
|
for (index, (reason, block)) in view.not_cached.iter().zip(&blocks).enumerate() {
|
||||||
if index > 0 {
|
if index > 0 {
|
||||||
let (gap, _) = ui.allocate_exact_size(egui::vec2(width, theme::space::BETWEEN_PARTS), Sense::hover());
|
let (gap, _) = ui.allocate_exact_size(egui::vec2(width, SEPARATOR), Sense::hover());
|
||||||
ui.painter().hline(gap.x_range(), gap.center().y.round() + 0.5, Stroke::new(1.0, p.grid));
|
ui.painter().rect_filled(gap, 0.0, p.grid);
|
||||||
|
}
|
||||||
|
let (row, response) = ui.allocate_exact_size(egui::vec2(width, block.row), Sense::click());
|
||||||
|
let response = response.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||||
|
response.widget_info(|| {
|
||||||
|
egui::WidgetInfo::labeled(egui::WidgetType::Button, true, reason.name.as_str())
|
||||||
|
});
|
||||||
|
if response.clicked() {
|
||||||
|
ui.ctx().data_mut(|data| data.insert_temp(open_id(&reason.reason), !block.open));
|
||||||
|
ui.ctx().request_repaint();
|
||||||
}
|
}
|
||||||
let (row, _) = ui.allocate_exact_size(egui::vec2(width, block.row), Sense::hover());
|
|
||||||
let painter = ui.painter();
|
let painter = ui.painter();
|
||||||
|
if response.hovered() || response.has_focus() {
|
||||||
|
painter.rect_filled(row, theme::space::CONTROL_RADIUS, p.hover);
|
||||||
|
}
|
||||||
|
if response.has_focus() {
|
||||||
|
painter.rect_stroke(row, theme::space::CONTROL_RADIUS, Stroke::new(1.0, p.muted), egui::StrokeKind::Inside);
|
||||||
|
}
|
||||||
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, name_top + 8.0), 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() + side + NAME_GAP, name_top), block.name.clone(), p.text);
|
painter.galley(egui::pos2(row.left() + indent, name_top), block.name.clone(), p.text);
|
||||||
let share_left = row.right() - block.share.size().x;
|
let chevron_left = row.right() - CHEVRON;
|
||||||
let at = |galley: &Arc<Galley>, right: f32| {
|
chevron(painter, egui::pos2(chevron_left + CHEVRON / 2.0, row.center().y), block.open, p.muted);
|
||||||
egui::pos2(right - galley.size().x, row.top() + (block.row - galley.size().y) / 2.0)
|
let share_left = chevron_left - NAME_GAP - block.share.size().x;
|
||||||
|
let at = |galley: &Arc<Galley>, left: f32| {
|
||||||
|
egui::pos2(left, row.top() + (block.row - galley.size().y) / 2.0)
|
||||||
};
|
};
|
||||||
painter.galley(at(&block.share, row.right()), block.share.clone(), p.text);
|
painter.galley(at(&block.share, share_left), block.share.clone(), p.text);
|
||||||
painter.galley(at(&block.count, share_left - NAME_GAP), block.count.clone(), p.text);
|
let count_left = share_left - NAME_GAP - block.count.size().x;
|
||||||
for galley in std::iter::once(&block.meaning).chain(block.action.as_ref()) {
|
painter.galley(at(&block.count, count_left), block.count.clone(), p.text);
|
||||||
let (place, _) = ui.allocate_exact_size(galley.size(), Sense::hover());
|
let mut opened = false;
|
||||||
ui.painter().galley(place.min, galley.clone(), p.muted);
|
for galley in block.meaning.iter().chain(block.action.as_ref()) {
|
||||||
|
ui.add_space(theme::space::LINE);
|
||||||
|
let (place, _) = ui.allocate_exact_size(egui::vec2(width, galley.size().y), Sense::hover());
|
||||||
|
ui.painter().galley(egui::pos2(place.left() + indent, place.top()), galley.clone(), p.muted);
|
||||||
|
opened = true;
|
||||||
|
}
|
||||||
|
if opened {
|
||||||
|
ui.add_space(theme::space::ITEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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 blocks = blocks(ui, view, inner);
|
let entries: Vec<_> = blocks(ui, view, inner).iter().map(Block::entry).collect();
|
||||||
let gaps = blocks.len().saturating_sub(1) as f32 * (theme::space::BETWEEN_PARTS + theme::space::LINE);
|
let list = disclosure::list_height(&entries, theme::space::LINE, theme::space::ITEM, SEPARATOR);
|
||||||
let content: f32 = blocks.iter().map(Block::height).sum();
|
theme::layout::REASONS_FIXED_HEIGHT + list.max(theme::space::ROW)
|
||||||
theme::layout::REASONS_FIXED_HEIGHT + content.max(theme::space::ROW) + gaps
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "By language": one row per language, with hits, misses, errors, the hit rate
|
/// "By language": one row per language, with hits, misses, errors, the hit rate
|
||||||
|
|||||||
@@ -8,3 +8,7 @@ test:
|
|||||||
|
|
||||||
run:
|
run:
|
||||||
cargo run -p sccache-dash
|
cargo run -p sccache-dash
|
||||||
|
|
||||||
|
# Screenshots of the whole page at the 3, 2 and 1 column widths; read them before merging a page change.
|
||||||
|
shots url="http://127.0.0.1:8226/" out="target/shots":
|
||||||
|
prlimit --core=1:1 -- node scripts/shots.js {{url}} {{out}}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Screenshots of the whole page at each layout width (3, 2 and 1 column), read
|
||||||
|
// before any page change is merged. Usage: just shots [url] [out-dir]
|
||||||
|
const path = require('path');
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
const root = execSync('mise where npm:playwright 2>/dev/null || mise where playwright', { encoding: 'utf8' }).trim();
|
||||||
|
const { chromium } = require(path.join(root, 'node_modules/playwright'));
|
||||||
|
const [, , url = 'http://127.0.0.1:8226/', out = 'target/shots'] = process.argv;
|
||||||
|
(async () => {
|
||||||
|
require('fs').mkdirSync(out, { recursive: true });
|
||||||
|
const browser = await chromium.launch({
|
||||||
|
args: ['--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'],
|
||||||
|
});
|
||||||
|
for (const [width, height] of [[1400, 2600], [900, 3600], [390, 5600]]) {
|
||||||
|
// The page scrolls inside its canvas, so a tall window shows all of it.
|
||||||
|
const page = await browser.newPage({ viewport: { width, height }, colorScheme: 'dark' });
|
||||||
|
await page.goto(url);
|
||||||
|
await page.waitForTimeout(5000);
|
||||||
|
const file = path.join(out, `page-${width}.png`);
|
||||||
|
await page.screenshot({ path: file });
|
||||||
|
console.log(file);
|
||||||
|
await page.close();
|
||||||
|
}
|
||||||
|
await browser.close();
|
||||||
|
})().catch((error) => { console.error(error); process.exit(1); });
|
||||||
Reference in new issue
Block a user