feat(player): somewhat of a album view

This commit is contained in:
Christoph J. Scherr 2024-08-23 01:13:19 +02:00
parent 1e38e17f36
commit 22dbfdd193
2 changed files with 27 additions and 21 deletions

View File

@ -101,19 +101,17 @@ impl Player {
} }
fn main_panel(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) { fn main_panel(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) {
let tb = TableBuilder::new(ui) let mut tb = TableBuilder::new(ui);
.column(Column::remainder())
.column(Column::remainder()) let entries_per_line: usize = ctx.screen_rect().width() as usize / 256;
.column(Column::remainder())
.column(Column::remainder()) for _ in 0..entries_per_line {
.column(Column::remainder()) tb = tb.column(Column::remainder());
.column(Column::remainder()) }
.column(Column::remainder())
.column(Column::remainder());
tb.body(|mut body| { tb.body(|mut body| {
for line in self.entries().chunks(8) { for line in self.entries().chunks(entries_per_line) {
body.row(30.0, |mut row| { body.row(240.0, |mut row| {
for e in line { for e in line {
row.col(|ui| { row.col(|ui| {
ui.add(ShowBox::new(e)); ui.add(ShowBox::new(e));

View File

@ -19,16 +19,24 @@ impl ShowBox {
impl egui::Widget for ShowBox { impl egui::Widget for ShowBox {
fn ui(mut self, ui: &mut egui::Ui) -> egui::Response { fn ui(mut self, ui: &mut egui::Ui) -> egui::Response {
egui::Frame::none()
.fill(Color32::GRAY)
.show(ui, |ui| {
ui.label("Label with red background");
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
ui.add( ui.add(
egui::Image::new(ImageSource::Bytes { egui::Image::new(ImageSource::Bytes {
uri: std::borrow::Cow::Borrowed("fuck you"), uri: std::borrow::Cow::Borrowed("fuck you"),
bytes: egui::load::Bytes::Static(ICON_RAW), bytes: egui::load::Bytes::Static(ICON_RAW),
}) })
.rounding(5.0), .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")) ui.button("i dont get it").union(ui.label("caption"))
}) })
})
.response .response
} }
} }