Skip to main content

fastpack_gui/
lib.rs

1#![allow(dead_code, unused_imports, unused_variables, unused_mut)]
2
3pub mod app;
4pub mod menu;
5pub mod panels;
6pub mod state;
7pub mod theme;
8pub mod toolbar;
9pub mod widgets;
10pub mod worker;
11
12use std::path::PathBuf;
13
14/// Launch the native GUI window.
15///
16/// `project_path` is the optional `.fpsheet` file to open on startup.
17pub fn run(project_path: Option<PathBuf>) -> anyhow::Result<()> {
18    let mut app = app::FastPackApp::default();
19    if let Some(path) = project_path {
20        match std::fs::read_to_string(&path) {
21            Ok(text) => match toml::from_str(&text) {
22                Ok(project) => {
23                    app.state.project = project;
24                    app.state.project_path = Some(path);
25                }
26                Err(e) => app.state.log_error(format!("Failed to parse project: {e}")),
27            },
28            Err(e) => app.state.log_error(format!("Failed to read project: {e}")),
29        }
30    }
31    let options = eframe::NativeOptions::default();
32    eframe::run_native(
33        "FastPack",
34        options,
35        Box::new(|cc| {
36            theme::apply(&cc.egui_ctx, app.state.dark_mode);
37            Ok(Box::new(app))
38        }),
39    )
40    .map_err(|e| anyhow::anyhow!("eframe error: {e}"))
41}