beatbaer/src/player/ui/showbox.rs
PlexSheep e068450b6b
Some checks failed
cargo devel CI / cargo CI (push) Failing after 1m4s
feat: add a lot of stuff, don't remember what exactly it did lol
2024-08-24 01:24:39 +02:00

53 lines
1.4 KiB
Rust

use egui::text::LayoutJob;
use egui::{Color32, FontFamily, FontId, Label, TextFormat};
use super::Entry;
pub struct ShowBox {
entry: Entry,
frame: egui::Frame,
}
impl ShowBox {
pub fn new(entry: &Entry) -> Self {
let frame = egui::Frame::none();
Self {
entry: entry.to_owned(),
frame,
}
}
}
impl egui::Widget for ShowBox {
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
ui.vertical_centered(|ui| {
let r = ui.add(
egui::Image::new(self.entry.img())
.rounding(5.0)
.bg_fill(Color32::DARK_GRAY)
.shrink_to_fit()
.maintain_aspect_ratio(true),
);
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
}
}
impl std::fmt::Debug for ShowBox {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ShowBox")
.field("entry", &self.entry)
.finish()
}
}