use serde::{Deserialize, Serialize};
use tracing::info;
#[derive(Debug, Deserialize, Serialize)]
pub struct AppConfig {
pub name: String,
pub version: String,
pub description: Option<String>,
pub authors: Vec<String>,
}
#[derive(Debug)]
pub struct App {
config: AppConfig,
windows: Vec<Window>,
}
#[derive(Debug)]
pub struct Window {
title: String,
width: u32,
height: u32,
}
impl App {
pub fn new(config: AppConfig) -> Self {
info!("Creating new GUI app: {}", config.name);
Self { config, windows: Vec::new() }
}
pub fn add_window(&mut self, title: &str, width: u32, height: u32) -> usize {
let window = Window { title: title.to_string(), width, height };
self.windows.push(window);
self.windows.len() - 1
}
pub fn run(&mut self) -> Result<(), Box<dyn std::error::Error>> {
info!("Running GUI app: {}", self.config.name);
Ok(())
}
pub fn config(&self) -> &AppConfig {
&self.config
}
pub fn windows(&self) -> &Vec<Window> {
&self.windows
}
}