|
1 | | -#![windows_subsystem = "windows"] |
2 | | - |
3 | | -mod album; |
4 | | -mod analysis; |
5 | | -mod app; |
6 | | -mod audio; |
7 | | -mod audiodecode; |
8 | | -mod automation; |
9 | | -mod chorddb; |
10 | | -mod chordgrid; |
11 | | -mod chordvideo; |
12 | | -mod chordvoice; |
13 | | -mod cleanup; |
14 | | -mod coherence; |
15 | | -mod config; |
16 | | -mod crossfade; |
17 | | -mod crossfade_player; |
18 | | -mod dsp; |
19 | | -mod export; |
20 | | -mod fretboard; |
21 | | -mod generator; |
22 | | -mod git_update; |
23 | | -mod keymap; |
24 | | -mod lufs; |
25 | | -mod manual; |
26 | | -mod player; |
27 | | -mod project; |
28 | | -mod suno_import; |
29 | | -mod suno_meta; |
30 | | -mod tba; |
31 | | -mod tba_album; |
32 | | -mod telemetry; |
33 | | -mod tib; |
34 | | -mod tib_project; |
35 | | -mod tracker; |
36 | | -mod trim; |
37 | | -mod ui; |
38 | | -mod wav_meta; |
39 | | - |
40 | | -use eframe::egui; |
41 | | -use std::sync::Arc; |
42 | | - |
43 | | -pub const APP_NAME: &str = "TinyBooth Sound Studio"; |
44 | | -pub const APP_WINDOW_TITLE: &str = "TinyBooth Sound Studio"; |
45 | | -pub const APP_GH_REPO: &str = "ophiocus/TinyBoothSoundStudio"; |
46 | | - |
47 | | -/// PNG bitmap embedded at compile time for the window's top-left icon. |
48 | | -/// 256×256 is plenty — Windows' DWM scales it down for titlebar/taskbar. |
49 | | -const VIEWPORT_ICON_PNG: &[u8] = include_bytes!("../assets/icon_viewport.png"); |
50 | | - |
51 | | -/// Decode the embedded icon into raw RGBA for egui. Falls back silently |
52 | | -/// if decoding ever fails — we'd rather ship without a custom icon than |
53 | | -/// refuse to start. |
54 | | -fn load_icon() -> egui::IconData { |
55 | | - match image::load_from_memory(VIEWPORT_ICON_PNG) { |
56 | | - Ok(img) => { |
57 | | - let rgba = img.to_rgba8(); |
58 | | - let (width, height) = rgba.dimensions(); |
59 | | - egui::IconData { |
60 | | - rgba: rgba.into_raw(), |
61 | | - width, |
62 | | - height, |
63 | | - } |
64 | | - } |
65 | | - Err(_) => egui::IconData::default(), |
66 | | - } |
67 | | -} |
68 | | - |
69 | | -/// Install a panic hook that appends the panic message + backtrace to |
70 | | -/// `%APPDATA%\TinyBooth Sound Studio\logs\panic.log`. Without this, a |
71 | | -/// panic in a GUI-subsystem build has nowhere to go — there's no |
72 | | -/// console, so the window just vanishes with no trace (see the v0.4.39 |
73 | | -/// "session vanished with no log" investigation). Keeps the default |
74 | | -/// hook chained so behaviour under a debugger/console is unchanged. |
75 | | -fn install_panic_logger() { |
76 | | - let default_hook = std::panic::take_hook(); |
77 | | - std::panic::set_hook(Box::new(move |info| { |
78 | | - if let Some(dir) = dirs::data_dir() { |
79 | | - let logs = dir.join(APP_NAME).join("logs"); |
80 | | - let _ = std::fs::create_dir_all(&logs); |
81 | | - if let Ok(mut f) = std::fs::OpenOptions::new() |
82 | | - .create(true) |
83 | | - .append(true) |
84 | | - .open(logs.join("panic.log")) |
85 | | - { |
86 | | - use std::io::Write; |
87 | | - let bt = std::backtrace::Backtrace::force_capture(); |
88 | | - let _ = writeln!( |
89 | | - f, |
90 | | - "=== panic @ {} (v{}) ===\n{info}\n--- backtrace ---\n{bt}\n", |
91 | | - chrono::Local::now().to_rfc3339(), |
92 | | - env!("APP_VERSION"), |
93 | | - ); |
94 | | - } |
95 | | - } |
96 | | - default_hook(info); |
97 | | - })); |
98 | | -} |
99 | | - |
100 | | -fn main() -> eframe::Result<()> { |
101 | | - install_panic_logger(); |
102 | | - |
103 | | - let native_options = eframe::NativeOptions { |
104 | | - viewport: egui::ViewportBuilder::default() |
105 | | - .with_inner_size([1200.0, 800.0]) |
106 | | - .with_min_inner_size([900.0, 560.0]) |
107 | | - .with_title(APP_WINDOW_TITLE) |
108 | | - .with_icon(Arc::new(load_icon())), |
109 | | - ..Default::default() |
110 | | - }; |
111 | | - |
112 | | - eframe::run_native( |
113 | | - APP_NAME, |
114 | | - native_options, |
115 | | - Box::new(|cc| Ok(Box::new(app::TinyBoothApp::new(cc)))), |
116 | | - ) |
117 | | -} |
| 1 | +#![windows_subsystem = "windows"] |
| 2 | + |
| 3 | +mod album; |
| 4 | +mod analysis; |
| 5 | +mod app; |
| 6 | +mod audio; |
| 7 | +mod audiodecode; |
| 8 | +mod automation; |
| 9 | +mod chorddb; |
| 10 | +mod chordgrid; |
| 11 | +mod chordvideo; |
| 12 | +mod chordvoice; |
| 13 | +mod cleanup; |
| 14 | +mod coherence; |
| 15 | +mod config; |
| 16 | +mod crossfade; |
| 17 | +mod crossfade_player; |
| 18 | +mod dsp; |
| 19 | +mod export; |
| 20 | +mod fretboard; |
| 21 | +mod generator; |
| 22 | +mod git_update; |
| 23 | +mod keymap; |
| 24 | +mod lufs; |
| 25 | +mod manual; |
| 26 | +mod player; |
| 27 | +mod project; |
| 28 | +mod samplelib; |
| 29 | +mod suno_import; |
| 30 | +mod suno_meta; |
| 31 | +mod tba; |
| 32 | +mod tba_album; |
| 33 | +mod telemetry; |
| 34 | +mod tib; |
| 35 | +mod tib_project; |
| 36 | +mod tracker; |
| 37 | +mod tracker_demos; |
| 38 | +mod trim; |
| 39 | +mod ui; |
| 40 | +mod wav_meta; |
| 41 | + |
| 42 | +use eframe::egui; |
| 43 | +use std::sync::Arc; |
| 44 | + |
| 45 | +pub const APP_NAME: &str = "TinyBooth Sound Studio"; |
| 46 | +pub const APP_WINDOW_TITLE: &str = "TinyBooth Sound Studio"; |
| 47 | +pub const APP_GH_REPO: &str = "ophiocus/TinyBoothSoundStudio"; |
| 48 | + |
| 49 | +/// PNG bitmap embedded at compile time for the window's top-left icon. |
| 50 | +/// 256×256 is plenty — Windows' DWM scales it down for titlebar/taskbar. |
| 51 | +const VIEWPORT_ICON_PNG: &[u8] = include_bytes!("../assets/icon_viewport.png"); |
| 52 | + |
| 53 | +/// Decode the embedded icon into raw RGBA for egui. Falls back silently |
| 54 | +/// if decoding ever fails — we'd rather ship without a custom icon than |
| 55 | +/// refuse to start. |
| 56 | +fn load_icon() -> egui::IconData { |
| 57 | + match image::load_from_memory(VIEWPORT_ICON_PNG) { |
| 58 | + Ok(img) => { |
| 59 | + let rgba = img.to_rgba8(); |
| 60 | + let (width, height) = rgba.dimensions(); |
| 61 | + egui::IconData { |
| 62 | + rgba: rgba.into_raw(), |
| 63 | + width, |
| 64 | + height, |
| 65 | + } |
| 66 | + } |
| 67 | + Err(_) => egui::IconData::default(), |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +/// Install a panic hook that appends the panic message + backtrace to |
| 72 | +/// `%APPDATA%\TinyBooth Sound Studio\logs\panic.log`. Without this, a |
| 73 | +/// panic in a GUI-subsystem build has nowhere to go — there's no |
| 74 | +/// console, so the window just vanishes with no trace (see the v0.4.39 |
| 75 | +/// "session vanished with no log" investigation). Keeps the default |
| 76 | +/// hook chained so behaviour under a debugger/console is unchanged. |
| 77 | +fn install_panic_logger() { |
| 78 | + let default_hook = std::panic::take_hook(); |
| 79 | + std::panic::set_hook(Box::new(move |info| { |
| 80 | + if let Some(dir) = dirs::data_dir() { |
| 81 | + let logs = dir.join(APP_NAME).join("logs"); |
| 82 | + let _ = std::fs::create_dir_all(&logs); |
| 83 | + if let Ok(mut f) = std::fs::OpenOptions::new() |
| 84 | + .create(true) |
| 85 | + .append(true) |
| 86 | + .open(logs.join("panic.log")) |
| 87 | + { |
| 88 | + use std::io::Write; |
| 89 | + let bt = std::backtrace::Backtrace::force_capture(); |
| 90 | + let _ = writeln!( |
| 91 | + f, |
| 92 | + "=== panic @ {} (v{}) ===\n{info}\n--- backtrace ---\n{bt}\n", |
| 93 | + chrono::Local::now().to_rfc3339(), |
| 94 | + env!("APP_VERSION"), |
| 95 | + ); |
| 96 | + } |
| 97 | + } |
| 98 | + default_hook(info); |
| 99 | + })); |
| 100 | +} |
| 101 | + |
| 102 | +fn main() -> eframe::Result<()> { |
| 103 | + install_panic_logger(); |
| 104 | + |
| 105 | + let native_options = eframe::NativeOptions { |
| 106 | + viewport: egui::ViewportBuilder::default() |
| 107 | + .with_inner_size([1200.0, 800.0]) |
| 108 | + .with_min_inner_size([900.0, 560.0]) |
| 109 | + .with_title(APP_WINDOW_TITLE) |
| 110 | + .with_icon(Arc::new(load_icon())), |
| 111 | + ..Default::default() |
| 112 | + }; |
| 113 | + |
| 114 | + eframe::run_native( |
| 115 | + APP_NAME, |
| 116 | + native_options, |
| 117 | + Box::new(|cc| Ok(Box::new(app::TinyBoothApp::new(cc)))), |
| 118 | + ) |
| 119 | +} |
0 commit comments