Improve playlist page design

This commit is contained in:
Elias Projahn 2024-07-13 12:20:39 +02:00
parent b9c874ab8c
commit 09bedc892b
6 changed files with 56 additions and 37 deletions

View file

@ -52,16 +52,8 @@
border-radius: 12px; border-radius: 12px;
} }
.playlisttile .title {
font-weight: bold;
}
.playlisttile .subtitle {
font-size: smaller;
}
.playlisttile .parttitle { .playlisttile .parttitle {
font-size: smaller; font-style: italic;
} }
.program { .program {

View file

@ -8,7 +8,7 @@ template $MusicusPlaylistPage : Adw.Bin {
[top] [top]
Adw.HeaderBar { Adw.HeaderBar {
title-widget: Adw.WindowTitle { title-widget: Adw.WindowTitle {
title: _("Playlist"); title: _("Program");
}; };
[start] [start]

View file

@ -6,7 +6,7 @@ template $MusicusPlaylistTile : Gtk.Box {
Adw.Bin { Adw.Bin {
valign: end; valign: end;
margin-bottom: 12; margin-bottom: 14;
width-request: 48; width-request: 48;
Gtk.Image playing_icon { Gtk.Image playing_icon {
@ -19,29 +19,38 @@ template $MusicusPlaylistTile : Gtk.Box {
margin-end: 12; margin-end: 12;
orientation: vertical; orientation: vertical;
Gtk.Label title_label { Gtk.Label composers_label {
styles ["title"] styles ["title-4"]
visible: false; xalign: 0.0;
margin-top: 24;
halign: start;
wrap: true; wrap: true;
visible: false;
margin-top: 32;
}
Gtk.Label work_label {
styles ["title-2"]
xalign: 0.0;
wrap: true;
visible: false;
margin-top: 32;
margin-bottom: 12;
} }
Gtk.Label performances_label { Gtk.Label performances_label {
styles ["subtitle", "dim-label"] xalign: 0.0;
visible: false;
halign: start;
wrap: true; wrap: true;
visible: false;
margin-bottom: 12;
} }
Gtk.Label part_title_label { Gtk.Label part_title_label {
styles ["parttitle"] styles ["parttitle"]
xalign: 0.0;
wrap: true;
margin-top: 12; margin-top: 12;
margin-bottom: 12; margin-bottom: 12;
visible: false; visible: false;
margin-start: 24; margin-start: 24;
halign: start;
wrap: true;
} }
} }
} }

View file

@ -219,12 +219,6 @@ impl MusicusPlayer {
return; return;
} }
let title = format!(
"{}: {}",
recording.work.composers_string(),
recording.work.name.get(),
);
let performances = recording.performers_string(); let performances = recording.performers_string();
let mut items = Vec::new(); let mut items = Vec::new();
@ -232,7 +226,8 @@ impl MusicusPlayer {
if tracks.len() == 1 { if tracks.len() == 1 {
items.push(PlaylistItem::new( items.push(PlaylistItem::new(
true, true,
&title, Some(&recording.work.composers_string()),
&recording.work.name.get(),
Some(&performances), Some(&performances),
None, None,
&tracks[0].path, &tracks[0].path,
@ -259,7 +254,8 @@ impl MusicusPlayer {
items.push(PlaylistItem::new( items.push(PlaylistItem::new(
true, true,
&title, Some(&recording.work.composers_string()),
&recording.work.name.get(),
Some(&performances), Some(&performances),
Some(&track_title(&first_track, 1)), Some(&track_title(&first_track, 1)),
&first_track.path, &first_track.path,
@ -269,7 +265,8 @@ impl MusicusPlayer {
for (index, track) in tracks.enumerate() { for (index, track) in tracks.enumerate() {
items.push(PlaylistItem::new( items.push(PlaylistItem::new(
false, false,
&title, Some(&recording.work.composers_string()),
&recording.work.name.get(),
Some(&performances), Some(&performances),
// track number = track index + 1 (first track) + 1 (zero based) // track number = track index + 1 (first track) + 1 (zero based)
Some(&track_title(&track, index + 2)), Some(&track_title(&track, index + 2)),

View file

@ -17,7 +17,10 @@ mod imp {
pub is_title: OnceCell<bool>, pub is_title: OnceCell<bool>,
#[property(get, construct_only)] #[property(get, construct_only)]
pub title: OnceCell<String>, pub composers: OnceCell<Option<String>>,
#[property(get, construct_only)]
pub work: OnceCell<String>,
#[property(get, construct_only, nullable)] #[property(get, construct_only, nullable)]
pub performers: OnceCell<Option<String>>, pub performers: OnceCell<Option<String>>,
@ -49,7 +52,8 @@ glib::wrapper! {
impl PlaylistItem { impl PlaylistItem {
pub fn new( pub fn new(
is_title: bool, is_title: bool,
title: &str, composers: Option<&str>,
work: &str,
performers: Option<&str>, performers: Option<&str>,
part_title: Option<&str>, part_title: Option<&str>,
path: impl AsRef<Path>, path: impl AsRef<Path>,
@ -57,7 +61,8 @@ impl PlaylistItem {
) -> Self { ) -> Self {
glib::Object::builder() glib::Object::builder()
.property("is-title", is_title) .property("is-title", is_title)
.property("title", title) .property("composers", composers)
.property("work", work)
.property("performers", performers) .property("performers", performers)
.property("part-title", part_title) .property("part-title", part_title)
.property("path", path.as_ref()) .property("path", path.as_ref())
@ -66,7 +71,14 @@ impl PlaylistItem {
} }
pub fn make_title(&self) -> String { pub fn make_title(&self) -> String {
let mut title = self.title(); let mut title = String::new();
if let Some(composers) = self.composers() {
title.push_str(&composers);
title.push_str(": ");
}
title.push_str(&self.work());
if let Some(part_title) = self.part_title() { if let Some(part_title) = self.part_title() {
title.push_str(": "); title.push_str(": ");

View file

@ -11,7 +11,9 @@ mod imp {
#[template_child] #[template_child]
pub playing_icon: TemplateChild<gtk::Image>, pub playing_icon: TemplateChild<gtk::Image>,
#[template_child] #[template_child]
pub title_label: TemplateChild<gtk::Label>, pub composers_label: TemplateChild<gtk::Label>,
#[template_child]
pub work_label: TemplateChild<gtk::Label>,
#[template_child] #[template_child]
pub performances_label: TemplateChild<gtk::Label>, pub performances_label: TemplateChild<gtk::Label>,
#[template_child] #[template_child]
@ -59,12 +61,19 @@ impl PlaylistTile {
if let Some(item) = item { if let Some(item) = item {
if item.is_title() { if item.is_title() {
imp.title_label.set_label(&item.title()); if let Some(composers) = item.composers() {
imp.title_label.set_visible(true); imp.composers_label.set_label(&composers);
imp.composers_label.set_visible(true);
imp.work_label.set_margin_top(3);
}
imp.work_label.set_label(&item.work());
imp.work_label.set_visible(true);
if let Some(performances) = item.performers() { if let Some(performances) = item.performers() {
imp.performances_label.set_label(&performances); imp.performances_label.set_label(&performances);
imp.performances_label.set_visible(true); imp.performances_label.set_visible(true);
imp.work_label.set_margin_bottom(6);
} }
} }