Polish pass: consistent sizes, quieter accent, keycaps

Binds the two shortcuts menus showed but nothing handled, and raises
faint text to 4.5:1 in light mode, with tests for both. Text sizes go
from 12 to 6 and corner sizes onto one scale, rows and buttons onto the
4px grid. Icons in lists use the text colour, the Git count is tonal and
the terminal dot only means something is running. Shortcuts show as
keycaps, and short strings lose their periods.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-06 19:06:13 -06:00
commit 5674954693
19 changed files with 180 additions and 118 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

After

Width:  |  Height:  |  Size: 279 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 KiB

After

Width:  |  Height:  |  Size: 527 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 KiB

After

Width:  |  Height:  |  Size: 384 KiB

Before After
Before After

View file

@ -352,7 +352,7 @@ impl App {
let shared = self.panes.iter().flat_map(|p| &p.tabs).filter(|t| t.doc == doc).count() > 1;
let d = &self.docs[&doc];
if d.buf.is_modified() && !shared && !d.buf.rope.len_chars().eq(&0) {
self.dialog = Some(Dialog::Confirm { title: format!("Save {}?", d.title()), body: "Your changes will be lost if you don't save them.".into(), pane, tab: i });
self.dialog = Some(Dialog::Confirm { title: format!("Save {}?", d.title()), body: "Your changes will be lost if you don't save them".into(), pane, tab: i });
return;
}
self.force_close(pane, i);
@ -734,7 +734,7 @@ impl App {
if let Some(c) = &self.complete {
let key = format!("comp/{}", c.seq);
let k = motion::spring_from(&key, 0.0, 1.0, Preset { stiffness: 900.0, damping: 0.66 });
let row = 30.0;
let row = 32.0;
let shown = c.items.len().min(8);
let sel = c.sel;
let first = sel.saturating_sub(shown - 1);
@ -751,16 +751,16 @@ impl App {
let area = egui::Area::new(Id::unique("completion")).order(egui::Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| {
ui.set_min_size(rect.size());
let p = ui.painter().clone();
shadow(&p, rect, 18.0, 0.9, t.dark);
p.rect_filled(rect, cr(18.0), t.high);
shadow(&p, rect, 16.0, 0.9, t.dark);
p.rect_filled(rect, cr(16.0), t.high);
let sy = spring("comp/y", (sel - first) as f32 * row, Preset { stiffness: 1400.0, damping: 0.78 });
p.rect_filled(Rect::from_min_size(rect.min + vec2(6.0, 6.0 + sy), vec2(w - 12.0, row)), cr(12.0), t.secondary_container);
for (i, (label, detail, kind)) in visible.iter().enumerate() {
let r = Rect::from_min_size(rect.min + vec2(6.0, 6.0 + i as f32 * row), vec2(w - 12.0, row));
if ui.interact(r, Id::unique(("comp", i)), Sense::click()).clicked() { clicked = Some(first + i) }
let ic = match kind { 2 | 3 | 4 => "code", 5 | 10 => "tag", 7 | 8 | 22 => "data_object", _ => "text_fields" };
icons::paint(ctx, &p, r.left_center() + vec2(16.0, 0.0), 15.0, ic, t.primary);
p.with_clip_rect(r).text(r.left_center() + vec2(32.0, 0.0), Align2::LEFT_CENTER, label, fonts::mono(12.5), if first + i == sel { t.on_secondary_container } else { t.on_surface });
icons::paint(ctx, &p, r.left_center() + vec2(16.0, 0.0), 16.0, ic, t.on_variant);
p.with_clip_rect(r).text(r.left_center() + vec2(32.0, 0.0), Align2::LEFT_CENTER, label, fonts::mono(12.0), if first + i == sel { t.on_secondary_container } else { t.on_surface });
p.with_clip_rect(r).text(r.right_center() - vec2(10.0, 0.0), Align2::RIGHT_CENTER, detail.chars().take(26).collect::<String>(), fonts::ui(11.0), t.outline);
}
});
@ -785,8 +785,8 @@ impl App {
let area = egui::Area::new(Id::unique("hover")).order(egui::Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| {
ui.set_min_size(rect.size());
let p = ui.painter().clone();
shadow(&p, rect, 18.0, 0.9, t.dark);
p.rect_filled(rect, cr(18.0), t.high);
shadow(&p, rect, 16.0, 0.9, t.dark);
p.rect_filled(rect, cr(16.0), t.high);
let pc = p.with_clip_rect(rect.shrink(8.0));
for (i, l) in lines.iter().enumerate() {
pc.text(rect.left_top() + vec2(14.0, 11.0 + i as f32 * 18.0), Align2::LEFT_TOP, *l, fonts::mono(12.0), t.on_surface);
@ -1117,7 +1117,7 @@ impl App {
(A, Key::J, SelectNext), (C, Key::F, Find), (C, Key::R, Replace), (CS, Key::F, FindInFiles), (C, Key::G, GotoLine),
(C, Key::P, QuickOpen), (CS, Key::R, Symbols), (C, Key::F5, RunFile), (C, Key::B, ToggleSidebar),
(A, Key::Num1, Side(0)), (A, Key::Num2, Side(1)), (A, Key::Num3, Side(2)), (A, Key::Num4, Side(3)), (A, Key::Num5, Side(4)),
(CS, Key::L, SplitRight), (N, Key::F10, ToggleWrap), (C, Key::Equals, ZoomIn), (C, Key::Plus, ZoomIn), (C, Key::Minus, ZoomOut), (C, Key::Num0, ZoomReset),
(CS, Key::L, SplitRight), (CA, Key::ArrowRight, FocusNextPane), (CS, Key::N, ToggleNumbers), (N, Key::F10, ToggleWrap), (C, Key::Equals, ZoomIn), (C, Key::Plus, ZoomIn), (C, Key::Minus, ZoomOut), (C, Key::Num0, ZoomReset),
(CS, Key::Minus, FoldHere), (CS, Key::OpenBracket, FoldAll), (CS, Key::CloseBracket, UnfoldAll),
(CS, Key::B, ToggleBookmark), (A, Key::PageDown, NextBookmark), (A, Key::PageUp, PrevBookmark),
(N, Key::F12, GotoDefinition), (C, Key::I, Hover), (C, Key::Space, Complete), (N, Key::F8, NextProblem), (C, Key::Comma, Settings),
@ -1244,7 +1244,7 @@ impl App {
}
for (id, modified, name) in reload {
if modified {
self.toast("warning", format!("{name} changed on disk. Reload with F5."));
self.toast("warning", format!("{name} changed on disk, reload with F5"));
} else {
let _ = self.docs.get_mut(&id).unwrap().reload();
}
@ -1468,7 +1468,7 @@ impl App {
let code = Rect::from_min_max(card.min, pos2(card.right() - mini_w - if mini_w > 0.0 { 8.0 } else { 0.0 }, card.bottom()));
self.editor(ui, i, code.shrink2(vec2(0.0, 2.0)));
if self.s.preview {
let rail = Rect::from_min_max(pos2(card.right() - mini_w - 6.0, card.top() + 6.0), pos2(card.right() - 6.0, card.bottom() - 6.0));
let rail = Rect::from_min_max(pos2(card.right() - mini_w - 8.0, card.top() + 8.0), pos2(card.right() - 8.0, card.bottom() - 8.0));
self.preview(ui, i, rail);
}
if focused {
@ -1511,18 +1511,18 @@ impl App {
let picks: Vec<&crate::ui::commands::Entry> = self.s.toolbar.iter().filter_map(|l| all.iter().find(|e| e.label == l)).collect();
let n = picks.len();
for (i, e) in picks.iter().enumerate() {
let x = right - 44.0 - (n - 1 - i) as f32 * 38.0;
let x = right - 44.0 - (n - 1 - i) as f32 * 36.0;
let key = format!("bar/{}", e.label);
let tip = if e.keys.is_empty() { e.label.to_string() } else { format!("{} ({})", e.label, e.keys) };
let k = motion::spring_from(format!("{key}/in"), 0.4, 1.0, motion::DEFAULT);
if icon_btn(ui, &t, Rect::from_center_size(pos2(x, y), vec2(34.0, 34.0) * k), &key, e.ic, &tip, false).clicked() {
if icon_btn(ui, &t, Rect::from_center_size(pos2(x, y), vec2(32.0, 32.0) * k), &key, e.ic, &tip, false).clicked() {
self.run(&ctx, e.cmd.clone());
}
}
}
fn toolbar_width(&self) -> f32 {
60.0 + self.s.toolbar.len() as f32 * 38.0
60.0 + self.s.toolbar.len() as f32 * 36.0
}
fn toasts_ui(&mut self, ctx: &egui::Context) {
@ -1536,17 +1536,17 @@ impl App {
let age = (now - x.born) as f32;
let out = age > 3.2;
let k = motion::spring_from(format!("toast/{}", x.seq), 0.0, if out { 0.0 } else { 1.0 }, motion::DEFAULT);
let w = 66.0 + ctx.fonts_mut(|f| f.layout_no_wrap(x.text.clone(), fonts::ui(13.5), t.on_surface).size().x);
let w = 66.0 + ctx.fonts_mut(|f| f.layout_no_wrap(x.text.clone(), fonts::ui(13.0), t.on_surface).size().x);
let size = vec2(lerp(44.0, w, k.clamp(0.0, 1.1)), 44.0);
let r = Rect::from_min_size(pos2(screen.center().x - size.x / 2.0, y + (1.0 - k) * 60.0 - 44.0), size);
let inv = (t.on_surface, t.surface);
egui::Area::new(Id::unique(("toast", x.seq))).order(egui::Order::Tooltip).fixed_pos(r.min).interactable(false).show(ctx, |ui| {
let p = ui.painter().with_clip_rect(ctx.content_rect());
shadow(&p, r, 22.0, k.clamp(0.0, 1.0) * 0.8, t.dark);
p.rect_filled(r, cr(22.0), inv.0);
shadow(&p, r, r.height() / 2.0, k.clamp(0.0, 1.0) * 0.8, t.dark);
p.rect_filled(r, cr(r.height() / 2.0), inv.0);
icons::paint(ctx, &p, r.left_center() + vec2(23.0, 0.0), 19.0, x.ic, alpha(inv.1, k.clamp(0.0, 1.0)));
if k > 0.5 {
p.with_clip_rect(r).text(r.left_center() + vec2(42.0, 0.0), Align2::LEFT_CENTER, &x.text, fonts::ui(13.5), alpha(inv.1, (k * 2.0 - 1.0).clamp(0.0, 1.0)));
p.with_clip_rect(r).text(r.left_center() + vec2(42.0, 0.0), Align2::LEFT_CENTER, &x.text, fonts::ui(13.0), alpha(inv.1, (k * 2.0 - 1.0).clamp(0.0, 1.0)));
}
});
y -= 52.0 * k.clamp(0.0, 1.0);

View file

@ -230,7 +230,7 @@ impl Theme {
lowest: n.at(d(4.0, 100.0)), low: n.at(d(10.0, 96.0)), container: n.at(d(12.0, 94.0)),
high: n.at(d(17.0, 92.0)), highest: n.at(d(22.0, 90.0)),
on_surface: n.at(d(90.0, 10.0)), on_variant: nv.at(d(80.0, 30.0)),
outline: nv.at(d(60.0, 50.0)), outline_variant: nv.at(d(30.0, 80.0)),
outline: nv.at(d(62.0, 42.0)), outline_variant: nv.at(d(30.0, 80.0)),
syntax, ansi,
added: hue(145.0, d(74.0, 48.0), 1.3), changed: hue(235.0, d(74.0, 48.0), 1.3), removed: err.at(d(70.0, 50.0)),
}
@ -247,6 +247,22 @@ mod tests {
(x.max(y) + 0.05) / (x.min(y) + 0.05)
}
/// `outline` is the faint text: line numbers, paths, hints.
#[test]
fn faint_text_stays_readable_on_every_scheme() {
for seed in ["#7f5fc4", "#d0485e", "#3f9c6b", "#c8a020", "#2b7fd4"] {
for dark in [true, false] {
for sc in ["tonal", "vibrant", "expressive", "mono"] {
let t = Theme::from_seed(hex(seed).unwrap(), dark, sc);
for (name, bg) in [("low", t.low), ("container", t.container), ("high", t.high)] {
let c = contrast(t.outline, bg);
assert!(c >= 4.5, "{seed} dark={dark} {sc} on {name}: {c:.2}");
}
}
}
}
}
#[test]
fn code_stays_readable_on_every_scheme() {
for seed in ["#7f5fc4", "#d0485e", "#3f9c6b", "#c8a020", "#2b7fd4"] {

View file

@ -58,9 +58,9 @@ pub fn all() -> Vec<Entry> {
e!(Side(0), "Files", "folder", "Alt+1"), e!(Side(1), "Search", "search", "Alt+2"), e!(Side(2), "Outline", "account_tree", "Alt+3"),
e!(Side(3), "Git", "commit", "Alt+4"), e!(Side(4), "Problems", "error", "Alt+5"),
e!(SplitRight, "Split right", "vertical_split", "Ctrl+Shift+L"), e!(SplitDown, "Split down", "splitscreen", ""),
e!(CloseSplit, "Close split", "close_fullscreen", ""), e!(FocusNextPane, "Next split", "tab", "Alt+Tab"),
e!(CloseSplit, "Close split", "close_fullscreen", ""), e!(FocusNextPane, "Next split", "tab", "Ctrl+Alt+Right"),
e!(Zen, "Zen mode", "fullscreen", "F11"), e!(ToggleWrap, "Word wrap", "wrap_text", "F10"),
e!(ToggleWhitespace, "Show whitespace", "visibility", ""), e!(ToggleNumbers, "Line numbers", "looks_one", "F11+Shift"),
e!(ToggleWhitespace, "Show whitespace", "visibility", ""), e!(ToggleNumbers, "Line numbers", "looks_one", "Ctrl+Shift+N"),
e!(TogglePreview, "Scrolling preview", "map", ""), e!(ToggleLens, "Preview lens", "manage_search", ""),
e!(ZoomIn, "Larger text", "add", "Ctrl+="), e!(ZoomOut, "Smaller text", "remove", "Ctrl+-"), e!(ZoomReset, "Default text size", "text_fields", "Ctrl+0"),
e!(FoldHere, "Fold or unfold here", "unfold_less", "Ctrl+Shift+-"), e!(FoldAll, "Fold everything", "unfold_less", "Ctrl+Shift+["),
@ -73,3 +73,31 @@ pub fn all() -> Vec<Entry> {
e!(GitRefresh, "Refresh git status", "sync", ""),
]
}
#[cfg(test)]
mod tests {
/// A shortcut shown in a menu has to be a shortcut that works.
#[test]
fn every_shortcut_shown_is_bound() {
let app = include_str!("../app.rs");
let table = &app[app.index_of_table()..];
for e in super::all() {
let name = format!("{:?}", e.cmd);
// these are text-editing keys handled by egui or the editor itself
if e.keys.is_empty() || ["Cut", "Copy", "Paste", "Indent", "Unindent"].contains(&name.as_str()) {
continue;
}
assert!(table.contains(&format!(", {name})")), "{} shows {} but nothing is bound", e.label, e.keys);
}
}
trait Table {
fn index_of_table(&self) -> usize;
}
impl Table for str {
fn index_of_table(&self) -> usize {
self.find("let global:").expect("the shortcut table")
}
}
}

View file

@ -321,7 +321,7 @@ impl App {
let bubble_y = spring(format!("cur/{pane}"), rect.top() + 6.0 + head_row as f32 * m.lh, Preset { stiffness: 1100.0, damping: 0.72 }) - scroll;
if doc.buf.sels.len() == 1 && doc.buf.sels[0].is_empty() {
let r = Rect::from_min_size(pos2(rect.left() + 6.0, bubble_y), vec2(rect.width() - 12.0, m.lh));
painter.rect_filled(r, cr(10.0), alpha(t.primary, if focused { 0.08 } else { 0.04 }));
painter.rect_filled(r, cr(8.0), alpha(t.primary, if focused { 0.08 } else { 0.04 }));
}
for (_, (line, _), _) in &rows {
if *line >= doc.buf.lines() { continue }
@ -341,7 +341,7 @@ impl App {
let eol = if *line < b.0 && to == *c1 { m.cw * 0.6 } else { 0.0 };
let xb = (vis_col(&text, to, tab_w) - base) as f32 * m.cw + eol;
let sr = Rect::from_min_max(pos2(x0 + xa, y_of(*row)), pos2(x0 + xb, y_of(*row) + m.lh));
code_p.rect_filled(sr, cr(5.0), alpha(t.primary, 0.3));
code_p.rect_filled(sr, cr(4.0), alpha(t.primary, 0.3));
}
}
for (a, b, is_current) in self.find_hits_in(doc_id, doc, &rows) {
@ -352,7 +352,7 @@ impl App {
let xa = (vis_col(&text, c0, tab_w) - base) as f32 * m.cw;
let xb = (vis_col(&text, c0 + (b - a), tab_w) - base) as f32 * m.cw;
let sr = Rect::from_min_max(pos2(x0 + xa - 1.0, y_of(row.0) + 1.0), pos2(x0 + xb + 1.0, y_of(row.0) + m.lh - 1.0));
code_p.rect_filled(sr, cr(5.0), if is_current { alpha(t.tertiary, 0.6) } else { alpha(t.tertiary, 0.24) });
code_p.rect_filled(sr, cr(4.0), if is_current { alpha(t.tertiary, 0.6) } else { alpha(t.tertiary, 0.24) });
}
if let Some((a, b)) = doc.buf.matching_bracket(doc.buf.head()) {
for at in [a, b] {
@ -362,7 +362,7 @@ impl App {
let x = (vis_col(&text, col, tab_w) - vis_col(&text, row.1.1, tab_w)) as f32 * m.cw;
let r = Rect::from_min_size(pos2(x0 + x - 1.0, y_of(row.0) + 1.0), vec2(m.cw + 2.0, m.lh - 2.0));
let pop = spring(format!("br/{pane}/{}", (at == a) as u8), 1.0, motion::FAST);
code_p.rect_filled(scale_rect(r, pop), cr(5.0), alpha(t.primary, 0.26));
code_p.rect_filled(scale_rect(r, pop), cr(4.0), alpha(t.primary, 0.26));
}
}
@ -372,7 +372,7 @@ impl App {
let y = y_of(*row);
if *c0 == 0 {
if self.s.line_numbers {
let col = if *line == cur_line { t.primary } else { alpha(t.on_variant, 0.55) };
let col = if *line == cur_line { t.primary } else { t.outline };
painter.text(pos2(rect.left() + gutter - 22.0, y + m.lh / 2.0), egui::Align2::RIGHT_CENTER, (line + 1).to_string(), g_font.clone(), col);
}
if doc.bookmarks.contains(line) {
@ -418,7 +418,7 @@ impl App {
let k = 1.0 - (age / 0.9);
let r = Rect::from_min_size(pos2(rect.left() + 6.0, y_of(row)), vec2(rect.width() - 12.0, m.lh));
let grow = motion::stagger(age, 0.0, 0.35);
painter.rect_filled(r.expand2(vec2(0.0, 5.0 * (1.0 - grow))), cr(10.0), alpha(t.primary, 0.34 * k * k));
painter.rect_filled(r.expand2(vec2(0.0, 5.0 * (1.0 - grow))), cr(8.0), alpha(t.primary, 0.34 * k * k));
motion::keep_alive();
}
}

View file

@ -133,10 +133,10 @@ impl App {
return;
}
let row = Rect::from_min_size(rect.min, vec2(rect.width(), 52.0));
if morph::button(ui, &t, Rect::from_center_size(pos2(rect.left() + 26.0, row.center().y), vec2(34.0, 34.0)), "find/more", Morph::Fold, self.find.replace, "Replace", t.high).clicked() {
if morph::button(ui, &t, Rect::from_center_size(pos2(rect.left() + 26.0, row.center().y), vec2(32.0, 32.0)), "find/more", Morph::Fold, self.find.replace, "Replace", t.high).clicked() {
self.find.replace = !self.find.replace;
}
let tools = 4.0 * 32.0 + 124.0;
let tools = 4.0 * 32.0 + 132.0;
let field = Rect::from_min_max(pos2(rect.left() + 48.0, row.top() + 9.0), pos2(rect.right() - tools, row.bottom() - 9.0));
let te = ui.put(field, egui::TextEdit::singleline(&mut self.find.query).frame(egui::Frame::NONE).hint_text("Find").font(fonts::ui(14.0)).align(Align2::LEFT_CENTER).text_color(if self.find.error { t.error } else { t.on_surface }));
if self.find.focus {
@ -156,18 +156,18 @@ impl App {
}
let count = if self.find.query.is_empty() { String::new() } else if self.find.hits.is_empty() { "None".to_string() } else { format!("{}/{}", self.find.cur + 1, self.find.hits.len()) };
p.text(pos2(rect.right() - tools + 52.0, row.center().y), Align2::CENTER_CENTER, count, fonts::ui(12.0), t.on_variant);
let mut x = rect.right() - 142.0;
let mut x = rect.right() - 150.0;
for (key, tip, label, on) in [("find/case", "Match case", "Aa", self.find.case), ("find/word", "Whole word", "ab", self.find.word), ("find/re", "Regular expression", ".*", self.find.regex)] {
let r = Rect::from_center_size(pos2(x, row.center().y), vec2(30.0, 30.0));
let r = Rect::from_center_size(pos2(x, row.center().y), vec2(32.0, 32.0));
let resp = icon_btn(ui, &t, r, key, "", tip, on);
p.text(r.center(), Align2::CENTER_CENTER, label, fonts::med(12.0), if on { t.on_secondary_container } else { t.on_variant });
if resp.clicked() {
match key { "find/case" => self.find.case ^= true, "find/word" => self.find.word ^= true, _ => self.find.regex ^= true }
}
x += 30.0;
x += 32.0;
}
if icon_btn(ui, &t, Rect::from_center_size(pos2(x + 2.0, row.center().y), vec2(30.0, 30.0)), "find/next", "keyboard_arrow_down", "Next (Enter)", false).clicked() { self.find_step(ui.ctx(), false) }
if morph::button(ui, &t, Rect::from_center_size(pos2(x + 32.0, row.center().y), vec2(30.0, 30.0)), "find/close", Morph::SearchClose, self.find.open, "Close (Esc)", t.high).clicked() { self.find_close(ui.ctx()) }
if icon_btn(ui, &t, Rect::from_center_size(pos2(x + 2.0, row.center().y), vec2(32.0, 32.0)), "find/next", "keyboard_arrow_down", "Next (Enter)", false).clicked() { self.find_step(ui.ctx(), false) }
if morph::button(ui, &t, Rect::from_center_size(pos2(x + 34.0, row.center().y), vec2(32.0, 32.0)), "find/close", Morph::SearchClose, self.find.open, "Close (Esc)", t.high).clicked() { self.find_close(ui.ctx()) }
if rep > 0.5 {
let y = row.bottom() - 2.0;
let f2 = Rect::from_min_max(pos2(rect.left() + 48.0, y + 8.0), pos2(rect.right() - 170.0, y + 34.0));

View file

@ -116,7 +116,7 @@ impl App {
let k = spring_from(&key, 0.0, 1.0, Preset { stiffness: 800.0, damping: 0.66 });
let row = 36.0;
let height: f32 = menu.items.iter().map(|i| if i.act.is_none() { 11.0 } else { row }).sum::<f32>() + 14.0;
let width = 268.0;
let width = 300.0;
let screen = ctx.content_rect();
let x = menu.pos.x.min(screen.right() - width - 10.0);
let y = menu.pos.y.min(screen.bottom() - height - 10.0).max(8.0);
@ -134,8 +134,8 @@ impl App {
let area = Area::new(Id::unique("menu-body")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| {
ui.set_min_size(rect.size());
let p = ui.painter();
shadow(p, rect, 22.0, 1.0, t.dark);
p.rect_filled(rect, cr(22.0), t.high);
shadow(p, rect, 20.0, 1.0, t.dark);
p.rect_filled(rect, cr(20.0), t.high);
let mut yy = rect.top() + 7.0;
for (i, it) in menu.items.iter().enumerate() {
let Some(a) = &it.act else {
@ -151,10 +151,10 @@ impl App {
let k2 = motion::stagger(motion::spring_from(format!("{ikey}/t"), 0.0, 1.0, motion::SLOW), i as f32 * 0.035, 0.6);
let dx = (1.0 - k2) * -10.0;
let col = alpha(t.on_surface, k2.clamp(0.0, 1.0));
if hov > 0.01 { p.rect_filled(scale_rect(r, 1.0 - 0.02 * press), cr(14.0), alpha(t.primary, 0.13 * hov)); }
if hov > 0.01 { p.rect_filled(scale_rect(r, 1.0 - 0.02 * press), cr(12.0), alpha(t.primary, 0.13 * hov)); }
if !it.ic.is_empty() { icons::paint(ui.ctx(), p, pos2(r.left() + 20.0 + dx, r.center().y), 18.0, it.ic, alpha(t.on_variant, k2.clamp(0.0, 1.0))) }
p.text(pos2(r.left() + 42.0 + dx, r.center().y), Align2::LEFT_CENTER, &it.label, fonts::ui(13.5), col);
if !it.keys.is_empty() { p.text(pos2(r.right() - 12.0, r.center().y), Align2::RIGHT_CENTER, &it.keys, fonts::ui(11.5), alpha(t.outline, k2.clamp(0.0, 1.0))); }
p.text(pos2(r.left() + 42.0 + dx, r.center().y), Align2::LEFT_CENTER, &it.label, fonts::ui(13.0), col);
if !it.keys.is_empty() { keycaps(p, &t, r.right_center() - vec2(8.0, 0.0), &it.keys, k2.clamp(0.0, 1.0)); }
if resp.clicked() { chosen = Some(a.clone()) }
yy += row;
}
@ -185,14 +185,14 @@ impl App {
let mut after: Option<Box<dyn FnOnce(&mut App, &egui::Context)>> = None;
let area = Area::new(Id::unique("dlg")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui: &mut Ui| {
ui.set_min_size(rect.size());
shadow(ui.painter(), rect, 28.0, 1.0, t.dark);
ui.painter().rect_filled(rect, cr(28.0), t.high);
shadow(ui.painter(), rect, 24.0, 1.0, t.dark);
ui.painter().rect_filled(rect, cr(24.0), t.high);
let title = match &dlg {
Dialog::Prompt { title, .. } | Dialog::Confirm { title, .. } => title.clone(),
Dialog::ConfirmTrash(p) => format!("Move {} to the trash?", p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default()),
Dialog::ConfirmQuit => "Quit with unsaved changes?".to_string(),
};
ui.painter().text(rect.left_top() + vec2(26.0, 34.0), Align2::LEFT_CENTER, title, fonts::med(18.0), t.on_surface);
ui.painter().text(rect.left_top() + vec2(26.0, 34.0), Align2::LEFT_CENTER, title, fonts::med(16.0), t.on_surface);
let btn_y = rect.bottom() - 48.0;
let primary = Rect::from_min_size(pos2(rect.right() - 126.0, btn_y), vec2(104.0, 36.0));
let cancel = Rect::from_min_size(pos2(rect.right() - 226.0, btn_y), vec2(92.0, 36.0));
@ -236,7 +236,7 @@ impl App {
}
}
Dialog::ConfirmQuit => {
ui.painter().text(rect.left_top() + vec2(26.0, 72.0), Align2::LEFT_CENTER, if self.side_window { "This window isn't part of your session, so they'll be lost." } else { "They stay saved as recovery copies for next time." }, fonts::ui(14.0), t.on_variant);
ui.painter().text(rect.left_top() + vec2(26.0, 72.0), Align2::LEFT_CENTER, if self.side_window { "This window isn't part of your session, so they'll be lost" } else { "They stay saved as recovery copies for next time" }, fonts::ui(14.0), t.on_variant);
if pill(ui, &t, primary, "dlg/ok", "", "Quit", Tone::Filled).clicked() {
after = Some(Box::new(|app, ctx| { app.quit_now = true; ctx.send_viewport_cmd(egui::ViewportCommand::Close) }));
close = true;

View file

@ -157,7 +157,7 @@ impl App {
}
let screen = ctx.content_rect();
let width = (screen.width() * 0.56).clamp(420.0, 680.0);
let row_h = 46.0;
let row_h = 44.0;
let shown = self.palette.rows.len().min(9);
let list_h = spring("pal/h", shown as f32 * row_h + if shown > 0 { 12.0 } else { 0.0 }, motion::DEFAULT);
let rect = Rect::from_min_size(pos2(screen.center().x - width / 2.0, screen.top() + 66.0), vec2(width, 60.0 + list_h.max(0.0)));
@ -182,9 +182,9 @@ impl App {
let area = Area::new(Id::unique("palette")).order(Order::Tooltip).fixed_pos(rect.min).show(ctx, |ui| {
ui.set_min_size(rect.size());
let p = ui.painter().clone();
shadow(&p, rect, 28.0, 1.0, t.dark);
p.rect_filled(rect, cr(28.0), t.high);
icons::paint(ctx, &p, pos2(rect.left() + 28.0, rect.top() + 30.0), 22.0, "search", t.primary);
shadow(&p, rect, 24.0, 1.0, t.dark);
p.rect_filled(rect, cr(24.0), t.high);
icons::paint(ctx, &p, pos2(rect.left() + 28.0, rect.top() + 30.0), 22.0, "search", t.on_variant);
let field = Rect::from_min_size(rect.min + vec2(50.0, 17.0), vec2(width - 66.0, 28.0));
let hint = if self.palette.langs { "Pick a language" } else { "Files · > commands · : line · @ symbol · ! run" };
let te = ui.put(field, egui::TextEdit::singleline(&mut self.palette.query).frame(egui::Frame::NONE).hint_text(hint).font(fonts::ui(16.0)).text_color(t.on_surface).lock_focus(true));
@ -197,7 +197,7 @@ impl App {
let lp = p.with_clip_rect(list);
let sel_y = spring("pal/sel", (sel - first.min(sel)) as f32 * row_h, Preset { stiffness: 1200.0, damping: 0.72 });
if shown > 0 {
lp.rect_filled(Rect::from_min_size(list.min + vec2(0.0, sel_y), vec2(list.width(), row_h)), cr(18.0), t.secondary_container);
lp.rect_filled(Rect::from_min_size(list.min + vec2(0.0, sel_y), vec2(list.width(), row_h)), cr(16.0), t.secondary_container);
}
let rows: Vec<Row> = self.palette.rows.iter().skip(first).take(shown).cloned().collect();
for (i, r) in rows.iter().enumerate() {
@ -207,7 +207,7 @@ impl App {
let dy = (1.0 - e) * 14.0;
let a = e.clamp(0.0, 1.0);
let is_sel = first + i == sel;
if resp.hovered() && !is_sel { lp.rect_filled(rr, cr(18.0), alpha(t.on_surface, 0.05)); }
if resp.hovered() && !is_sel { lp.rect_filled(rr, cr(16.0), alpha(t.on_surface, 0.05)); }
let fg = if is_sel { t.on_secondary_container } else { t.on_surface };
let c = rr.left_center() + vec2(22.0, dy);
icons::paint(ctx, &lp, c, 19.0, r.ic, alpha(if is_sel { fg } else { t.on_variant }, a));
@ -219,8 +219,11 @@ impl App {
if !r.detail.is_empty() {
lp.text(pos2(x, rr.center().y + dy), Align2::LEFT_CENTER, &r.detail, fonts::ui(12.0), alpha(t.outline, a));
}
if !r.keys.is_empty() {
lp.text(pos2(rr.right() - 14.0, rr.center().y + dy), Align2::RIGHT_CENTER, &r.keys, fonts::ui(12.0), alpha(if is_sel { fg } else { t.outline }, a * 0.9));
if r.keys.chars().all(|c| c.is_ascii_digit()) {
// on symbol rows this is a line number, not a shortcut
lp.text(pos2(rr.right() - 14.0, rr.center().y + dy), Align2::RIGHT_CENTER, &r.keys, fonts::ui(12.0), alpha(t.outline, a));
} else {
keycaps(&lp, &t, pos2(rr.right() - 12.0, rr.center().y + dy), &r.keys, a);
}
if resp.clicked() { picked = Some(r.pick.clone()) }
}

View file

@ -237,9 +237,9 @@ impl App {
ui.painter().clone()
};
if popped {
shadow(&painter, frame, 18.0, pop.clamp(0.0, 1.0), t.dark);
shadow(&painter, frame, 16.0, pop.clamp(0.0, 1.0), t.dark);
}
painter.rect_filled(frame, cr(18.0), mix(t.container, t.high, pop.clamp(0.0, 1.0)));
painter.rect_filled(frame, cr(16.0), mix(t.container, t.high, pop.clamp(0.0, 1.0)));
let inner = frame.shrink2(vec2(7.0, 6.0));
// the bent texture
@ -348,7 +348,7 @@ impl App {
let doc = &self.docs[&doc_id];
let (line, y) = (self.panes[pane].lens_line, self.panes[pane].lens_y);
let screen = ui.ctx().content_rect();
let lh = 19.0;
let lh = 20.0;
let rows = 15usize;
let width = (frame.left() - screen.left() - 110.0).clamp(240.0, 620.0);
let height = rows as f32 * lh + 44.0;
@ -363,27 +363,27 @@ impl App {
ui.ctx().set_transform_layer(layer, tf);
let p = egui::Painter::new(ui.ctx().clone(), layer, screen);
let fade = k.clamp(0.0, 1.0);
shadow(&p, card, 26.0, fade, t.dark);
p.rect_filled(card, cr(26.0), t.high);
shadow(&p, card, 24.0, fade, t.dark);
p.rect_filled(card, cr(24.0), t.high);
// header: where you are
let total = doc.buf.lines();
let center = (line as usize).min(total.saturating_sub(1));
let peek = self.panes[pane].peek_from.is_some();
let label = format!("{} · line {}", doc.title(), center + 1);
p.text(pos2(card.left() + 20.0, card.top() + 22.0), egui::Align2::LEFT_CENTER, label, fonts::med(12.5), t.on_variant);
p.text(pos2(card.left() + 20.0, card.top() + 22.0), egui::Align2::LEFT_CENTER, label, fonts::med(12.0), t.on_variant);
if peek {
let tag = Rect::from_min_size(pos2(card.right() - 66.0, card.top() + 11.0), vec2(52.0, 22.0));
p.rect_filled(tag, cr(11.0), t.tertiary_container);
p.text(tag.center(), egui::Align2::CENTER_CENTER, "Peek", fonts::med(11.5), t.on_tertiary_container);
p.rect_filled(tag, cr(tag.height() / 2.0), t.tertiary_container);
p.text(tag.center(), egui::Align2::CENTER_CENTER, "Peek", fonts::med(11.0), t.on_tertiary_container);
}
// code: the lines slide by at a sub-line offset so dragging reads as motion, not steps
let area = Rect::from_min_max(pos2(card.left() + 8.0, card.top() + 40.0), pos2(card.right() - 8.0, card.bottom() - 8.0));
let code = p.with_clip_rect(area);
let band = Rect::from_center_size(pos2(area.center().x, area.center().y), vec2(area.width(), lh));
code.rect_filled(band, cr(9.0), alpha(t.primary, 0.14));
let font = fonts::mono(12.5);
code.rect_filled(band, cr(8.0), alpha(t.primary, 0.14));
let font = fonts::mono(12.0);
let cw = ui.fonts_mut(|f| f.glyph_width(&font, 'M'));
let frac = line.fract();
let gut = 44.0;
@ -395,7 +395,7 @@ impl App {
let y = area.center().y + (i as f32 - frac + 0.5) * lh - lh / 2.0;
let d = ((y - area.center().y).abs() / (area.height() / 2.0)).min(1.0);
let dim = 1.0 - d * d * 0.75;
let col = if l == center { t.primary } else { alpha(t.on_variant, 0.55 * dim) };
let col = if l == center { t.primary } else { alpha(t.outline, dim) };
code.text(pos2(area.left() + gut - 12.0, y), egui::Align2::RIGHT_CENTER, (l + 1).to_string(), fonts::mono(11.0), col);
let max_cols = ((area.width() - gut - 8.0) / cw) as usize + 8;
let job = super::editor::line_job(doc, &self.reg, &t, l, (0, max_cols), &font, self.s.tab_width, false);

View file

@ -69,11 +69,12 @@ impl App {
let pop = spring(format!("{key}/badge"), 1.0, motion::FAST);
let b = pos2(c.x + 13.0, c.y - 10.0);
let txt = if n > 99 { "99+".to_string() } else { n.to_string() };
let w = if n > 9 { 22.0 } else { 16.0 };
let col = if i == 4 { t.error } else { t.primary };
let on = if i == 4 { t.on_error } else { t.on_primary };
let w = if n > 99 { 28.0 } else if n > 9 { 24.0 } else { 16.0 };
// only problems ask for attention; a count of changed files is just a count
let col = if i == 4 { t.error } else { t.secondary_container };
let on = if i == 4 { t.on_error } else { t.on_secondary_container };
ui.painter().rect_filled(Rect::from_center_size(b, vec2(w, 16.0) * pop), cr(8.0), col);
ui.painter().text(b, Align2::CENTER_CENTER, txt, fonts::med(10.0), on);
ui.painter().text(b, Align2::CENTER_CENTER, txt, fonts::med(11.0), on);
}
if resp.clicked() {
self.run(ui.ctx(), Cmd::Side(i));

View file

@ -82,7 +82,7 @@ impl App {
}
fn card(&self, ui: &Ui, r: Rect) {
ui.painter().rect_filled(r, cr(18.0), self.t.high);
ui.painter().rect_filled(r, cr(16.0), self.t.high);
}
fn label(&self, ui: &Ui, r: Rect, title: &str, sub: &str) {
@ -126,8 +126,8 @@ impl App {
let c = pos2(r.right() - 70.0, r.center().y);
ui.painter().text(c, Align2::CENTER_CENTER, value, fonts::med(14.0), t.on_surface);
let mut d = 0;
if icon_btn(ui, &t, Rect::from_center_size(c - vec2(44.0, 0.0), vec2(34.0, 34.0)), &format!("{key}-"), "remove", "", false).clicked() { d = -1 }
if icon_btn(ui, &t, Rect::from_center_size(c + vec2(44.0, 0.0), vec2(34.0, 34.0)), &format!("{key}+"), "add", "", false).clicked() { d = 1 }
if icon_btn(ui, &t, Rect::from_center_size(c - vec2(44.0, 0.0), vec2(32.0, 32.0)), &format!("{key}-"), "remove", "", false).clicked() { d = -1 }
if icon_btn(ui, &t, Rect::from_center_size(c + vec2(44.0, 0.0), vec2(32.0, 32.0)), &format!("{key}+"), "add", "", false).clicked() { d = 1 }
*y += 66.0;
d
}
@ -185,7 +185,7 @@ impl App {
self.s.motion = v.parse().unwrap_or(2);
}
self.toggle(ui, list, y, "set/prev", "Scrolling preview", "The rail of code beside the editor", |s| &mut s.preview);
self.toggle(ui, list, y, "set/lens", "Preview lens", "A card of code pops out while you drag. Hold Shift to peek.", |s| &mut s.lens);
self.toggle(ui, list, y, "set/lens", "Preview lens", "Shows readable code as you drag, hold Shift to peek", |s| &mut s.lens);
}
fn terminal_settings(&mut self, ui: &mut Ui, list: Rect, y: &mut f32) {
@ -212,7 +212,7 @@ impl App {
let field = Rect::from_min_size(pos2(r.right() - 214.0, r.center().y - 19.0), vec2(200.0, 38.0));
let resp = ui.interact(field, ui.scope_id().with("set/shellf"), Sense::click());
let (hov, press) = states("set/shellf", &resp);
ui.painter().rect_filled(scale_rect(field, 1.0 - 0.03 * press), cr(14.0), mix(t.highest, t.on_surface, 0.06 * hov));
ui.painter().rect_filled(scale_rect(field, 1.0 - 0.03 * press), cr(12.0), mix(t.highest, t.on_surface, 0.06 * hov));
ui.painter().text(field.left_center() + vec2(14.0, 0.0), Align2::LEFT_CENTER, current, fonts::med(13.0), t.on_surface);
morph::paint(ui.painter(), field.right_center() - vec2(20.0, 0.0), 16.0, Morph::Fold, 1.0 + open * 2.0, t.on_variant, t.highest);
if resp.clicked() { self.shell_open = !self.shell_open }
@ -224,10 +224,10 @@ impl App {
let row = ui.interact(rr.intersect(whole), ui.scope_id().with(&key), Sense::click());
let (hov, _) = states(&key, &row);
let on = self.s.shell == *path;
if on { p.rect_filled(rr, cr(14.0), t.secondary_container); }
else if hov > 0.01 { p.rect_filled(rr, cr(14.0), alpha(t.on_surface, 0.07 * hov)); }
if on { p.rect_filled(rr, cr(12.0), t.secondary_container); }
else if hov > 0.01 { p.rect_filled(rr, cr(12.0), alpha(t.on_surface, 0.07 * hov)); }
let fg = if on { t.on_secondary_container } else { t.on_surface };
p.text(rr.left_center() + vec2(14.0, 0.0), Align2::LEFT_CENTER, name, fonts::med(13.5), fg);
p.text(rr.left_center() + vec2(14.0, 0.0), Align2::LEFT_CENTER, name, fonts::med(13.0), fg);
p.text(rr.right_center() - vec2(14.0, 0.0), Align2::RIGHT_CENTER, path, fonts::ui(12.0), t.on_variant);
if row.clicked() {
self.s.shell = path.clone();
@ -249,9 +249,9 @@ impl App {
if pill(ui, &t, reset, "set/barclear", "", "Clear all", Tone::Tonal).clicked() { self.s.toolbar.clear() }
*y += 66.0;
let field = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 42.0));
ui.painter().rect_filled(field, cr(18.0), t.high);
ui.painter().rect_filled(field, cr(16.0), t.high);
icons::paint(ui.ctx(), ui.painter(), field.left_center() + vec2(20.0, 0.0), 18.0, "search", t.on_variant);
ui.put(Rect::from_min_max(field.min + vec2(38.0, 10.0), field.max - vec2(12.0, 8.0)), egui::TextEdit::singleline(&mut self.toolbar_filter).frame(egui::Frame::NONE).hint_text("Search commands").font(fonts::ui(13.5)).text_color(t.on_surface));
ui.put(Rect::from_min_max(field.min + vec2(38.0, 10.0), field.max - vec2(12.0, 8.0)), egui::TextEdit::singleline(&mut self.toolbar_filter).frame(egui::Frame::NONE).hint_text("Search commands").font(fonts::ui(13.0)).text_color(t.on_surface));
*y += 48.0;
let q = self.toolbar_filter.clone();
for e in super::commands::all() {
@ -260,16 +260,16 @@ impl App {
*y += 48.0;
if r.bottom() < list.top() || r.top() > list.bottom() { continue }
let on = self.s.toolbar.iter().any(|l| l == e.label);
ui.painter().rect_filled(r, cr(14.0), if on { t.highest } else { t.high });
ui.painter().rect_filled(r, cr(12.0), if on { t.highest } else { t.high });
icons::paint(ui.ctx(), ui.painter(), r.left_center() + vec2(22.0, 0.0), 19.0, e.ic, t.on_variant);
ui.painter().text(r.left_center() + vec2(46.0, 0.0), Align2::LEFT_CENTER, e.label, fonts::med(13.5), t.on_surface);
ui.painter().text(r.left_center() + vec2(46.0, 0.0), Align2::LEFT_CENTER, e.label, fonts::med(13.0), t.on_surface);
let sw = Rect::from_center_size(r.right_center() - vec2(44.0, 0.0), vec2(60.0, 38.0));
let full = !on && used >= TOOLBAR_MAX;
if switch(ui, &t, sw, &format!("set/bar/{}", e.label), on).clicked() {
if on {
self.s.toolbar.retain(|l| l != e.label);
} else if full {
self.toast("info", format!("The top bar holds {TOOLBAR_MAX} icons. Remove one first."));
self.toast("info", format!("The top bar holds {TOOLBAR_MAX} icons. Remove one first"));
} else {
self.s.toolbar.push(e.label.to_string());
}
@ -285,13 +285,13 @@ impl App {
let r = Rect::from_min_size(pos2(list.left(), *y), vec2(list.width(), 62.0));
self.card(ui, r);
let missing = self.s.discord_id.trim().is_empty();
self.label(ui, r, "Application ID", if missing { "Needed before anything shows. See the note below." } else { "The name Discord shows comes from this" });
self.label(ui, r, "Application ID", if missing { "Needed before anything shows" } else { "The name Discord shows comes from this" });
let field = Rect::from_min_size(pos2(r.right() - 234.0, r.center().y - 18.0), vec2(220.0, 36.0));
ui.painter().rect_filled(field, cr(14.0), t.highest);
ui.painter().rect_filled(field, cr(12.0), t.highest);
ui.put(field.shrink2(vec2(12.0, 9.0)), egui::TextEdit::singleline(&mut self.s.discord_id).frame(egui::Frame::NONE).font(fonts::ui(13.0)).text_color(t.on_surface));
*y += 66.0;
for (i, line) in ["Make an application named Damson at discord.com/developers/applications,", "then paste its Application ID here. For the small Damson icon, upload", "packaging/damson.svg as a PNG under Rich Presence, named damson."].iter().enumerate() {
ui.painter().text(pos2(list.left() + 18.0, *y + 12.0 + i as f32 * 19.0), Align2::LEFT_CENTER, *line, fonts::ui(12.5), t.on_variant);
ui.painter().text(pos2(list.left() + 18.0, *y + 12.0 + i as f32 * 19.0), Align2::LEFT_CENTER, *line, fonts::ui(12.0), t.on_variant);
}
*y += 70.0;
}

View file

@ -134,16 +134,16 @@ impl App {
let (hov, press) = states(key, &resp);
let c = scale_rect(r, 1.0 - 0.015 * press);
let p = ui.painter();
if sel { p.rect_filled(c, cr(14.0), t.secondary_container); }
else if hov > 0.01 { p.rect_filled(c, cr(14.0), alpha(t.on_surface, 0.07 * hov)); }
if !ic.is_empty() { icons::paint(ui.ctx(), p, pos2(r.left() + 16.0, r.center().y), 17.0, ic, col) }
if sel { p.rect_filled(c, cr(12.0), t.secondary_container); }
else if hov > 0.01 { p.rect_filled(c, cr(12.0), alpha(t.on_surface, 0.07 * hov)); }
if !ic.is_empty() { icons::paint(ui.ctx(), p, pos2(r.left() + 16.0, r.center().y), 16.0, ic, if sel { t.on_secondary_container } else { col }) }
let fg = if sel { t.on_secondary_container } else { t.on_surface };
let tx = r.left() + if ic.is_empty() { 12.0 } else { 34.0 };
let g = p.layout_no_wrap(label.to_string(), fonts::ui(13.0), fg);
let w = g.size().x;
p.with_clip_rect(r.intersect(ui.clip_rect())).galley(pos2(tx, r.center().y - g.size().y / 2.0), g, fg);
if !detail.is_empty() {
p.with_clip_rect(r.intersect(ui.clip_rect())).text(pos2(tx + w + 8.0, r.center().y), Align2::LEFT_CENTER, detail, fonts::ui(11.5), t.outline);
p.with_clip_rect(r.intersect(ui.clip_rect())).text(pos2(tx + w + 8.0, r.center().y), Align2::LEFT_CENTER, detail, fonts::ui(11.0), t.outline);
}
resp
}
@ -163,7 +163,7 @@ impl App {
let t = self.t.clone();
let Some(root) = self.root.clone() else {
let c = area.center_top() + vec2(0.0, 90.0);
ui.painter().text(c, Align2::CENTER_CENTER, "No folder open", fonts::ui(13.5), t.on_variant);
ui.painter().text(c, Align2::CENTER_CENTER, "No folder open", fonts::ui(13.0), t.on_variant);
let r = Rect::from_center_size(c + vec2(0.0, 40.0), vec2(150.0, 40.0));
if pill(ui, &t, r, "side/openf", "folder_open", "Open folder", Tone::Tonal).clicked() { self.run(ui.ctx(), Cmd::OpenFolder) }
return;
@ -189,7 +189,7 @@ impl App {
rows.splice(pos..pos, sub);
}
}
let row_h = 30.0;
let row_h = 34.0;
let scroll = self.scrolled(ui, area, 0, rows.len() as f32 * row_h);
let cur = self.cur_doc().and_then(|d| d.path.clone());
let first = (scroll / row_h) as usize;
@ -200,7 +200,7 @@ impl App {
let r = Rect::from_min_size(pos2(area.left() + *depth as f32 * 14.0, y), vec2(area.width() - *depth as f32 * 14.0 - 6.0, row_h - 2.0));
let key = format!("f/{}", path.display());
let open = self.side_state.expanded.contains(path);
let (ic, col) = if *is_dir { (if open { "folder_open" } else { "folder" }, t.primary) } else { ("description", t.on_variant) };
let (ic, col) = if *is_dir { (if open { "folder_open" } else { "folder" }, t.on_variant) } else { ("description", t.on_variant) };
let git = changed.get(path).copied();
let resp = self.row(ui, r, &key, ic, col, name, "", cur.as_ref() == Some(path));
if let Some(g) = git {
@ -239,9 +239,9 @@ impl App {
fn search_panel(&mut self, ui: &mut Ui, area: Rect) {
let t = self.t.clone();
let field = Rect::from_min_size(area.min + vec2(2.0, 2.0), vec2(area.width() - 4.0, 40.0));
ui.painter().rect_filled(field, cr(20.0), t.high);
ui.painter().rect_filled(field, cr(field.height() / 2.0), t.high);
icons::paint(ui.ctx(), ui.painter(), pos2(field.left() + 20.0, field.center().y), 18.0, "search", t.on_variant);
let te = ui.put(Rect::from_min_max(pos2(field.left() + 38.0, field.top() + 10.0), pos2(field.right() - 12.0, field.bottom() - 8.0)), egui::TextEdit::singleline(&mut self.side_state.search).frame(egui::Frame::NONE).hint_text("Search in project").font(fonts::ui(13.5)).text_color(t.on_surface));
let te = ui.put(Rect::from_min_max(pos2(field.left() + 38.0, field.top() + 10.0), pos2(field.right() - 12.0, field.bottom() - 8.0)), egui::TextEdit::singleline(&mut self.side_state.search).frame(egui::Frame::NONE).hint_text("Search in project").font(fonts::ui(13.0)).text_color(t.on_surface));
if self.side_state.search_focus { self.side_state.search_focus = false; te.request_focus() }
if te.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter)) { self.start_search() }
let list = Rect::from_min_max(pos2(area.left(), area.top() + 52.0), area.max);
@ -264,7 +264,7 @@ impl App {
let resp = ui.interact(r, ui.scope_id().with(("res", i)), Sense::click());
let (hov, _) = states(&format!("res/{i}"), &resp);
let p = ui.painter().with_clip_rect(r.intersect(ui.clip_rect()));
if hov > 0.01 { p.rect_filled(r, cr(14.0), alpha(t.on_surface, 0.07 * hov)); }
if hov > 0.01 { p.rect_filled(r, cr(12.0), alpha(t.on_surface, 0.07 * hov)); }
p.text(pos2(r.left() + 10.0, r.top() + 13.0), Align2::LEFT_CENTER, text, fonts::mono(12.0), t.on_surface);
let rel = path.strip_prefix(&root).unwrap_or(path).display();
p.text(pos2(r.left() + 10.0, r.top() + 31.0), Align2::LEFT_CENTER, format!("{rel}:{}", line + 1), fonts::ui(11.0), t.outline);
@ -278,10 +278,10 @@ impl App {
let t = self.t.clone();
let items = self.outline();
if items.is_empty() {
ui.painter().text(area.center_top() + vec2(0.0, 80.0), Align2::CENTER_CENTER, "No symbols found", fonts::ui(13.5), t.on_variant);
ui.painter().text(area.center_top() + vec2(0.0, 80.0), Align2::CENTER_CENTER, "No symbols found", fonts::ui(13.0), t.on_variant);
return;
}
let row_h = 30.0;
let row_h = 34.0;
let scroll = self.scrolled(ui, area, 2, items.len() as f32 * row_h);
let cur = self.cur_doc().map_or(0, |d| d.buf.pos(d.buf.head()).0);
let here = items.iter().rposition(|i| i.0 <= cur);
@ -291,7 +291,7 @@ impl App {
let y = area.top() + i as f32 * row_h - scroll;
let r = Rect::from_min_size(pos2(area.left(), y), vec2(area.width() - 6.0, row_h - 2.0));
let ic = match *kind { "type" | "class" => "data_object", "heading" => "tag", _ => "code" };
if self.row(ui, r, &format!("o/{i}"), ic, t.primary, name, "", here == Some(i)).clicked() { go = Some(*line) }
if self.row(ui, r, &format!("o/{i}"), ic, t.on_variant, name, "", here == Some(i)).clicked() { go = Some(*line) }
}
if let Some(l) = go { self.jump_to_line(ui.ctx(), l) }
}
@ -299,17 +299,17 @@ impl App {
fn git_panel(&mut self, ui: &mut Ui, area: Rect) {
let t = self.t.clone();
if self.git.root.is_none() {
ui.painter().text(area.center_top() + vec2(0.0, 80.0), Align2::CENTER_CENTER, "Not a git repository", fonts::ui(13.5), t.on_variant);
ui.painter().text(area.center_top() + vec2(0.0, 80.0), Align2::CENTER_CENTER, "Not a git repository", fonts::ui(13.0), t.on_variant);
return;
}
let root = self.git.root.clone().unwrap();
let branch = Rect::from_min_size(area.min + vec2(2.0, 2.0), vec2(area.width() - 4.0, 38.0));
ui.painter().rect_filled(branch, cr(19.0), t.secondary_container);
ui.painter().rect_filled(branch, cr(branch.height() / 2.0), t.secondary_container);
icons::paint(ui.ctx(), ui.painter(), pos2(branch.left() + 20.0, branch.center().y), 18.0, "call_split", t.on_secondary_container);
ui.painter().text(pos2(branch.left() + 38.0, branch.center().y), Align2::LEFT_CENTER, format!("{} {}", self.git.branch, self.git.ahead), fonts::med(13.0), t.on_secondary_container);
let field = Rect::from_min_size(area.min + vec2(2.0, 50.0), vec2(area.width() - 4.0, 40.0));
ui.painter().rect_filled(field, cr(16.0), t.high);
ui.put(field.shrink2(vec2(14.0, 11.0)), egui::TextEdit::singleline(&mut self.side_state.commit).frame(egui::Frame::NONE).hint_text("Commit message").font(fonts::ui(13.5)).text_color(t.on_surface));
ui.put(field.shrink2(vec2(14.0, 11.0)), egui::TextEdit::singleline(&mut self.side_state.commit).frame(egui::Frame::NONE).hint_text("Commit message").font(fonts::ui(13.0)).text_color(t.on_surface));
let w = (area.width() - 10.0) / 3.0;
let row = |i: usize| Rect::from_min_size(pos2(area.left() + 2.0 + i as f32 * (w + 3.0), area.top() + 98.0), vec2(w, 34.0));
if pill(ui, &t, row(0), "git/commit", "check", "Commit", Tone::Filled).clicked() { self.git_commit() }
@ -317,7 +317,7 @@ impl App {
if pill(ui, &t, row(2), "git/push", "upload", "Push", Tone::Tonal).clicked() { self.git_remote("push") }
let list = Rect::from_min_max(pos2(area.left(), area.top() + 142.0), area.max);
let files = self.git.files.clone();
let row_h = 32.0;
let row_h = 34.0;
let scroll = self.scrolled(ui, list, 3, files.len() as f32 * row_h);
let mut cl = ui.new_child(egui::UiBuilder::new().max_rect(list));
cl.set_clip_rect(list.intersect(ui.clip_rect()));
@ -349,10 +349,10 @@ impl App {
if all.is_empty() {
let c = area.center_top() + vec2(0.0, 80.0);
icons::paint(ui.ctx(), ui.painter(), c, 34.0, "check_circle", t.primary);
ui.painter().text(c + vec2(0.0, 32.0), Align2::CENTER_CENTER, "No problems", fonts::ui(13.5), t.on_variant);
ui.painter().text(c + vec2(0.0, 32.0), Align2::CENTER_CENTER, "No problems", fonts::ui(13.0), t.on_variant);
return;
}
let row_h = 54.0;
let row_h = 48.0;
let scroll = self.scrolled(ui, area, 4, all.len() as f32 * row_h);
let first = (scroll / row_h) as usize;
let mut open = None;
@ -362,11 +362,11 @@ impl App {
let resp = ui.interact(r, ui.scope_id().with(("prob", i)), Sense::click());
let (hov, _) = states(&format!("prob/{i}"), &resp);
let p = ui.painter().with_clip_rect(r.intersect(ui.clip_rect()));
if hov > 0.01 { p.rect_filled(r, cr(14.0), alpha(t.on_surface, 0.07 * hov)); }
if hov > 0.01 { p.rect_filled(r, cr(12.0), alpha(t.on_surface, 0.07 * hov)); }
let (ic, col) = if d.severity == 1 { ("error", t.error) } else if d.severity == 2 { ("warning", t.syntax[crate::syntax::DefStyle::Warning as usize]) } else { ("info", t.primary) };
icons::paint(ui.ctx(), &p, pos2(r.left() + 15.0, r.top() + 16.0), 17.0, ic, col);
let msg: String = d.msg.lines().next().unwrap_or("").chars().take(70).collect();
p.text(pos2(r.left() + 32.0, r.top() + 16.0), Align2::LEFT_CENTER, msg, fonts::ui(12.5), t.on_surface);
p.text(pos2(r.left() + 32.0, r.top() + 16.0), Align2::LEFT_CENTER, msg, fonts::ui(12.0), t.on_surface);
let name = path.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
p.text(pos2(r.left() + 32.0, r.top() + 36.0), Align2::LEFT_CENTER, format!("{name}:{}", d.line + 1), fonts::ui(11.0), t.outline);
if resp.clicked() { open = Some((path.clone(), d.line)) }

View file

@ -37,14 +37,14 @@ impl App {
items.push((format!("{e} errors, {w} warnings"), if e > 0 { "error" } else { "warning" }, Some(Cmd::Side(4))));
}
for (i, (text, ic, cmd)) in items.iter().enumerate() {
let g = ui.painter().layout_no_wrap(text.clone(), fonts::ui(12.5), t.on_variant);
let g = ui.painter().layout_no_wrap(text.clone(), fonts::ui(12.0), t.on_variant);
let w = g.size().x + 22.0 + if ic.is_empty() { 0.0 } else { 20.0 };
if x + w > rect.right() - FAB_W - 52.0 { break }
let r = Rect::from_min_size(pos2(x, rect.center().y - 14.0), vec2(w, 28.0));
let key = format!("st/{i}");
let resp = ui.interact(r, ui.scope_id().with(&key), if cmd.is_some() { Sense::click() } else { Sense::hover() });
let (hov, press) = states(&key, &resp);
ui.painter().rect_filled(scale_rect(r, 1.0 - 0.06 * press), cr(14.0), alpha(t.on_surface, 0.07 * hov));
ui.painter().rect_filled(scale_rect(r, 1.0 - 0.06 * press), cr(12.0), alpha(t.on_surface, 0.07 * hov));
let mut tx = r.left() + 11.0;
if !ic.is_empty() {
icons::paint(ui.ctx(), ui.painter(), pos2(tx + 7.0, r.center().y), 15.0, ic, t.on_variant);
@ -82,7 +82,7 @@ impl App {
let ic = pos2(c.left() + 28.0, c.center().y);
blob(ui.painter(), ic, 15.0, 6.0, 0.09 + 0.05 * on, on * 2.0 + hov * 0.4, alpha(fg, 0.16));
morph::paint(ui.painter(), ic, 21.0, Morph::TerminalHide, on, fg, bg);
ui.painter().text(pos2(c.left() + 50.0, c.center().y), Align2::LEFT_CENTER, "Terminal", fonts::med(13.5), fg);
ui.painter().text(pos2(c.left() + 50.0, c.center().y), Align2::LEFT_CENTER, "Terminal", fonts::med(13.0), fg);
if self.term_busy {
ui.painter().circle_filled(pos2(c.right() - 14.0, c.center().y), 3.5, fg);
}

View file

@ -173,7 +173,7 @@ impl App {
if let Some(i) = close {
self.close_tab(pane, i);
}
let add = Rect::from_center_size(pos2(rect.right() - 20.0, rect.center().y), vec2(34.0, 34.0));
let add = Rect::from_center_size(pos2(rect.right() - 20.0, rect.center().y), vec2(32.0, 32.0));
if morph::button(ui, &t, add, &format!("tabs/{pane}/add"), Morph::AddSpin, false, "New file", t.surface).clicked() {
self.focus_pane = pane;
self.run(ui.ctx(), super::commands::Cmd::New);

View file

@ -278,7 +278,8 @@ impl App {
ctx.memory_mut(|m| m.surrender_focus(egui::Id::unique("terminal-surface")));
}
}
self.term_busy = !self.terms.is_empty() && !self.term_open;
// the dot on the button means something is running behind the closed card
self.term_busy = !self.term_open && self.terms.iter().any(|s| s.running);
}
/// Draws the card. `open` is the spring from 0 (the button) to 1 (the full card).
@ -314,7 +315,7 @@ impl App {
let names: Vec<(String, u64)> = self.terms.iter().map(|s| (s.title.clone(), s.id)).collect();
for (i, (name, id)) in names.iter().enumerate() {
let label: String = name.chars().take(26).collect();
let g = p.layout_no_wrap(label, fonts::med(12.5), t.on_variant);
let g = p.layout_no_wrap(label, fonts::med(12.0), t.on_variant);
let w = g.size().x + 46.0;
let r = Rect::from_min_size(pos2(x, head.center().y - 14.0), vec2(w, 28.0));
let key = format!("term/tab/{id}");
@ -323,8 +324,8 @@ impl App {
let sel = i == self.term_cur;
let pop = crate::motion::spring_from(format!("{key}/in"), 0.5, 1.0, motion::DEFAULT);
let c = scale_rect(r, pop);
if sel { p.rect_filled(c, cr(14.0), alpha(t.secondary_container, vis)); }
else if hov > 0.01 { p.rect_filled(c, cr(14.0), alpha(t.on_surface, 0.07 * hov * vis)); }
if sel { p.rect_filled(c, cr(12.0), alpha(t.secondary_container, vis)); }
else if hov > 0.01 { p.rect_filled(c, cr(12.0), alpha(t.on_surface, 0.07 * hov * vis)); }
let fg = if sel { t.on_secondary_container } else { t.on_variant };
p.galley(pos2(r.left() + 12.0, r.center().y - g.size().y / 2.0), g, alpha(fg, vis));
let xr = Rect::from_center_size(pos2(r.right() - 14.0, r.center().y), vec2(20.0, 20.0));

View file

@ -20,8 +20,8 @@ impl App {
blob(ui.painter(), c, 42.0 * k, 6.0, 0.07, -now * 0.16, alpha(t.primary, 0.32));
icons::paint(ui.ctx(), ui.painter(), c, 42.0 * k, "code", t.on_primary_container);
if ui.input(|i| i.focused) { motion::keep_alive() }
ui.painter().text(c + vec2(0.0, 92.0), Align2::CENTER_CENTER, "Damson", fonts::med(30.0), t.on_surface);
ui.painter().text(c + vec2(0.0, 124.0), Align2::CENTER_CENTER, "Open something to get started", fonts::ui(14.0), t.on_variant);
ui.painter().text(c + vec2(0.0, 92.0), Align2::CENTER_CENTER, "Damson", fonts::med(26.0), t.on_surface);
ui.painter().text(c + vec2(0.0, 124.0), Align2::CENTER_CENTER, format!("{} languages from Kate, ready when you are", self.reg.languages.len()), fonts::ui(14.0), t.on_variant);
let y = c.y + 156.0;
let bw = 136.0;
let cx = rect.center().x;
@ -46,7 +46,7 @@ impl App {
let p = std::path::Path::new(r);
icons::paint(ui.ctx(), ui.painter(), pos2(rr.left() + 20.0, rr.center().y), 17.0, "history", t.on_variant);
ui.painter().text(pos2(rr.left() + 42.0, rr.center().y), Align2::LEFT_CENTER, p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(), fonts::med(13.0), t.on_surface);
ui.painter().with_clip_rect(rr).text(pos2(rr.right() - 12.0, rr.center().y), Align2::RIGHT_CENTER, p.parent().map(|d| d.to_string_lossy().replace(&dirs::home_dir().unwrap_or_default().to_string_lossy().into_owned(), "~")).unwrap_or_default(), fonts::ui(11.5), t.outline);
ui.painter().with_clip_rect(rr).text(pos2(rr.right() - 12.0, rr.center().y), Align2::RIGHT_CENTER, p.parent().map(|d| d.to_string_lossy().replace(&dirs::home_dir().unwrap_or_default().to_string_lossy().into_owned(), "~")).unwrap_or_default(), fonts::ui(11.0), t.outline);
if resp.clicked() { open = Some(p.to_path_buf()) }
ry += 40.0;
}

View file

@ -81,7 +81,7 @@ pub fn pill(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, ic: &str, text: &str,
let p = ui.painter();
p.rect_filled(c, cr(radius), bg);
p.rect_filled(c, cr(radius), alpha(if tone == Tone::Filled { t.on_primary } else { t.on_surface }, 0.08 * hov));
let font = fonts::med(13.5);
let font = fonts::med(13.0);
let g = p.layout_no_wrap(text.to_string(), font, fg);
let total = g.size().x + if ic.is_empty() { 0.0 } else { 26.0 };
let mut x = rect.center().x - total / 2.0;
@ -101,9 +101,9 @@ pub fn switch(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, on: bool) -> Respon
let track = Rect::from_center_size(rect.center(), vec2(50.0, 30.0));
let p = ui.painter();
let c = v.clamp(0.0, 1.0);
p.rect_filled(track, cr(15.0), mix(t.highest, t.primary, c));
p.rect_filled(track, cr(track.height() / 2.0), mix(t.highest, t.primary, c));
if c < 0.99 {
p.rect_stroke(track, cr(15.0), Stroke::new(2.0, alpha(t.outline, 1.0 - c)), StrokeKind::Inside);
p.rect_stroke(track, cr(track.height() / 2.0), Stroke::new(2.0, alpha(t.outline, 1.0 - c)), StrokeKind::Inside);
}
let x = lerp(track.left() + 15.0, track.right() - 15.0, v);
let d = lerp(16.0, 24.0, c) + 4.0 * press;
@ -133,6 +133,19 @@ pub fn segmented(ui: &mut Ui, t: &Theme, rect: Rect, key: &str, opts: &[(&str, &
out
}
/// Draws a shortcut as small keycaps, ending at `right`.
pub fn keycaps(p: &egui::Painter, t: &Theme, right: Pos2, keys: &str, fade: f32) {
let mut x = right.x;
for k in keys.rsplit('+') {
let g = p.layout_no_wrap(k.to_string(), fonts::ui(11.0), alpha(t.on_variant, fade));
let w = (g.size().x + 10.0).max(20.0);
let r = Rect::from_min_size(pos2(x - w, right.y - 10.0), vec2(w, 20.0));
p.rect_filled(r, cr(4.0), alpha(t.on_surface, 0.08 * fade));
p.galley(r.center() - g.size() / 2.0, g, t.on_variant);
x -= w + 4.0;
}
}
/// A thin scroll position pill for lists.
pub fn scroll_pill(p: &egui::Painter, t: &Theme, area: Rect, offset: f32, content: f32) {
if content <= area.height() {