Skip to content
Snippets Groups Projects

Implemented basic layout persistance

Merged Alberto Nidasio requested to merge layout-persistance into master

Addresses #5 (closed).

Requirements

  • R04: It MUST allow exporting and importing layout configurations in a serialized format: the entire layout must be serializable to a file (in JSON, XML, YAML, or any other format) to save, manage and load different configurations without needing to reset the system each time.
  • R04.1: The serialization format SHOULD be easily interpreted by a human (human-friendly).
  • R04.2: The serialization format SHOULD be uniquely tied to the Layout, in a declarative manner (the layout can be expressed and composed directly by using this format).

Implementation details

Serialization Format

JSON is used as the serialization format. The Tiles struct from egui_tiles uses a hash map with integers as keys, this limits the usable formats (e.g. TOML does not support integer keys in maps).

Layout File Handling

The system-dependent path for storing layouts is derived using eframe::storage_dir(app_id: &str):

  • Linux: /home/UserName/.local/share/APP_ID/layouts
  • macOS: /Users/UserName/Library/Application Support/APP_ID/layouts
  • Windows: C:\Users\UserName\AppData\Roaming\APP_ID\data\layouts

Ui

The layouts folder is scanned when the layout manager opens, and each file is loaded into a BTreeMap, ensuring keys are ordered (otherwise the layouts could change order in the ui seemingly at random). File names are used as keys. Layouts are displayed in a UI list where users can:

  • Select a layout by clicking on its name.
  • Load the selected layout.
  • Load an empty layout.
  • If the current displayed layout is different from the selected one, save it with a new name.
  • Import a layout by selecting a file. It is then copies into the layouts folder and displayed in the ui.

Layouts are compared using the PartialEq trait.

If the layout manager is open, the directory is rescanned at every ui redraw, and new files are loaded.

Known issues

  • Live Reload: Layout changes made outside the app while it’s running are not reflected.
  • Colors: Selected layout color indicators need improvement.
  • Save Behavior: If a different layout is selected but not loaded, closing the app save the selected layout instead of the loaded one.
  • Unsaved Changes: No warnings are displayed if the user opens a new layout with unsaved changes.
  • Persistency on web: If we ever compile for web, saving layouts into files will probably not work.
Edited by Alberto Nidasio

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading