mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Add separate serialize feature and better persitence control (#753)
* Rename epaint feature "persistence" to "serialize" * Add separate "serialize" feature to egui * egui_demo_lib: separate serialize and persistence features * Add App::persist_native_window and App::persist_egui_memory Controls what gets persisted
This commit is contained in:
@@ -94,7 +94,7 @@ pub trait App {
|
||||
/// Allows you to do setup code, e.g to call `[egui::Context::set_fonts]`,
|
||||
/// `[egui::Context::set_visuals]` etc.
|
||||
///
|
||||
/// Also allows you to restore state, if there is a storage.
|
||||
/// Also allows you to restore state, if there is a storage (required the "persistence" feature).
|
||||
fn setup(
|
||||
&mut self,
|
||||
_ctx: &egui::CtxRef,
|
||||
@@ -113,6 +113,8 @@ pub trait App {
|
||||
|
||||
/// Called on shutdown, and perhaps at regular intervals. Allows you to save state.
|
||||
///
|
||||
/// Only called when the "persistence" feature is enabled.
|
||||
///
|
||||
/// On web the states is stored to "Local Storage".
|
||||
/// On native the path is picked using [`directories_next::ProjectDirs::data_dir`](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir) which is:
|
||||
/// * Linux: `/home/UserName/.local/share/APPNAME`
|
||||
@@ -150,6 +152,18 @@ pub trait App {
|
||||
// `transparent()` option they get immediate results.
|
||||
egui::Color32::from_rgba_unmultiplied(12, 12, 12, 180).into()
|
||||
}
|
||||
|
||||
/// Controls wether or not the native window position and size will be
|
||||
/// persisted (only if the "persistence" feature is enabled).
|
||||
fn persist_native_window(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Controls wether or not the egui memory (window positions etc) will be
|
||||
/// persisted (only if the "persistence" feature is enabled).
|
||||
fn persist_egui_memory(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// Options controlling the behavior of a native window
|
||||
|
||||
Reference in New Issue
Block a user