Panel: truncate task-button titles to fit their pill
CI / test (push) Successful in 38s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-24 20:06:53 -08:00
1 parent 9b31a7c476
commit 9e7687bea8
1 file changed
+11 -1
+11 -1
View File
@@ -170,6 +170,16 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
} }
} }
///| Truncate `s` with ".." so it fits `width` px (the renderer's small text is 6 px per char).
fn fit_title(s : String, width : Int) -> String {
let max_chars = width / 6
if s.length() <= max_chars {
s
} else {
s[:max_chars - 2].to_string() + ".."
}
}
///| ///|
fn inside(r : @scene.Rect, x : Int, y : Int) -> Bool { fn inside(r : @scene.Rect, x : Int, y : Int) -> Bool {
r.w > 0 && x >= r.x && x < r.x + r.w && y >= r.y && y < r.y + r.h r.w > 0 && x >= r.x && x < r.x + r.w && y >= r.y && y < r.y + r.h
@@ -312,7 +322,7 @@ pub fn DesktopShell::render(
translate( translate(
[ [
@ui.fill_rect(@ui.rect(tx, 0, pill_w, p.h), tokens.palette.surface_hover, radius=tokens.radius.reinterpret_as_int()), @ui.fill_rect(@ui.rect(tx, 0, pill_w, p.h), tokens.palette.surface_hover, radius=tokens.radius.reinterpret_as_int()),
@ui.text(tx + 10, p.h / 2, title, tokens.font_size.reinterpret_as_int() - 2, tokens.palette.foreground), @ui.text(tx + 10, p.h / 2, fit_title(title, pill_w - 20), tokens.font_size.reinterpret_as_int() - 2, tokens.palette.foreground),
], ],
p.x, p.x,
p.y, p.y,