generated from PlexSheep/rs-base
feat(player): add category and category selector
cargo devel CI / cargo CI (push) Successful in 3m28s
Details
cargo devel CI / cargo CI (push) Successful in 3m28s
Details
This commit is contained in:
parent
3dd949e9a5
commit
af3135462a
|
@ -29,6 +29,7 @@ image = { version = "0.25.2", default-features = true, features = [
|
|||
] }
|
||||
|
||||
libpt = { version = "0.6.0", features = ["cli", "full"] }
|
||||
strum = { version = "0.26.3", features = ["derive"] }
|
||||
thiserror = "1.0.63"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use libpt::log::{debug, info};
|
|||
|
||||
use crate::error::Error;
|
||||
|
||||
use self::ui::entry::Entry;
|
||||
use self::ui::entry::{Entry, Kind};
|
||||
|
||||
pub mod ui;
|
||||
|
||||
|
@ -21,6 +21,9 @@ pub struct Player {
|
|||
|
||||
#[clap(skip)]
|
||||
show_info_window: bool,
|
||||
|
||||
#[clap(skip)]
|
||||
kind: Kind,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
|
@ -59,16 +62,28 @@ impl Player {
|
|||
// we can use the creation context to do some customizing, but idc right now
|
||||
}
|
||||
|
||||
fn set_category(&mut self, kind: Kind) {
|
||||
self.kind = kind;
|
||||
}
|
||||
|
||||
fn category(&self) -> Kind {
|
||||
self.kind
|
||||
}
|
||||
|
||||
fn open(&mut self, entry: &Entry) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn entries(&self) -> Vec<Entry> {
|
||||
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());
|
||||
let mut v = Vec::new();
|
||||
match self.category() {
|
||||
Kind::Album => {
|
||||
let e = Entry::new(Kind::Album, "boom boom boom", "boomerboom", None);
|
||||
for _ in 0..100 {
|
||||
v.push(e.clone());
|
||||
}
|
||||
}
|
||||
_ => todo!("not all categories are implemented yet"),
|
||||
}
|
||||
v
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use egui::ImageSource;
|
||||
use strum::EnumIter;
|
||||
|
||||
#[derive(Hash, Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Hash, Debug, Clone, PartialEq, Eq, Copy, Default, EnumIter)]
|
||||
pub enum Kind {
|
||||
Playlist,
|
||||
#[default]
|
||||
Album,
|
||||
Song,
|
||||
Artist,
|
||||
|
@ -37,3 +39,24 @@ impl Entry {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Entry {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.title)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Kind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
Self::Song => "Song",
|
||||
Self::Album => "Album",
|
||||
Self::Playlist => "Playlist",
|
||||
Self::Artist => "Artist",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use egui::IconData;
|
||||
use egui::{IconData, Sense};
|
||||
use egui_extras::{Column, TableBuilder};
|
||||
use libpt::log::trace;
|
||||
use libpt::log::{trace, warn};
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
pub mod entry;
|
||||
pub mod showbox;
|
||||
|
@ -114,7 +115,13 @@ impl Player {
|
|||
body.row(240.0, |mut row| {
|
||||
for e in line {
|
||||
row.col(|ui| {
|
||||
ui.add(ShowBox::new(e));
|
||||
let shobo = ui.add(ShowBox::new(e));
|
||||
let shobo = shobo.interact(Sense::click());
|
||||
if shobo.clicked() {
|
||||
debug!("showbox \"{:#?}\" was clicked", shobo);
|
||||
warn!("clicking for showbox not defined yet");
|
||||
self.open(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -123,18 +130,13 @@ impl Player {
|
|||
}
|
||||
|
||||
fn meta_panel(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) {
|
||||
egui::menu::bar(ui, |ui| {
|
||||
// NOTE: no File->Quit on web pages!
|
||||
ui.menu_button("File", |ui| {
|
||||
if ui.button("Info").clicked() {
|
||||
self.show_info_window = true;
|
||||
ui.horizontal_centered(|ui| {
|
||||
for category in Kind::iter() {
|
||||
let sl = ui.selectable_label(self.category() == category, category.to_string());
|
||||
if sl.clicked() {
|
||||
self.set_category(category);
|
||||
}
|
||||
ui.separator();
|
||||
if ui.button("Quit").clicked() {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
});
|
||||
ui.add_space(16.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -47,3 +47,11 @@ impl egui::Widget for ShowBox {
|
|||
.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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue