Display album name for playable objects (#268)

* display album name

* give proper name to the space key

fixes #266

* use 50% for center offset

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
Moshe Sherman
2020-09-28 23:28:10 +03:00
committed by GitHub
parent cded15f50c
commit 77e5de562d
9 changed files with 47 additions and 2 deletions

View File

@@ -202,16 +202,19 @@ impl<I: ListItem> View for ListView<I> {
};
let left = item.display_left();
let center = item.display_center();
let right = item.display_right(self.library.clone());
let center_offset = printer.size.x / 2;
// draw left string
printer.with_color(style, |printer| {
printer.print_hline((0, 0), printer.size.x, " ");
printer.print((0, 0), &left);
});
// draw ".." to indicate a cut off string
let max_length = printer.size.x.saturating_sub(right.width() + 1);
// left string cut off indicator
let max_length = center_offset.saturating_sub(1);
if max_length < left.width() {
let offset = max_length.saturating_sub(1);
printer.with_color(style, |printer| {
@@ -219,6 +222,19 @@ impl<I: ListItem> View for ListView<I> {
});
}
printer.with_color(style, |printer| {
printer.print((center_offset, 0), &center);
});
// center string cut off indicator
let max_length = printer.size.x.saturating_sub(right.width() + 1);
if max_length < center_offset + center.width() {
let offset = max_length.saturating_sub(1);
printer.with_color(style, |printer| {
printer.print((offset, 0), "..");
});
}
// draw right string
let offset = HAlign::Right.get_offset(right.width(), printer.size.x);