feat(player): imrpove album view

This commit is contained in:
Christoph J. Scherr 2024-08-23 09:43:16 +02:00
parent c7b6917af2
commit 8f6c6b594f
4 changed files with 23 additions and 7 deletions

View File

@ -60,7 +60,12 @@ impl Player {
}
fn entries(&self) -> Vec<Entry> {
let e = Entry::new(ui::entry::Kind::Album, "boom boom boom.", None);
let e = Entry::new(
ui::entry::Kind::Album,
"boom boom boom.",
"boomerboom",
None,
);
let mut v = vec![e.clone()];
for _ in 0..100 {
v.push(e.clone());

View File

@ -12,15 +12,17 @@ pub enum Kind {
pub struct Entry {
pub kind: Kind,
pub title: String,
pub subtitle: String,
/// image url because I can't be bothered to use lifetimes everywhere
pub img_url: Option<String>,
}
impl Entry {
pub fn new(kind: Kind, title: &str, img: Option<String>) -> Self {
pub fn new(kind: Kind, title: &str, subtitle: &str, img: Option<String>) -> Self {
Self {
kind,
title: title.to_owned(),
subtitle: subtitle.to_owned(),
img_url: img,
}
}

View File

@ -9,7 +9,6 @@ use self::showbox::ShowBox;
use super::*;
const ICON_RAW_PATH: &str = "file://../../../assets/img/icon-512.jpg";
const ICON_RAW: &[u8; 36525] = include_bytes!("../../../assets/img/icon-512.jpg");
impl Player {

View File

@ -1,4 +1,5 @@
use egui::{Color32, ImageSource};
use egui::text::LayoutJob;
use egui::{Color32, FontFamily, FontId, ImageSource, Label, TextFormat};
use super::{Entry, ICON_RAW};
@ -22,16 +23,25 @@ impl egui::Widget for ShowBox {
egui::Frame::none()
// .fill(Color32::DARK_GRAY)
.show(ui, |ui| {
ui.label("Label with red background");
ui.vertical_centered(|ui| {
ui.add(
let mut r = ui.add(
egui::Image::new(self.entry.img())
.rounding(5.0)
.bg_fill(Color32::DARK_GRAY)
.shrink_to_fit()
.maintain_aspect_ratio(true),
);
ui.button("i dont get it").union(ui.label("caption"))
let mut job = LayoutJob::default();
job.append(
&self.entry.title,
0.0,
TextFormat {
font_id: FontId::new(14.0, FontFamily::Proportional),
..Default::default()
},
);
r.union(ui.add(Label::new(job)));
r.union(ui.label(&self.entry.subtitle));
})
})
.response