use super::context::ControllerContext;
use super::types::TabInfo;
use crate::error::Result;
use std::path::PathBuf;
pub trait ControllerFeature: Send {
fn id(&self) -> &'static str;
fn tab_info(&self) -> TabInfo;
fn render(&mut self, ui: &mut egui::Ui, ctx: &mut ControllerContext);
fn on_activate(&mut self, _ctx: &mut ControllerContext) {}
fn on_deactivate(&mut self, _ctx: &mut ControllerContext) {}
fn update(&mut self, _ctx: &mut ControllerContext) {}
fn initialize(&mut self, _ctx: &mut ControllerContext) -> Result<()> {
Ok(())
}
fn shutdown(&mut self) {}
}
pub trait FeatureState: Sized {
fn load() -> Result<Self>;
fn save(&self) -> Result<()>;
fn config_path() -> PathBuf;
fn load_or_default() -> Self
where
Self: Default,
{
Self::load().unwrap_or_default()
}
}