use clap::Parser; use eframe::CreationContext; use libpt::cli::args::VerbosityLevel; use libpt::log::{debug, info}; use crate::error::Error; use self::ui::entry::Entry; pub mod ui; pub const TITLE: &str = "Beatbär"; #[derive(Parser)] pub struct Player { #[command(flatten)] verbosity: VerbosityLevel, #[clap(skip)] pub gui_options: eframe::NativeOptions, #[clap(skip)] show_info_window: bool, } impl Player { pub fn build() -> Result { let mut app = Player::parse(); let filter = tracing_subscriber::EnvFilter::builder() .with_default_directive(app.verbosity.level().into()) .from_env() .expect("could not init logger") .add_directive( format!("{}={}", env!("CARGO_PKG_NAME"), app.verbosity.level()) .parse() .expect("could not init logger"), ); tracing_subscriber::fmt::Subscriber::builder() .with_env_filter(filter) .with_max_level(app.verbosity.level()) .init(); debug!("logging initialized!"); debug!("level: {}", app.verbosity.level()); app.gui_options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_inner_size([400.0, 300.0]) .with_min_inner_size([300.0, 220.0]) .with_icon(Player::load_icon()), ..Default::default() }; info!("Player ready to start UI"); Ok(app) } pub fn init(&mut self, _cc: &CreationContext) { // we can use the creation context to do some customizing, but idc right now } fn entries(&self) -> Vec { let e = Entry::new(ui::entry::Kind::Album, "boom boom boom.", None); let mut v = vec![e.clone()]; for _ in 0..100 { v.push(e.clone()); } v } }