8.4 KiB
Midra Layout application settings, version 6
Implementation: crates/midra-layout/src/settings.rs. This per-user JSON file is
independent of the project JSON and SVG contracts.
Complete default example.
Version 1 files migrate automatically: the saved theme becomes the only entry in
recent_themes, with all other preferences preserved. The version 1 example
remains a migration fixture. Version 2 files then migrate by adding disabled
snapping with all target types enabled. The version 2 example
remains a migration fixture too. Version 3 files migrate by adding an empty midra_host; the version 3 example remains a migration fixture. Version 4 files migrate by adding allow_sending_to_program: false; the version 4 example remains a migration fixture. Version 5 files migrate with autoconnect_at_startup: false; the version 5 example remains a migration fixture. Saving writes version 6; old applications reject it.
The directories 6 crate resolves ProjectDirs::from("org", "beffroi", "midra-layout").
The filename is settings.json beneath config_dir():
| Platform | Location |
|---|---|
| Linux | $XDG_CONFIG_HOME/midra-layout/settings.json, otherwise ~/.config/midra-layout/settings.json |
| Windows | %APPDATA%\beffroi\midra-layout\config\settings.json (Roaming AppData) |
| macOS | ~/Library/Application Support/org.beffroi.midra-layout/settings.json |
UTF-8, pretty-printed JSON with a trailing newline; maximum input size 64 KiB. Every field is required, unknown fields are rejected, and unknown versions or unknown theme names are rejected. There are no numeric coordinates or units.
| Field | Values / default |
|---|---|
version |
Integer 6 |
autoconnect_at_startup |
Boolean; default false. Try one background connection at application startup if the saved address is nonblank. |
allow_sending_to_program |
Boolean; default false. Enables the Program destination in the exporter. Turning it off restores Preview; applies to quick Apply too. |
midra_host |
Device IP address text; default "". Saved as typed, including incomplete drafts; validated when connecting. |
theme |
Theme ID from the catalog below; default "midra" |
recent_themes |
1–3 unique theme IDs, newest first; first must equal theme; default ["midra"] |
show_toolbar_icon_names |
Boolean; default false |
keep_aspect_ratio |
Boolean; default true |
show_source_pattern |
Boolean; default false |
snapping |
Object with required boolean fields enabled (false), pixels (true), screen_edges (true), layer_edges (true); unknown fields rejected |
Loaded once at startup before the editor appears. Explicit Options changes save the current preferences and theme history immediately. The directory is created lazily; missing files do not trigger a write until the user changes an option. Writes use a temporary file in the same directory, file sync and atomic replacement. Multiple application instances use last-successful-write wins; no merging or live reloading is performed. Selecting a theme moves it to the front, removes any previous occurrence, and trims the list to three. Starting the app does not reorder the restored history. Opening or dismissing the full picker changes nothing.
Project JSON v1/v2 remains unchanged. Opening a project can restore its embedded caption, aspect-ratio and source-preview preferences for that document; it never writes application settings. Theme remains global. Editing an option afterward saves all currently active preferences as the next startup defaults. Snapping remains an application preference and is not read from or written into project JSON.
Invalid/unreadable settings fall back to defaults, report the failure in Options, and disable writes for that run to preserve the original file. Repair/move the file and restart to recover. A write failure retains in-memory preferences and the previous destination where atomic publication failed; Options offers a retry. Failure to locate a configuration directory also disables persistence with an Options error. Tests use temporary directories and never touch user settings.
The device address is saved immediately when edited in Midra connection…. Startup attempts a read-only connection only when autoconnect_at_startup is enabled and the saved address is nonblank. It never sends layer settings. Opening a project preserves the current connection and address, clears import choices, and loads the project’s saved layer destination links. Connection status and snapshots are not persisted. Layer destination links are saved in project JSON, not application settings. Restore default preferences disables autoconnect and leaves the connection address unchanged; edit it in the connection window.
No layer geometry, source crops, camera state, project paths, image bytes or clipboard contents are stored. No settings are exported to SVG. Breaking or additive schema changes under this strict contract require a version bump, updated documentation/examples/tests, and either an explicit migration or an actionable unsupported-version error.
Bundled theme catalog
All 18 CSS themes in SOTV_Websites/sotv/song_database/styles/themes/ are
represented, alongside Midra Dark. Palettes are bundled in src/theme.rs:
no sibling checkout or CSS interpreter is required at build or runtime. Corporate
uses the website's base defaults. The existing three palettes retain their
hand-tuned viewport colors; other palettes map body/panel/sidebar/tab surfaces,
main/subtle text, button accent and border tokens into the editor. Action fills
blend accent and panel; light-theme text/accent colors are darkened for contrast.
The picker includes both light and dark themes with color swatches.
| Theme | Settings ID | Source CSS |
|---|---|---|
| Midra Dark | midra |
Original editor palette |
| Corporate Light | corporate_light |
theme-corporate.css and ../base/variables.css |
| Foxified Dark | foxified_dark |
theme-foxified-dark.css |
| Bluecore | bluecore |
theme-bluecore.css |
| Dupont Monsanto | dupont_monsanto |
theme-dupont-monsanto.css |
| Eden Green | eden_green |
theme-eden-green.css |
| Foxified Light | foxified_light |
theme-foxified-light.css |
| HCI | hci |
theme-hci.css |
| Iron Docks | iron_docks |
theme-iron-docks.css |
| Peaceframe | peaceframe |
theme-peaceframe.css |
| Rebel | rebel |
theme-rebel.css |
| Sirius Mind | sirius_mind |
theme-sirius-mind.css |
| Solarized | solarized |
theme-solarized.css |
| Sons Of Banard | sons_of_banard |
theme-sons-of-banard.css |
| Storm Pilot | storm_pilot |
theme-storm-pilot.css |
| Tessier Ashpol | tessier_ashpol |
theme-tessier-ashpol.css |
| USTF | ustf |
theme-ustf.css |
| Verdant Rebel | verdant_rebel |
theme-verdant-rebel.css |
| Weicat Industrial | weicat_industrial |
theme-weicat-industrial.css |
The Preferences window and quick menus share the same settings. Changes apply and save immediately; closing the window requires no Apply step. Restore default preferences resets appearance and editing values, including theme history and snapping, without changing layer geometry or pending position/size text fields. Snapping uses a fixed six-logical-pixel proximity radius converted by viewport scale. It affects layer movement and resize handles; numeric entry, nudges and crop-content gestures bypass it. Resize snapping preserves anchors and proportions and shows guides only when the resulting edge actually reaches its target. Shift temporarily inverts snapping during layer resizing, including release, without changing the saved option. Alt temporarily disables it and takes precedence over Shift.
Preferences → Midra integration → Allow sending to Program saves immediately. Restore default preferences disables it. Projects do not override this application preference; the Preview/Program destination itself remains session-only.
Try autoconnecting at startup is in Preferences → Midra integration. It saves immediately but applies on the next launch; toggling it does not initiate a connection. One background attempt uses the regular connection timeout and error handling, with no automatic retry loop. Failures leave the app offline and are reported in Midra connection. Project loading does not trigger an attempt.