From aadf765d87ba7a6036ab32e05d4766f6fe531187 Mon Sep 17 00:00:00 2001 From: server2 Date: Mon, 19 Oct 2026 11:41:57 +0200 Subject: [PATCH] Idle pill: the words only where they fit with room at both ends, else the note alone, so it never nears the rim --- src/island.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/island.rs b/src/island.rs index 12d9ea3..4f07369 100644 --- a/src/island.rs +++ b/src/island.rs @@ -589,15 +589,17 @@ pub fn faded(color: Color, alpha: u8) -> Color { 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 { - let content = Rectangle::new() - .width(c::pill::width()) - .height(c::pill::height()) - .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)); + let (width, h, note) = (c::pill::width(), c::pill::height(), 15.0); + let words = Text::new("Nothing playing").size(text::body()).color(theme::now().dim); + let fits = matches!(words.width(), amane::Size::Fixed(words_w) if note + 8.0 + words_w + h <= width); - 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