diff --git a/psst-gui/src/ui/track.rs b/psst-gui/src/ui/track.rs index ebc68053..7d2fd43e 100644 --- a/psst-gui/src/ui/track.rs +++ b/psst-gui/src/ui/track.rs @@ -1,8 +1,10 @@ use std::sync::Arc; use druid::{ - widget::{CrossAxisAlignment, Either, Flex, Label, LineBreaking, ViewSwitcher}, - LensExt, LocalizedString, Menu, MenuItem, Size, TextAlignment, Widget, WidgetExt, + piet::UnitPoint, + widget::{CrossAxisAlignment, Either, Flex, Label, LineBreaking, Painter, ViewSwitcher}, + LensExt, LocalizedString, Menu, MenuItem, RenderContext, Size, TextAlignment, Widget, + WidgetExt, }; use psst_core::{ audio::normalize::NormalizationLevel, @@ -17,7 +19,7 @@ use crate::{ RecommendationsRequest, Track, }, ui::playlist, - widget::{icons, Empty, MyWidgetExt, RemoteImage}, + widget::{icons, Empty, MyWidgetExt, Overlay, RemoteImage}, }; use super::{ @@ -76,17 +78,24 @@ pub fn playable_widget(track: &Track, display: Display) -> impl Widget impl Widget>> { + let marker = playable::is_playing_marker_widget() + .lens(PlayRow::is_playing) + .expand_width() + .fix_height(8.0); // Adjust this value to visually confirm centering + + let title = Label::raw() + .with_font(theme::UI_FONT_MEDIUM) + .with_line_break_mode(LineBreaking::Clip) + .lens(PlayRow::item.then(Track::name.in_arc())); + + Overlay::bottom(marker, title) + .align_vertical(UnitPoint::CENTER) + .expand_width() + } + let mut title_row = Flex::row() - .with_flex_child( - Label::raw() - .with_font(theme::UI_FONT_MEDIUM) - .with_line_break_mode(LineBreaking::Clip) - .lens(PlayRow::item.then(Track::name.in_arc())) - .expand_width(), - 1.0, - ) - .with_default_spacer() - // .with_child(playable::is_playing_marker_widget().lens(PlayRow::is_playing)) + .with_flex_child(title_with_marker(), 1.0) .with_default_spacer() .must_fill_main_axis(true);