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:
@@ -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), ¢er);
|
||||
});
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user