Idle pill: the words only where they fit with room at both ends, else the note alone, so it never nears the rim

This commit is contained in:
server2
2026-10-19 11:41:57 +02:00
parent ed0eb532db
commit bccdb86ebb
+9 -7
View File
@@ -600,15 +600,17 @@ pub fn faded(color: Color, alpha: u8) -> Color {
Color::rgba(color.red(), color.green(), color.blue(), alpha) Color::rgba(color.red(), color.green(), color.blue(), alpha)
} }
// the island while no player is open: a music note and "Nothing playing", on the pill's surface // the island while no player is open: a music note and "Nothing playing", on the pill's surface;
// the words only where they fit with half the pill's height to spare at each end, else the note alone, so it never nears the rim
fn idle(colors: &[Color; 3]) -> Rectangle { fn idle(colors: &[Color; 3]) -> Rectangle {
let content = Rectangle::new() let (width, h, note) = (c::pill::width(), c::pill::height(), 15.0);
.width(c::pill::width()) let words = Text::new("Nothing playing").size(text::body()).color(theme::now().dim);
.height(c::pill::height()) let fits = matches!(words.width(), amane::Size::Fixed(words_w) if note + 8.0 + words_w + h <= width);
.align_child(Center, Center)
.child(Row::new(children![icon(Glyph::Note, 15.0, theme::now().accent), Text::new("Nothing playing").size(text::body()).color(theme::now().dim)]).gap(8.0).align(Center));
surface::shell(c::pill::width(), c::pill::height(), c::pill::height() / 2.0, colors, 0.0, content) let row = if fits { Row::new(children![icon(Glyph::Note, note, theme::now().accent), words]) } else { Row::new(children![icon(Glyph::Note, note, theme::now().accent)]) };
let content = Rectangle::new().width(width).height(h).align_child(Center, Center).child(row.gap(8.0).align(Center));
surface::shell(width, h, h / 2.0, colors, 0.0, content)
} }
// the pill: cover, title, the player's live levels // the pill: cover, title, the player's live levels