1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 15:13:12 -04:00
Files
egui/crates/egui_plot/src/memory.rs
Emil Ernerfeldt 7b169ec13d Break out plotting to own crate egui_plot (#3282)
This replaces `egui::plot` with the new crate `egui_plot`
2023-08-27 17:22:49 +02:00

34 lines
1.0 KiB
Rust

use epaint::Pos2;
use crate::{Context, Id};
use super::{transform::ScreenTransform, AxisBools};
/// Information about the plot that has to persist between frames.
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Clone)]
pub(super) struct PlotMemory {
/// Indicates if the user has modified the bounds, for example by moving or zooming,
/// or if the bounds should be calculated based by included point or auto bounds.
pub(super) bounds_modified: AxisBools,
pub(super) hovered_entry: Option<String>,
pub(super) hidden_items: ahash::HashSet<String>,
pub(super) last_screen_transform: ScreenTransform,
/// Allows to remember the first click position when performing a boxed zoom
pub(super) last_click_pos_for_zoom: Option<Pos2>,
}
impl PlotMemory {
pub fn load(ctx: &Context, id: Id) -> Option<Self> {
ctx.data().get_persisted(id)
}
pub fn store(self, ctx: &Context, id: Id) {
ctx.data().insert_persisted(id, self);
}
}