| 15 | Medium, |
| 16 | Large, |
| 17 | ExtraLarge, |
| 18 | } |
| 19 | |
| 20 | impl ZoomLevel { |
| 21 | pub(crate) const ALL: [Self; 4] = [Self::Small, Self::Medium, Self::Large, Self::ExtraLarge]; |
| 22 | |
| 23 | pub(crate) fn factor(self) -> f32 { |
| 24 | match self { |
| 25 | Self::Small => 0.9, |
| 26 | Self::Medium => 1.0, |
| 27 | Self::Large => 1.15, |
| 28 | Self::ExtraLarge => 1.3, |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | pub(crate) fn label(self) -> &'static str { |
| 33 | match self { |
| 34 | Self::Small => "S", |
| 35 | Self::Medium => "M", |
| 36 | Self::Large => "L", |
| 37 | Self::ExtraLarge => "XL", |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | // Matches egui's default Monospace size so a fresh profile renders identically. |
| 43 | pub(crate) const DEFAULT_MONO_SIZE: f32 = 12.0; |
| 44 | |
| 45 | const SETTINGS_MAX_WIDTH: f32 = 620.0; |
| 46 | const SETTINGS_INSET_X: f32 = 28.0; |
| 47 | |
| 48 | // Every field is #[serde(default)] so older and newer profiles load forward-compatibly. |
| 49 | #[derive(Serialize, Deserialize, Clone, PartialEq, Debug)] |
| 50 | #[serde(default)] |
| 51 | pub(crate) struct AppSettings { |
| 52 | // Appearance |
| 53 | pub(crate) ui_zoom: ZoomLevel, |
| 54 | pub(crate) editor_font_size: f32, |
| 55 | pub(crate) current_line_highlight: bool, |
| 56 | // Editor |
| 57 | pub(crate) check_on_save: bool, |
| 58 | pub(crate) check_on_idle: bool, |
| 59 | pub(crate) save_all_before_run: bool, |
| 60 | pub(crate) confirm_discard_on_close: bool, |
| 61 | // Terminal |
| 62 | pub(crate) open_terminal_on_run: bool, |
| 63 | pub(crate) focus_machine_console_on_run: bool, |
| 64 | // Machine / debugger |
| 65 | pub(crate) default_steps_per_frame: u64, |
| 66 | pub(crate) frame_budget_ms: u64, |
| 67 | pub(crate) restart_reuses_build: bool, |
| 68 | pub(crate) persist_breakpoints: bool, |
| 69 | // Startup (native only) |
| 70 | pub(crate) reopen_last_workspace: bool, |
| 71 | pub(crate) last_workspace: Option<String>, |
| 72 | } |
| 73 | |
| 74 | impl Default for AppSettings { |