1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 12:50:04 -04:00

Add eframe::storage_dir (#3286)

* Add `eframe::storage_dir`

Now you can easily tell where eframe stores its state

* egui_plot: work even without the `serde` featur flag
This commit is contained in:
Emil Ernerfeldt
2023-08-29 15:22:07 +02:00
committed by GitHub
parent a59eda7a27
commit 70bfc7e09f
5 changed files with 38 additions and 16 deletions

View File

@@ -126,6 +126,7 @@ struct PlotMemory {
last_click_pos_for_zoom: Option<Pos2>,
}
#[cfg(feature = "serde")]
impl PlotMemory {
pub fn load(ctx: &Context, id: Id) -> Option<Self> {
ctx.data_mut(|d| d.get_persisted(id))
@@ -136,6 +137,17 @@ impl PlotMemory {
}
}
#[cfg(not(feature = "serde"))]
impl PlotMemory {
pub fn load(ctx: &Context, id: Id) -> Option<Self> {
ctx.data_mut(|d| d.get_temp(id))
}
pub fn store(self, ctx: &Context, id: Id) {
ctx.data_mut(|d| d.insert_temp(id, self));
}
}
// ----------------------------------------------------------------------------
/// Indicates a vertical or horizontal cursor line in plot coordinates.