previews: run previews as notedeck apps
This allows ./preview to be a notedeck app runner. I am currently using it for the ProfilePic app (which will because notedeck_viz) Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::AppContext;
|
||||
|
||||
pub trait App {
|
||||
fn update(&mut self, ctx: &mut AppContext<'_>);
|
||||
fn update(&mut self, ctx: &mut AppContext<'_>, ui: &mut egui::Ui);
|
||||
}
|
||||
|
||||
@@ -15,5 +15,4 @@ pub struct AppContext<'a> {
|
||||
pub path: &'a DataPath,
|
||||
pub args: &'a Args,
|
||||
pub theme: &'a mut ThemeHandler,
|
||||
pub egui: &'a egui::Context,
|
||||
}
|
||||
|
||||
@@ -22,18 +22,12 @@ impl DataPath {
|
||||
pub fn default_base() -> Option<PathBuf> {
|
||||
dirs::data_local_dir().map(|pb| pb.join("notedeck"))
|
||||
}
|
||||
}
|
||||
|
||||
pub enum DataPathType {
|
||||
Log,
|
||||
Setting,
|
||||
Keys,
|
||||
SelectedKey,
|
||||
Db,
|
||||
Cache,
|
||||
}
|
||||
pub fn default_base_or_cwd() -> PathBuf {
|
||||
use std::str::FromStr;
|
||||
Self::default_base().unwrap_or_else(|| PathBuf::from_str(".").unwrap())
|
||||
}
|
||||
|
||||
impl DataPath {
|
||||
pub fn rel_path(&self, typ: DataPathType) -> PathBuf {
|
||||
match typ {
|
||||
DataPathType::Log => PathBuf::from("logs"),
|
||||
@@ -50,6 +44,21 @@ impl DataPath {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DataPath {
|
||||
fn default() -> Self {
|
||||
Self::new(Self::default_base_or_cwd())
|
||||
}
|
||||
}
|
||||
|
||||
pub enum DataPathType {
|
||||
Log,
|
||||
Setting,
|
||||
Keys,
|
||||
SelectedKey,
|
||||
Db,
|
||||
Cache,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Directory {
|
||||
pub file_path: PathBuf,
|
||||
|
||||
Reference in New Issue
Block a user