Compare commits

...

2 commits

Author SHA1 Message Date
3dd949e9a5 Merge branch 'devel' of git.cscherr.de:PlexSheep/beatbaer into devel
All checks were successful
cargo devel CI / cargo CI (push) Successful in 3m9s
2024-08-23 09:43:27 +02:00
8f6c6b594f feat(player): imrpove album view 2024-08-23 09:43:16 +02:00
4 changed files with 24 additions and 8 deletions

View file

@ -60,7 +60,12 @@ impl Player {
} }
fn entries(&self) -> Vec<Entry> { 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()]; let mut v = vec![e.clone()];
for _ in 0..100 { for _ in 0..100 {
v.push(e.clone()); v.push(e.clone());

View file

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

View file

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

View file

@ -1,6 +1,7 @@
use egui::Color32; use egui::text::LayoutJob;
use egui::{Color32, FontFamily, FontId, ImageSource, Label, TextFormat};
use super::Entry; use super::{Entry, ICON_RAW};
pub struct ShowBox { pub struct ShowBox {
entry: Entry, entry: Entry,
@ -22,16 +23,25 @@ impl egui::Widget for ShowBox {
egui::Frame::none() egui::Frame::none()
// .fill(Color32::DARK_GRAY) // .fill(Color32::DARK_GRAY)
.show(ui, |ui| { .show(ui, |ui| {
ui.label("Label with red background");
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
ui.add( let mut r = ui.add(
egui::Image::new(self.entry.img()) egui::Image::new(self.entry.img())
.rounding(5.0) .rounding(5.0)
.bg_fill(Color32::DARK_GRAY) .bg_fill(Color32::DARK_GRAY)
.shrink_to_fit() .shrink_to_fit()
.maintain_aspect_ratio(true), .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 .response