feat(gui): the company is named once in the frame: a tab, with a hue; its card at the foot; no header, no heading
The tab, the sidebar's header and the Overview's heading all said the company's name side by side. Now the tab is the company's identity (badge and name); the sidebar header and the Overview heading are gone (the summary sentence leads the page, at the theme's heading size); and the status card at the foot of the sidebar opens with a heading row, the badge and the name (the rail shows the badge alone, the name on hover), so "these are this company's books: verified, live" is on every page, at the opposite corner from the tabs. The top of the sidebar is an empty `top_slot` for the assistant's connection state, a later unit. Each company has one of eight badge hues (theme::BADGE_HUES, light and dark) chosen by FNV-1a of the id of its books: a function of the id alone, so it is the same on its tab and its card, after a restart, in any order of opening and on every machine. A test computes the contrast of every hue in both themes: letter 4.5:1, badge 3:1 on each surface it sits on. No figure, date or amount changed. Regenerated: the tall sidebar's shapes and pixel goldens (header gone, links moved up, card heading row, hue) and the eight tabs_* snapshots (hue, Overview lead, the rail's badge). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
No files matched your search
@@ -617,6 +617,7 @@ impl eframe::App for App {
|
||||
_ => title.clone(),
|
||||
},
|
||||
title,
|
||||
hue_key: v.hue_key(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -32,7 +32,6 @@ use crate::owner::Owner;
|
||||
use crate::pages;
|
||||
use crate::receipts::Receipts;
|
||||
use crate::scheme_menu::SchemeMenu;
|
||||
use crate::schemes;
|
||||
use crate::theme::{self, pal};
|
||||
use egui::{Align, CornerRadius, Frame, Key, Layout, Margin, RichText, Sense, Stroke, Ui, vec2};
|
||||
use egui_phosphor::regular as icon;
|
||||
@@ -203,20 +202,51 @@ impl CompanyView {
|
||||
pub fn title(&self) -> String {
|
||||
self.name()
|
||||
.or_else(|| self.book_id())
|
||||
.or_else(|| {
|
||||
let dir = self.data_dir.as_deref()?;
|
||||
// A demo's or a copy's folder is `books-data`: its parent
|
||||
// names it.
|
||||
let name = dir.file_name()?.to_str()?;
|
||||
let parent = dir.parent().and_then(|p| p.file_name()?.to_str());
|
||||
Some(match (name, parent) {
|
||||
("books-data", Some(p)) => p.to_string(),
|
||||
_ => name.to_string(),
|
||||
})
|
||||
})
|
||||
.or_else(|| self.folder_name())
|
||||
.unwrap_or_else(|| "Company".to_string())
|
||||
}
|
||||
|
||||
/// The books' folder's name: a demo's or a copy's folder is
|
||||
/// `books-data`, which its parent names.
|
||||
fn folder_name(&self) -> Option<String> {
|
||||
let dir = self.data_dir.as_deref()?;
|
||||
let name = dir.file_name()?.to_str()?;
|
||||
let parent = dir.parent().and_then(|p| p.file_name()?.to_str());
|
||||
Some(match (name, parent) {
|
||||
("books-data", Some(p)) => p.to_string(),
|
||||
_ => name.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
/// What this company's badge hue is chosen from: the id of its books
|
||||
/// (theme.rs `hue_of`), else the name of their folder, which is that
|
||||
/// id for books in a data root: a function of where the books are
|
||||
/// kept and never of the name they carry, so renaming a company
|
||||
/// leaves its colour.
|
||||
pub fn hue_key(&self) -> String {
|
||||
self.book_id()
|
||||
.or_else(|| self.folder_name())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The status card's heading: this company's badge and name.
|
||||
fn card_head(&self, ctx: &egui::Context) -> CardHead {
|
||||
CardHead {
|
||||
initial: self.initial(),
|
||||
title: self.title(),
|
||||
hue: theme::badge_hue(ctx, &self.hue_key()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The letter on this company's badge: its title's first, upper case.
|
||||
fn initial(&self) -> char {
|
||||
self.title()
|
||||
.chars()
|
||||
.next()
|
||||
.map(|c| c.to_uppercase().next().unwrap_or(c))
|
||||
.unwrap_or('W')
|
||||
}
|
||||
|
||||
/// The books as last loaded (tests).
|
||||
pub fn books(&self) -> Option<&Arc<Books>> {
|
||||
self.books.as_ref()
|
||||
@@ -592,6 +622,7 @@ impl CompanyView {
|
||||
}
|
||||
let p = pal(ui.ctx());
|
||||
let books = self.books.clone();
|
||||
let head = self.card_head(ui.ctx());
|
||||
egui::Panel::left("sidebar")
|
||||
.exact_size(224.0)
|
||||
.resizable(false)
|
||||
@@ -601,37 +632,7 @@ impl CompanyView {
|
||||
.inner_margin(Margin::symmetric(12, 16)),
|
||||
)
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let (r, _) = ui.allocate_exact_size(vec2(28.0, 28.0), Sense::hover());
|
||||
ui.painter().rect_filled(r, CornerRadius::same(8), p.accent);
|
||||
let initial = books
|
||||
.as_ref()
|
||||
.and_then(|b| b.company_name().chars().next())
|
||||
.unwrap_or('W');
|
||||
ui.painter().text(
|
||||
r.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
initial,
|
||||
theme::bold(15.0),
|
||||
schemes::on(p.accent),
|
||||
);
|
||||
ui.vertical(|ui| {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
let name = books
|
||||
.as_ref()
|
||||
.map(|b| b.company_name().to_string())
|
||||
.unwrap_or_else(|| "wanderbooks".into());
|
||||
ui.add(
|
||||
egui::Label::new(RichText::new(name).font(theme::semibold(13.5)))
|
||||
.truncate(),
|
||||
);
|
||||
ui.label(
|
||||
RichText::new("Books")
|
||||
.font(theme::regular(11.5))
|
||||
.color(p.muted),
|
||||
);
|
||||
});
|
||||
});
|
||||
top_slot(ui);
|
||||
let current = self.nav.current.section();
|
||||
let attention = books.as_ref().map(|b| b.attention.len()).unwrap_or(0);
|
||||
// Short windows give way in steps (Fit): the status card
|
||||
@@ -731,6 +732,7 @@ impl CompanyView {
|
||||
ui.input(|i| i.time) - self.updated_at,
|
||||
self.loader.is_some() || self.live_label,
|
||||
fit.folded,
|
||||
&head,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -742,6 +744,7 @@ impl CompanyView {
|
||||
fn rail(&mut self, ui: &mut Ui, schemes: &mut SchemeMenu) {
|
||||
let p = pal(ui.ctx());
|
||||
let books = self.books.clone();
|
||||
let head = self.card_head(ui.ctx());
|
||||
egui::Panel::left("rail")
|
||||
.exact_size(RAIL_W)
|
||||
.resizable(false)
|
||||
@@ -751,24 +754,7 @@ impl CompanyView {
|
||||
.inner_margin(Margin::symmetric(10, 16)),
|
||||
)
|
||||
.show(ui, |ui| {
|
||||
let name = books
|
||||
.as_ref()
|
||||
.map(|b| b.company_name().to_string())
|
||||
.unwrap_or_else(|| "wanderbooks".into());
|
||||
let (r, _) =
|
||||
ui.allocate_exact_size(vec2(ui.available_width(), 28.0), Sense::hover());
|
||||
let logo = egui::Rect::from_center_size(r.center(), vec2(28.0, 28.0));
|
||||
ui.painter()
|
||||
.rect_filled(logo, CornerRadius::same(8), p.accent);
|
||||
ui.painter().text(
|
||||
logo.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
name.chars().next().unwrap_or('W'),
|
||||
theme::bold(15.0),
|
||||
schemes::on(p.accent),
|
||||
);
|
||||
ui.interact(r, ui.id().with("logo"), Sense::hover())
|
||||
.on_hover_text(format!("{name} · Books"));
|
||||
top_slot(ui);
|
||||
let current = self.nav.current.section();
|
||||
let attention = books.as_ref().map(|b| b.attention.len()).unwrap_or(0);
|
||||
// As the sidebar's, with no card to fold.
|
||||
@@ -873,6 +859,13 @@ impl CompanyView {
|
||||
));
|
||||
}
|
||||
resp.on_hover_text(tip);
|
||||
// The company, above its status (the footer is laid
|
||||
// out bottom up): its badge alone, its name on hover.
|
||||
ui.add_space(2.0);
|
||||
let (r, resp) =
|
||||
ui.allocate_exact_size(vec2(RAIL_BADGE, RAIL_BADGE), Sense::hover());
|
||||
head.paint(ui, r, 6);
|
||||
resp.on_hover_text(&head.title);
|
||||
}
|
||||
});
|
||||
memo.measured(ui, "rail", fit.form(), footer.response.rect);
|
||||
@@ -1158,8 +1151,8 @@ const RAIL_W: f32 = 60.0;
|
||||
/// The footer's height (the status box and the menus under the sidebar's
|
||||
/// links; the rail's equivalent) before it is first measured. After the
|
||||
/// first frame its drawn heights are used ([`FooterMemo`]).
|
||||
const SIDEBAR_FOOTER: f32 = 172.0;
|
||||
const RAIL_FOOTER: f32 = 84.0;
|
||||
const SIDEBAR_FOOTER: f32 = 192.0;
|
||||
const RAIL_FOOTER: f32 = 112.0;
|
||||
/// How much shorter the footer is tightened ([`tighten`]), before it is
|
||||
/// measured so.
|
||||
const SIDEBAR_TIGHTEN: f32 = 36.0;
|
||||
@@ -1168,9 +1161,12 @@ const RAIL_TIGHTEN: f32 = 36.0;
|
||||
/// Space kept between the last link and the footer.
|
||||
const FOOTER_GAP: f32 = 8.0;
|
||||
|
||||
/// Tightened: the space between links, and under the header.
|
||||
/// Tightened: the space between links, and under the top slot. The slot
|
||||
/// draws nothing (`top_slot`), and the panel's margin is the first link's
|
||||
/// room under the tab bar, so both gaps are nothing today.
|
||||
const GAP_MIN: f32 = 2.0;
|
||||
const HEAD_GAP_TIGHT: f32 = 8.0;
|
||||
const HEAD_GAP: f32 = 0.0;
|
||||
const HEAD_GAP_TIGHT: f32 = 0.0;
|
||||
|
||||
/// A panel's links: how many, their height and spacing, the least height
|
||||
/// they tighten to, the gap above them, and whether its status card folds.
|
||||
@@ -1197,7 +1193,7 @@ const SIDEBAR_ROWS: Rows = Rows {
|
||||
// 22, not 24, since Invoices & Bills made 13 links (2026-10-24): so
|
||||
// they still fit the owner's 1479x519 window unscrolled.
|
||||
row_min: 22.0,
|
||||
head_gap: 18.0,
|
||||
head_gap: HEAD_GAP,
|
||||
foldable: true,
|
||||
};
|
||||
|
||||
@@ -1208,7 +1204,7 @@ const RAIL_ROWS: Rows = Rows {
|
||||
// As low as the sidebar's: at 28 the rail scrolled in the owner's
|
||||
// window (review, 2026-10-22), and at 24 once there were 13 links.
|
||||
row_min: 22.0,
|
||||
head_gap: 18.0,
|
||||
head_gap: HEAD_GAP,
|
||||
foldable: false,
|
||||
};
|
||||
|
||||
@@ -1530,12 +1526,58 @@ fn footer_layout<R>(
|
||||
}
|
||||
}
|
||||
|
||||
/// The top of the sidebar (and of the rail): where the assistant's
|
||||
/// connection state goes, in a later unit. It draws nothing today, so the
|
||||
/// links begin at the panel's top margin, under the tab bar. A block put
|
||||
/// here adds its own height and gap below it ([`HEAD_GAP`],
|
||||
/// [`HEAD_GAP_TIGHT`] are what the fit leaves under it).
|
||||
fn top_slot(_ui: &mut Ui) {}
|
||||
|
||||
/// What the status card says of its company: the heading row's badge
|
||||
/// (its hue, its letter) and name.
|
||||
struct CardHead {
|
||||
initial: char,
|
||||
title: String,
|
||||
hue: egui::Color32,
|
||||
}
|
||||
|
||||
/// The status card's badge, and the rail's.
|
||||
const CARD_BADGE: f32 = 16.0;
|
||||
const RAIL_BADGE: f32 = 24.0;
|
||||
|
||||
impl CardHead {
|
||||
fn paint(&self, ui: &Ui, rect: egui::Rect, radius: u8) {
|
||||
let font = theme::bold(if rect.width() > 20.0 { 13.0 } else { 10.0 });
|
||||
theme::paint_badge(ui.painter(), rect, radius, self.initial, self.hue, font);
|
||||
}
|
||||
|
||||
/// The card's heading row: the badge, small, and the name, cut with
|
||||
/// an ellipsis to the card's width.
|
||||
fn row(&self, ui: &mut Ui) -> egui::Response {
|
||||
ui.horizontal(|ui| {
|
||||
let (r, _) = ui.allocate_exact_size(vec2(CARD_BADGE, CARD_BADGE), Sense::hover());
|
||||
self.paint(ui, r, 4);
|
||||
ui.add(
|
||||
egui::Label::new(RichText::new(&self.title).font(theme::semibold(12.5))).truncate(),
|
||||
)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
}
|
||||
|
||||
/// The status card: whether the books are live, their newest event, and
|
||||
/// the integrity checks. Folded (a short window), one line, the checks
|
||||
/// in its tooltip.
|
||||
fn live_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool, folded: bool) {
|
||||
fn live_status(
|
||||
ui: &mut Ui,
|
||||
b: &Books,
|
||||
since_update: f64,
|
||||
live: bool,
|
||||
folded: bool,
|
||||
head: &CardHead,
|
||||
) {
|
||||
if folded {
|
||||
return folded_status(ui, b, since_update, live);
|
||||
return folded_status(ui, b, since_update, live, head);
|
||||
}
|
||||
let p = pal(ui.ctx());
|
||||
Frame::new()
|
||||
@@ -1584,6 +1626,9 @@ fn live_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool, folded: bo
|
||||
});
|
||||
}
|
||||
}
|
||||
// The footer is laid out bottom up, so what is added last is
|
||||
// the card's top: the heading, over what the card always said.
|
||||
head.row(ui).on_hover_text(&head.title);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1593,7 +1638,7 @@ fn live_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool, folded: bo
|
||||
/// of [`summaries`] that fits the card, so it is never cut off: a failed
|
||||
/// check's name outranks the event and the word "Live" (review,
|
||||
/// 2026-10-22: cut to "⊘ Datab…" it hid what failed).
|
||||
fn folded_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool) {
|
||||
fn folded_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool, head: &CardHead) {
|
||||
let p = pal(ui.ctx());
|
||||
let checks = checks(b);
|
||||
let failed: Vec<&str> = checks
|
||||
@@ -1658,6 +1703,10 @@ fn folded_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool) {
|
||||
.color(color),
|
||||
);
|
||||
});
|
||||
// Bottom up, so last is the top: the heading. Its hover is the
|
||||
// card's (below): the card is one target, whose tooltip begins
|
||||
// with the name.
|
||||
head.row(ui);
|
||||
});
|
||||
let resp = ui.interact(
|
||||
card.response.rect,
|
||||
@@ -1665,6 +1714,7 @@ fn folded_status(ui: &mut Ui, b: &Books, since_update: f64, live: bool) {
|
||||
Sense::click(),
|
||||
);
|
||||
resp.on_hover_ui(|ui| {
|
||||
ui.label(RichText::new(&head.title).font(theme::semibold(12.0)));
|
||||
if !(line.status && line.event) {
|
||||
ui.label(
|
||||
RichText::new(format!("{status} {event}"))
|
||||
|
||||
@@ -20,7 +20,7 @@ use rust_decimal::Decimal;
|
||||
pub fn show(ui: &mut Ui, b: &Books, shell: &mut Shell<'_>) {
|
||||
page(ui, "overview", |ui| {
|
||||
let k = &b.kpis;
|
||||
widgets::page_header(ui, b.company_name(), &headline(b));
|
||||
widgets::page_lead(ui, &headline(b));
|
||||
kpis(ui, b, shell);
|
||||
let _ = k;
|
||||
// What needs doing gets the page's full width, under the numbers:
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
//! width.
|
||||
//!
|
||||
//! The bar spans the whole window, above the sidebar: a tab is the top
|
||||
//! level, and the sidebar (its company badge, its pages, its status) is
|
||||
//! the company in the tab's, which the layout shows. With no company open
|
||||
//! level, and the sidebar (its pages, its status card) is the company in
|
||||
//! the tab's, which the layout shows. The tab is the company's identity
|
||||
//! in the frame (badge and name); nothing else at the top of the window
|
||||
//! repeats it, and the status card at the foot of the sidebar names it
|
||||
//! again, in the same hue. With no company open
|
||||
//! it is the window's top all the same. The "+" follows the last tab, and
|
||||
//! stays at the right edge, whole, while the tabs scroll.
|
||||
//!
|
||||
@@ -22,8 +25,8 @@
|
||||
//! company is reachable exactly while it has a tab).
|
||||
//! INVARIANTS:
|
||||
//! 1. One tab per open company, in the order opened, showing the
|
||||
//! company's badge (as the sidebar's header draws it, small) and
|
||||
//! name (the name last known, else the id of its books, until it is
|
||||
//! company's badge (its hue, from the id of its books: theme.rs
|
||||
//! `hue_of`; the status card draws the same) and name (the name last known, else the id of its books, until it is
|
||||
//! read). The bar is there with one company open, and with none.
|
||||
//! 2. The tab shown is marked by more than colour: a heavier name, a
|
||||
//! bar in the accent colour along its top edge, and "selected" to
|
||||
@@ -86,6 +89,15 @@ pub struct Tab {
|
||||
pub title: String,
|
||||
/// More about it, on hover.
|
||||
pub detail: String,
|
||||
/// What its badge's hue is chosen from: the id of its books
|
||||
/// ([`hue_of`]).
|
||||
pub hue_key: String,
|
||||
}
|
||||
|
||||
/// The badge hue of the company whose books have id `book_id`, light or
|
||||
/// dark: the one its tab and its status card both draw (theme.rs).
|
||||
pub fn hue_of(book_id: &str, dark: bool) -> egui::Color32 {
|
||||
theme::hue_of(book_id, dark)
|
||||
}
|
||||
|
||||
/// A company of the data root that is not open, as "+" lists it.
|
||||
@@ -455,24 +467,24 @@ fn one_tab(
|
||||
} else if resp.hovered() || close.hovered() {
|
||||
painter.rect_filled(rect.shrink2(vec2(0.0, 2.0)), CornerRadius::same(8), p.hover);
|
||||
}
|
||||
// The badge, as the sidebar's header draws it.
|
||||
// The badge: the company's hue, as its status card draws it.
|
||||
let badge = egui::Rect::from_center_size(
|
||||
egui::pos2(rect.left() + PAD_L + BADGE / 2.0, rect.center().y + 1.0),
|
||||
vec2(BADGE, BADGE),
|
||||
);
|
||||
painter.rect_filled(badge, CornerRadius::same(5), p.accent);
|
||||
let initial = tab
|
||||
.title
|
||||
.chars()
|
||||
.next()
|
||||
.map(|c| c.to_uppercase().next().unwrap_or(c))
|
||||
.unwrap_or('W');
|
||||
painter.text(
|
||||
badge.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
theme::paint_badge(
|
||||
painter,
|
||||
badge,
|
||||
5,
|
||||
initial,
|
||||
theme::badge_hue(ui.ctx(), &tab.hue_key),
|
||||
theme::bold(11.0),
|
||||
crate::schemes::on(p.accent),
|
||||
);
|
||||
let font = if here {
|
||||
theme::semibold(13.0)
|
||||
|
||||
@@ -90,6 +90,106 @@ pub const DARK: Palette = Palette {
|
||||
],
|
||||
};
|
||||
|
||||
/// The company badges' hues, light and dark: one per company, chosen by
|
||||
/// [`hue_of`] from the id of its books. Each is dark enough (light) or
|
||||
/// bright enough (dark) that its letter (black or white, whichever reads
|
||||
/// better) has 4.5:1 on it and it has 3:1 on every surface a badge sits
|
||||
/// on, in the viewer's own two themes (the test below).
|
||||
pub const BADGE_HUES: [(Color32, Color32); 8] = [
|
||||
// indigo
|
||||
(
|
||||
Color32::from_rgb(0x4F, 0x46, 0xE5),
|
||||
Color32::from_rgb(0x8B, 0x93, 0xFA),
|
||||
),
|
||||
// teal
|
||||
(
|
||||
Color32::from_rgb(0x0F, 0x76, 0x6E),
|
||||
Color32::from_rgb(0x2D, 0xD4, 0xBF),
|
||||
),
|
||||
// orange
|
||||
(
|
||||
Color32::from_rgb(0xB4, 0x53, 0x09),
|
||||
Color32::from_rgb(0xFB, 0xBF, 0x24),
|
||||
),
|
||||
// rose
|
||||
(
|
||||
Color32::from_rgb(0xBE, 0x18, 0x5D),
|
||||
Color32::from_rgb(0xF4, 0x72, 0xB6),
|
||||
),
|
||||
// blue
|
||||
(
|
||||
Color32::from_rgb(0x1D, 0x4E, 0xD8),
|
||||
Color32::from_rgb(0x60, 0xA5, 0xFA),
|
||||
),
|
||||
// green
|
||||
(
|
||||
Color32::from_rgb(0x15, 0x80, 0x3D),
|
||||
Color32::from_rgb(0x4A, 0xDE, 0x80),
|
||||
),
|
||||
// violet
|
||||
(
|
||||
Color32::from_rgb(0x7E, 0x22, 0xCE),
|
||||
Color32::from_rgb(0xC0, 0x84, 0xFC),
|
||||
),
|
||||
// slate
|
||||
(
|
||||
Color32::from_rgb(0x47, 0x55, 0x69),
|
||||
Color32::from_rgb(0x94, 0xA3, 0xB8),
|
||||
),
|
||||
];
|
||||
|
||||
/// Which hue a company has: FNV-1a over the bytes of the id of its books,
|
||||
/// modulo the number of hues. A function of the id alone (no seed, no
|
||||
/// machine, no order of opening), so a company keeps its hue for ever and
|
||||
/// on every machine; it is never changed without a new decision.
|
||||
pub fn hue_index(book_id: &str) -> usize {
|
||||
let mut h: u64 = 0xcbf2_9ce4_8422_2325;
|
||||
for b in book_id.bytes() {
|
||||
h ^= u64::from(b);
|
||||
h = h.wrapping_mul(0x100_0000_01b3);
|
||||
}
|
||||
(h % BADGE_HUES.len() as u64) as usize
|
||||
}
|
||||
|
||||
/// The badge hue of the company whose books have id `book_id`, in the
|
||||
/// light or dark table.
|
||||
pub fn hue_of(book_id: &str, dark: bool) -> Color32 {
|
||||
let (light, night) = BADGE_HUES[hue_index(book_id)];
|
||||
if dark { night } else { light }
|
||||
}
|
||||
|
||||
/// Whether the palette in force is a dark one (its page is darker than
|
||||
/// its text).
|
||||
fn is_dark(p: &Palette) -> bool {
|
||||
crate::schemes::luminance(p.bg) < crate::schemes::luminance(p.text)
|
||||
}
|
||||
|
||||
/// The badge hue of a company, for the palette in force.
|
||||
pub fn badge_hue(ctx: &Context, book_id: &str) -> Color32 {
|
||||
hue_of(book_id, is_dark(&pal(ctx)))
|
||||
}
|
||||
|
||||
/// A company's badge: a rounded square in its hue with its initial in it
|
||||
/// (black or white, whichever reads), drawn by the tab and the status
|
||||
/// card alike.
|
||||
pub fn paint_badge(
|
||||
painter: &egui::Painter,
|
||||
rect: egui::Rect,
|
||||
radius: u8,
|
||||
initial: char,
|
||||
hue: Color32,
|
||||
font: FontId,
|
||||
) {
|
||||
painter.rect_filled(rect, CornerRadius::same(radius), hue);
|
||||
painter.text(
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
initial,
|
||||
font,
|
||||
crate::schemes::on(hue),
|
||||
);
|
||||
}
|
||||
|
||||
/// Where the palette in force is kept, in the context's memory.
|
||||
fn palette_id() -> egui::Id {
|
||||
egui::Id::new("wanderbooks-palette")
|
||||
@@ -317,6 +417,43 @@ pub fn apply_scheme(ctx: &Context, scheme: &crate::schemes::Scheme) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// WCAG AA for each badge hue in both themes: its letter 4.5:1 on
|
||||
/// it, and 3:1 for the badge against every surface it is drawn on.
|
||||
#[test]
|
||||
fn every_badge_hue_reads_in_both_themes() {
|
||||
use crate::schemes::{contrast, on};
|
||||
for (name, p, pick) in [("light", &LIGHT, 0), ("dark", &DARK, 1)] {
|
||||
for (i, hues) in BADGE_HUES.iter().enumerate() {
|
||||
let hue = if pick == 0 { hues.0 } else { hues.1 };
|
||||
let letter = contrast(on(hue), hue);
|
||||
assert!(
|
||||
letter >= 4.5,
|
||||
"{name} hue {i} {hue:?}: letter {letter:.2}:1"
|
||||
);
|
||||
// The tab's (in front, behind, hovered) and the card's.
|
||||
for (what, ground) in [
|
||||
("surface", p.surface),
|
||||
("sidebar", p.sidebar),
|
||||
("page", p.bg),
|
||||
("hover", p.hover),
|
||||
] {
|
||||
let r = contrast(hue, ground);
|
||||
assert!(r >= 3.0, "{name} hue {i} {hue:?} on {what}: {r:.2}:1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hue_is_a_function_of_the_book_id_alone() {
|
||||
// Pinned: a change here recolours every company.
|
||||
assert_eq!(hue_index("alpha"), hue_index("alpha"));
|
||||
assert_eq!(hue_index(""), 0xcbf2_9ce4_8422_2325_u64 as usize % 8);
|
||||
let all: std::collections::HashSet<usize> =
|
||||
(0..200).map(|n| hue_index(&format!("books-{n}"))).collect();
|
||||
assert_eq!(all.len(), BADGE_HUES.len(), "every hue is used");
|
||||
}
|
||||
|
||||
/// font_definitions: every family ends with the PDFs' Noto fallbacks,
|
||||
/// in their order, after its own face, the icons and the symbol fonts,
|
||||
/// each Noto font the very bytes ledger-import bundles (the same
|
||||
|
||||
@@ -61,6 +61,19 @@ pub fn page_header(ui: &mut Ui, title: &str, subtitle: &str) {
|
||||
ui.add_space(16.0);
|
||||
}
|
||||
|
||||
/// A page that opens with a sentence instead of a title (the Overview:
|
||||
/// the company's name is the tab's, and the status card's, not the
|
||||
/// page's): the sentence at the theme's heading size and weight, the
|
||||
/// first thing on the page.
|
||||
pub fn page_lead(ui: &mut Ui, sentence: &str) {
|
||||
let w = ui.available_width().min(860.0);
|
||||
ui.allocate_ui(vec2(w, 0.0), |ui| {
|
||||
ui.set_max_width(w);
|
||||
ui.label(RichText::new(sentence).font(theme::semibold(20.0)));
|
||||
});
|
||||
ui.add_space(16.0);
|
||||
}
|
||||
|
||||
/// A rounded tag.
|
||||
pub fn pill(ui: &mut Ui, text: &str, fg: Color32, bg: Color32) -> Response {
|
||||
Frame::new()
|
||||
|
||||
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 44 KiB |
@@ -1 +1 @@
|
||||
fb22421d46ed2f8b
|
||||
58e68b1eeb0e1329
|
||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 57 KiB |
@@ -34,6 +34,17 @@
|
||||
//! 10. A company's name is remembered when it is loaded: the "+" list
|
||||
//! shows it (the id alone for a company never opened), and so does a
|
||||
//! tab whose books are not loaded yet.
|
||||
//! 11. The tab is the company's identity in the frame: nothing else in
|
||||
//! the top 120 points of the window shows its name, and the
|
||||
//! Overview opens with its summary sentence, not a heading with the
|
||||
//! name.
|
||||
//! 12. The status card at the foot of the sidebar names the company in
|
||||
//! front, with its badge, and follows the tab; the rail shows the
|
||||
//! badge alone.
|
||||
//! 13. A company's badge hue is a function of the id of its books alone
|
||||
//! (so it is the same on its tab and its card, in both themes, after
|
||||
//! a restart, in any order of opening), and every hue reads (the
|
||||
//! contrast test is `theme::tests`, in the crate).
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
@@ -1348,8 +1359,329 @@ fn the_empty_window_and_the_plus_list() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pictures of the whole window with two tabs, each in front once, the
|
||||
/// "+" list open and the empty window, for a person to look at
|
||||
// ---- 11-13: the company's name and hue --------------------------------------
|
||||
|
||||
/// Every text the last frame painted, with where it starts.
|
||||
fn placed(h: &Harness<'_, App>) -> Vec<(egui::Pos2, String)> {
|
||||
fn walk(s: &egui::Shape, out: &mut Vec<(egui::Pos2, String)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => out.push((t.pos, t.galley.text().to_string())),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut all = Vec::new();
|
||||
for c in &h.output().shapes {
|
||||
walk(&c.shape, &mut all);
|
||||
}
|
||||
all
|
||||
}
|
||||
|
||||
/// Every rectangle of exactly colour `color` the last frame painted.
|
||||
fn fills(h: &Harness<'_, App>, color: egui::Color32) -> Vec<egui::Rect> {
|
||||
fn walk(s: &egui::Shape, color: egui::Color32, out: &mut Vec<egui::Rect>) {
|
||||
match s {
|
||||
egui::Shape::Rect(r) if r.fill == color => out.push(r.rect),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, color, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut all = Vec::new();
|
||||
for c in &h.output().shapes {
|
||||
walk(&c.shape, color, &mut all);
|
||||
}
|
||||
all
|
||||
}
|
||||
|
||||
/// The sidebar's column below the bar.
|
||||
fn in_sidebar(r: egui::Rect) -> bool {
|
||||
r.max.x <= 224.5 && r.min.y >= ledger_gui::tabs::BAR_H
|
||||
}
|
||||
|
||||
/// The hue ids of the books give: the light or dark one.
|
||||
fn hue(id: &str, dark: bool) -> egui::Color32 {
|
||||
ledger_gui::tabs::hue_of(id, dark)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_in_the_top_of_the_window_but_the_tab_shows_the_company_name() {
|
||||
use ledger_gui::tabs::BAR_H;
|
||||
for dark in [false, true] {
|
||||
for route in [Route::Overview, Route::Cash, Route::Journal] {
|
||||
let w = World::new();
|
||||
let mut h = shown(
|
||||
&w,
|
||||
&["Wanderland Labs LLC", "Fernhill Studio"],
|
||||
dark,
|
||||
egui::vec2(1280.0, 700.0),
|
||||
);
|
||||
h.state_mut().goto(route.clone());
|
||||
h.run_steps(4);
|
||||
let tag = format!("{route:?}, dark {dark}");
|
||||
for name in ["Wanderland Labs LLC", "Fernhill Studio"] {
|
||||
// Painted text: in the top 120 points it is only the tab's.
|
||||
for (at, text) in placed(&h) {
|
||||
if text.contains(name) && at.y < 120.0 {
|
||||
assert!(
|
||||
at.y < BAR_H,
|
||||
"{tag}: {name} is painted at {at:?} below the bar: {text:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
// The tree: only the tab and its close control, both in the bar.
|
||||
for n in h.query_all_by_label_contains(name) {
|
||||
let r = n.rect();
|
||||
if r.top() < 120.0 {
|
||||
assert!(
|
||||
r.bottom() <= BAR_H + 0.5,
|
||||
"{tag}: a widget named {name} at {r:?} is under the bar"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// And the one in front is named once more, lower: the card.
|
||||
let card = placed(&h)
|
||||
.into_iter()
|
||||
.filter(|(at, t)| at.x < 224.0 && at.y > 120.0 && t == "Wanderland Labs LLC")
|
||||
.count();
|
||||
assert_eq!(card, 1, "{tag}: the status card names the company");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_status_card_shows_the_company_in_front_and_follows_the_tab() {
|
||||
for dark in [false, true] {
|
||||
let (w, _, _, _) = three();
|
||||
let mode = if dark { "true" } else { "false" };
|
||||
let mut h = start(
|
||||
&w,
|
||||
prefs(&[("open_companies", "alpha,beta"), ("dark", mode)]),
|
||||
egui::vec2(1280.0, 900.0),
|
||||
);
|
||||
loaded(&mut h);
|
||||
let card_names = |h: &Harness<'_, App>| -> Vec<String> {
|
||||
placed(h)
|
||||
.into_iter()
|
||||
.filter(|(at, t)| at.x < 224.0 && at.y > 120.0 && t.ends_with(" Co"))
|
||||
.map(|(_, t)| t)
|
||||
.collect()
|
||||
};
|
||||
// The card's badge: its hue, a small square in the sidebar, near
|
||||
// the foot (the tab's is in the bar).
|
||||
let card_badge = |h: &Harness<'_, App>, id: &str| {
|
||||
fills(h, hue(id, dark))
|
||||
.into_iter()
|
||||
.filter(|r| in_sidebar(*r) && r.min.y > 120.0)
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
assert_eq!(card_names(&h), ["Alpha Co"], "dark {dark}");
|
||||
assert_eq!(
|
||||
card_badge(&h, "alpha").len(),
|
||||
1,
|
||||
"alpha's badge on its card"
|
||||
);
|
||||
assert!(
|
||||
card_badge(&h, "beta").is_empty(),
|
||||
"beta's hue isn't on alpha's card"
|
||||
);
|
||||
// The badge is small, and carries the initial.
|
||||
let r = card_badge(&h, "alpha")[0];
|
||||
assert!(r.width() <= 20.0 && r.height() <= 20.0, "{r:?}");
|
||||
assert!(
|
||||
placed(&h)
|
||||
.iter()
|
||||
.any(|(at, t)| t == "A" && r.contains(*at + egui::vec2(4.0, 4.0))
|
||||
|| t == "A" && r.expand(4.0).contains(*at)),
|
||||
"the initial is on the badge"
|
||||
);
|
||||
show_tab(&mut h, "Beta Co");
|
||||
assert_eq!(card_names(&h), ["Beta Co"], "dark {dark}");
|
||||
assert_eq!(card_badge(&h, "beta").len(), 1, "beta's badge on its card");
|
||||
assert!(
|
||||
card_badge(&h, "alpha").is_empty(),
|
||||
"alpha's hue left the card"
|
||||
);
|
||||
// The window's title still names the company.
|
||||
assert_eq!(h.state().window_title(), "Beta Co · wanderbooks");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_rail_shows_the_badge_alone_with_the_name_on_hover() {
|
||||
let (w, _, _, _) = three();
|
||||
let mut h = start(
|
||||
&w,
|
||||
prefs(&[("open_companies", "alpha,beta"), ("dark", "false")]),
|
||||
egui::vec2(900.0, 700.0),
|
||||
);
|
||||
loaded(&mut h);
|
||||
let badge: Vec<_> = fills(&h, hue("alpha", false))
|
||||
.into_iter()
|
||||
.filter(|r| in_sidebar(*r) && r.max.x <= 60.5)
|
||||
.collect();
|
||||
assert_eq!(badge.len(), 1, "alpha's badge in the rail");
|
||||
assert!(
|
||||
!placed(&h)
|
||||
.iter()
|
||||
.any(|(at, t)| at.x < 60.0 && at.y > 36.0 && t.contains("Alpha Co")),
|
||||
"the rail has no room for the name"
|
||||
);
|
||||
h.hover_at(badge[0].center());
|
||||
h.run_steps(30);
|
||||
assert!(shows(&h, "Alpha Co"), "the name is on hover");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hue_is_the_books_id_alone_on_the_tab_and_the_card_in_both_themes_and_after_a_restart() {
|
||||
let (w, _, _, _) = three();
|
||||
for dark in [false, true] {
|
||||
let mode = if dark { "true" } else { "false" };
|
||||
let size = egui::vec2(1280.0, 900.0);
|
||||
// Two starts, the tabs opened in different orders: a restart, and
|
||||
// an order of opening, change nothing.
|
||||
let mut seen = Vec::new();
|
||||
for order in ["alpha,beta,gamma", "gamma,alpha,beta"] {
|
||||
let mut h = start(
|
||||
&w,
|
||||
prefs(&[("open_companies", order), ("dark", mode)]),
|
||||
size,
|
||||
);
|
||||
loaded(&mut h);
|
||||
for id in ["alpha", "beta", "gamma"] {
|
||||
let name = format!("{} Co", id[..1].to_uppercase() + &id[1..]);
|
||||
show_tab(&mut h, &name);
|
||||
let want = hue(id, dark);
|
||||
let tab: Vec<_> = fills(&h, want)
|
||||
.into_iter()
|
||||
.filter(|r| r.max.y <= ledger_gui::tabs::BAR_H)
|
||||
.collect();
|
||||
let card: Vec<_> = fills(&h, want)
|
||||
.into_iter()
|
||||
.filter(|r| in_sidebar(*r))
|
||||
.collect();
|
||||
assert_eq!(tab.len(), 1, "{id} dark {dark}: its tab's badge in its hue");
|
||||
assert_eq!(
|
||||
card.len(),
|
||||
1,
|
||||
"{id} dark {dark}: its card's badge in its hue"
|
||||
);
|
||||
seen.push((id, dark, want));
|
||||
}
|
||||
}
|
||||
// The same in both starts.
|
||||
let (first, second) = seen.split_at(3);
|
||||
let mut a = first.to_vec();
|
||||
let mut b = second.to_vec();
|
||||
a.sort_by_key(|x| x.0);
|
||||
b.sort_by_key(|x| x.0);
|
||||
assert_eq!(a, b);
|
||||
}
|
||||
// Pinned, with the rule: it never changes without a decision, and
|
||||
// is a function of the id alone (not the name, nor the machine).
|
||||
assert_eq!(
|
||||
hue("alpha", false),
|
||||
egui::Color32::from_rgb(0xBE, 0x18, 0x5D)
|
||||
);
|
||||
assert_eq!(
|
||||
hue("alpha", true),
|
||||
egui::Color32::from_rgb(0xF4, 0x72, 0xB6)
|
||||
);
|
||||
assert_eq!(
|
||||
hue("beta", false),
|
||||
egui::Color32::from_rgb(0x47, 0x55, 0x69)
|
||||
);
|
||||
assert_eq!(
|
||||
hue("gamma", false),
|
||||
egui::Color32::from_rgb(0xB4, 0x53, 0x09)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_overview_opens_with_its_summary_sentence_and_never_names_the_company() {
|
||||
for dark in [false, true] {
|
||||
let w = World::new();
|
||||
let mut h = shown(&w, &["Alpha Co"], dark, egui::vec2(1280.0, 800.0));
|
||||
h.run_steps(3);
|
||||
// The page's first text: the first under the company's top bar
|
||||
// (52 high, under the tab bar).
|
||||
let page_top = ledger_gui::tabs::BAR_H + 52.0;
|
||||
let mut page: Vec<(egui::Pos2, String)> = placed(&h)
|
||||
.into_iter()
|
||||
.filter(|(at, _)| at.x >= 224.0 && at.y >= page_top)
|
||||
.collect();
|
||||
page.sort_by(|a, b| a.0.y.total_cmp(&b.0.y).then(a.0.x.total_cmp(&b.0.x)));
|
||||
let (_, first) = page.first().expect("the page has text");
|
||||
assert!(
|
||||
first.starts_with("You have $8,765.44 in cash and owe $0.00."),
|
||||
"dark {dark}: the page opens with {first:?}"
|
||||
);
|
||||
// Nothing on the page says the company's name: no sentence there
|
||||
// used it.
|
||||
assert!(
|
||||
page.iter().all(|(_, t)| !t.contains("Alpha Co")),
|
||||
"dark {dark}: {:?}",
|
||||
page.iter()
|
||||
.filter(|(_, t)| t.contains("Alpha Co"))
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
// It reads as the page's opening line: bigger than body text,
|
||||
// smaller than a page's title (26).
|
||||
let lead = h
|
||||
.output()
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|c| match &c.shape {
|
||||
egui::Shape::Text(t) if t.galley.text().starts_with("You have") => {
|
||||
Some(t.galley.rows[0].height())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("the lead");
|
||||
let body = 14.0 * 1.2;
|
||||
assert!(lead > body * 1.2 && lead < 26.0 * 1.2, "lead row {lead}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_overview_of_books_with_no_transactions_opens_the_same_way() {
|
||||
let w = World::new();
|
||||
let id = "empty-co";
|
||||
let root = Root::find(Some(&w.root)).unwrap();
|
||||
let mut s = root
|
||||
.create_book(&BookId::parse(id).unwrap(), Currency::USD)
|
||||
.unwrap();
|
||||
s.add_account("1000", "Cash", AccountType::Asset, None, false)
|
||||
.unwrap();
|
||||
drop(s);
|
||||
let source = w.source(id);
|
||||
let mut h = Harness::builder()
|
||||
.with_size(egui::vec2(1280.0, 800.0))
|
||||
.build_eframe(move |cc| {
|
||||
App::with_books(
|
||||
&cc.egui_ctx,
|
||||
data::load_once(&source).unwrap(),
|
||||
false,
|
||||
Route::Overview,
|
||||
)
|
||||
});
|
||||
h.run_steps(4);
|
||||
let page_top = ledger_gui::tabs::BAR_H + 52.0;
|
||||
let mut page: Vec<_> = placed(&h)
|
||||
.into_iter()
|
||||
.filter(|(at, _)| at.x >= 224.0 && at.y >= page_top)
|
||||
.collect();
|
||||
page.sort_by(|a, b| a.0.y.total_cmp(&b.0.y));
|
||||
assert!(
|
||||
page[0].1.starts_with("No transactions yet."),
|
||||
"opens with {:?}",
|
||||
page[0].1
|
||||
);
|
||||
}
|
||||
|
||||
/// Pictures of the whole window: one company, two tabs each in front once,
|
||||
/// eight tabs, the "+" list open, the empty window, the rail, the
|
||||
/// smallest window and the Overview at its top, for a person to look at
|
||||
/// (`SHOT_DIR=… cargo test -p ledger-gui --test tabs -- --ignored pictures`).
|
||||
#[test]
|
||||
#[ignore]
|
||||
@@ -1364,7 +1696,41 @@ fn pictures() {
|
||||
};
|
||||
for dark in [false, true] {
|
||||
let mode = if dark { "dark" } else { "light" };
|
||||
// One company open.
|
||||
let (w, _, _, _) = three();
|
||||
let mut h = start(
|
||||
&w,
|
||||
prefs(&[
|
||||
("open_companies", "alpha"),
|
||||
("dark", if dark { "true" } else { "false" }),
|
||||
]),
|
||||
egui::vec2(1440.0, 920.0),
|
||||
);
|
||||
loaded(&mut h);
|
||||
save(&mut h, &format!("one-company-{mode}"));
|
||||
// The Overview scrolled down and back to its top.
|
||||
h.hover_at(egui::pos2(900.0, 500.0));
|
||||
for dy in [-400.0, 800.0] {
|
||||
h.event(egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
delta: egui::vec2(0.0, dy),
|
||||
phase: egui::TouchPhase::Move,
|
||||
modifiers: egui::Modifiers::NONE,
|
||||
});
|
||||
h.run_steps(6);
|
||||
}
|
||||
save(&mut h, &format!("overview-scrolled-to-top-{mode}"));
|
||||
// The sidebar collapsed to its rail, two companies open.
|
||||
let mut h = start(
|
||||
&w,
|
||||
prefs(&[
|
||||
("open_companies", "alpha,beta"),
|
||||
("dark", if dark { "true" } else { "false" }),
|
||||
]),
|
||||
egui::vec2(900.0, 700.0),
|
||||
);
|
||||
loaded(&mut h);
|
||||
save(&mut h, &format!("rail-two-companies-{mode}"));
|
||||
let mut h = start(
|
||||
&w,
|
||||
prefs(&[
|
||||
|
||||
@@ -122,8 +122,22 @@ The viewer is **one window with a tab per open company** (P15, D-78;
|
||||
the data root the companies are in) and a list of `CompanyView`s
|
||||
(`company.rs`), one per open company, with which is in front. The tab
|
||||
bar runs across the whole window, above the sidebar: a tab is the top
|
||||
level, and the sidebar (the company's badge, its pages, its status) is the
|
||||
company in the tab's. The bar's height (`tabs::BAR_H`) is taken from the
|
||||
level, and the sidebar (its pages, its status card) is the company in the
|
||||
tab's. The tab is the company's identity in the frame (its badge and
|
||||
name), and nothing else at the top of the window repeats it: the sidebar
|
||||
has no header, its first link sits under the bar (`top_slot` in
|
||||
`company.rs` is the empty place at the top of the sidebar and of the rail,
|
||||
where the assistant's connection state is drawn later), and the Overview
|
||||
opens with its summary sentence, not a heading with the name. The company
|
||||
is named once more, at the opposite corner: the status card at the foot of
|
||||
the sidebar begins with a heading row, the badge (small) and the name, cut
|
||||
with an ellipsis and whole on hover, over the lines it always had; the
|
||||
rail shows the badge alone, its name on hover. Each company has one badge
|
||||
hue of eight (`theme::BADGE_HUES`, light and dark), chosen by a stable
|
||||
hash of the id of its books (`theme::hue_index`, FNV-1a modulo eight: a
|
||||
function of the id alone, so a company keeps its colour on every machine
|
||||
and after a rename); its tab and its card draw the same one, and the
|
||||
active tab's accent line stays the theme's. The bar's height (`tabs::BAR_H`) is taken from the
|
||||
window, so the smallest window the viewer allows is the 400 points below
|
||||
the bar plus the bar. A tab is the company's badge and name, as wide as
|
||||
that between a least and a greatest width; the "+" follows the last tab
|
||||
|
||||
@@ -4382,8 +4382,35 @@ renderer, as the sidebar's do):
|
||||
(else by the id).
|
||||
- `the_plus_list_says_so_when_every_company_is_open`: "Every company is
|
||||
already open." and no heading.
|
||||
- `pictures` (ignored; `SHOT_DIR`): the whole window with each tab in front,
|
||||
the "+" list and the empty window, for a person to look at.
|
||||
- `nothing_in_the_top_of_the_window_but_the_tab_shows_the_company_name`:
|
||||
per theme, on the Overview, Cash and the Journal, no painted text or
|
||||
widget in the tree below the bar and above 120 points names the company
|
||||
(the tab and its close control are in the bar), and the status card
|
||||
names the company in front once.
|
||||
- `the_status_card_shows_the_company_in_front_and_follows_the_tab`: the
|
||||
card's heading is the tab in front's name and its badge, small, in that
|
||||
company's hue (the other's is not on the card), and both change when
|
||||
another tab is shown; the window's title is unchanged.
|
||||
- `the_rail_shows_the_badge_alone_with_the_name_on_hover`.
|
||||
- `a_hue_is_the_books_id_alone_on_the_tab_and_the_card_in_both_themes_and_after_a_restart`:
|
||||
the hue a tab and a card draw is the one the id gives, light and dark,
|
||||
the same after a restart and in another order of opening, and pinned
|
||||
for three ids (a change recolours every company).
|
||||
- `the_overview_opens_with_its_summary_sentence_and_never_names_the_company`
|
||||
and `the_overview_of_books_with_no_transactions_opens_the_same_way`: the
|
||||
first text of the page is the sentence ("You have $8,765.44 in cash …",
|
||||
or "No transactions yet. …"), set bigger than body text and smaller than
|
||||
a page title, and no text on the page names the company (no sentence
|
||||
there used the name).
|
||||
- In `theme.rs`: `every_badge_hue_reads_in_both_themes` computes, for each
|
||||
of the eight hues in each theme, the letter's contrast on the badge
|
||||
(4.5:1, WCAG AA) and the badge's on the surface, sidebar, page and hover
|
||||
colours (3:1); `a_hue_is_a_function_of_the_book_id_alone` pins the hash
|
||||
and that every hue is used.
|
||||
- `pictures` (ignored; `SHOT_DIR`): the whole window with one company, each
|
||||
of two tabs in front, eight tabs, the "+" list, the empty window, the
|
||||
rail with two companies, the smallest window and the Overview at its
|
||||
top, light and dark, for a person to look at.
|
||||
|
||||
Unit tests moved with the code they test: the sidebar's fit tests, now
|
||||
in `company.rs`; the scheme tests, in `scheme_menu.rs`. The tab bar runs
|
||||
@@ -4405,6 +4432,19 @@ it by its name, which the list shows once the company has been open; the
|
||||
list's empty words are now "Every company is already open." The ten
|
||||
`tabs_*` snapshots were regenerated for the new bar.
|
||||
|
||||
The company's name once, not three times (the owner's review of the bar):
|
||||
the sidebar's header (badge, name, "Books") is gone, and so is the
|
||||
Overview's heading, whose summary sentence is now the page's lead; the
|
||||
status card's new heading row carries the company instead, with its hue.
|
||||
That removed 28 points and the gap under the header from the top of the
|
||||
sidebar and added a row to the card, so the sidebar has more room at every
|
||||
height (at 1479x519 the links' viewport is 331 points, was 311, and the
|
||||
rows 23 high, were 22); no `sidenav.rs` assertion or window changed. The
|
||||
tall sidebar's shapes golden and pixel golden (`sidenav-1440x920`) were
|
||||
regenerated (the header gone and the links moved up, the card's heading
|
||||
row, the badge's hue), and the `tabs_*` snapshots again (hue, no
|
||||
Overview heading, the rail's badge); `tabs_empty_*` are as they were.
|
||||
|
||||
**Not tested here:** the window title reaching the window system (the
|
||||
harness has none: `window_title()` is what is tested); a company opened
|
||||
from the viewer while its books are being created by the server (the
|
||||
|
||||