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
14use eframe::egui;
15
16/// Launch the native GUI window.
17///
18/// `project_path` is the optional `.fpsheet` file to open on startup.
19pub fn run(project_path: Option<PathBuf>) -> anyhow::Result<()> {
20    let mut app = app::FastPackApp::default();
21    if let Some(path) = project_path {
22        match std::fs::read_to_string(&path) {
23            Ok(text) => match toml::from_str(&text) {
24                Ok(project) => {
25                    app.state.project = project;
26                    app.state.project_path = Some(path);
27                }
28                Err(e) => app.state.log_error(format!("Failed to parse project: {e}")),
29            },
30            Err(e) => app.state.log_error(format!("Failed to read project: {e}")),
31        }
32    }
33    let options = eframe::NativeOptions {
34        viewport: egui::ViewportBuilder::default().with_inner_size([1280.0, 800.0]),
35        ..Default::default()
36    };
37    eframe::run_native(
38        "FastPack",
39        options,
40        Box::new(|cc| {
41            theme::apply(&cc.egui_ctx, app.state.dark_mode);
42            Ok(Box::new(app))
43        }),
44    )
45    .map_err(|e| anyhow::anyhow!("eframe error: {e}"))
46}