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:
+7
-3
@@ -30,6 +30,9 @@ ron = { version = "0.6.4", optional = true }
|
||||
[features]
|
||||
default = ["default_fonts", "single_threaded"]
|
||||
|
||||
# add compatibility with https://crates.io/crates/cint
|
||||
cint = ["epaint/cint"]
|
||||
|
||||
# If set, egui will use `include_bytes!` to bundle some fonts.
|
||||
# If you plan on specifying your own fonts you may disable this feature.
|
||||
default_fonts = ["epaint/default_fonts"]
|
||||
@@ -42,10 +45,11 @@ extra_asserts = ["epaint/extra_asserts"]
|
||||
# Add compatability with https://github.com/kvark/mint
|
||||
mint = ["epaint/mint"]
|
||||
|
||||
# add compatibility with https://crates.io/crates/cint
|
||||
cint = ["epaint/cint"]
|
||||
# enable persistence of memory (window positions etc).
|
||||
persistence = ["serde", "epaint/serialize", "ron"]
|
||||
|
||||
persistence = ["serde", "epaint/persistence", "ron"]
|
||||
# implement serde on most types.
|
||||
serialize = ["serde", "epaint/serialize"]
|
||||
|
||||
# multi_threaded is only needed if you plan to use the same egui::Context
|
||||
# from multiple threads. It comes with a minor performance impact.
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::any::Any;
|
||||
|
||||
/// We need this because `TypeId` can't be deserialized or serialized directly, but this can be done using hashing. However, there is a small possibility that different types will have intersection by hashes of their type ids.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct TypeId(u64);
|
||||
|
||||
impl TypeId {
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::*;
|
||||
|
||||
/// State that is persisted between frames
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct State {
|
||||
/// Last known pos
|
||||
pub pos: Pos2,
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::{widgets::Label, *};
|
||||
use epaint::{Shape, TextStyle};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub(crate) struct State {
|
||||
open: bool,
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::ops::RangeInclusive;
|
||||
use crate::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
struct PanelState {
|
||||
rect: Rect,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct State {
|
||||
/// This is the size that the user has picked by dragging the resize handles.
|
||||
/// This may be smaller and/or larger than the actual size.
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
use crate::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub(crate) struct State {
|
||||
/// Positive offset means scrolling down/right
|
||||
offset: Vec2,
|
||||
@@ -17,7 +17,7 @@ pub(crate) struct State {
|
||||
show_scroll: [bool; 2],
|
||||
|
||||
/// Momentum, used for kinetic scrolling
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
pub vel: Vec2,
|
||||
|
||||
/// Mouse offset relative to the top of the handle when started moving the handle.
|
||||
|
||||
+10
-10
@@ -11,7 +11,7 @@ use crate::emath::*;
|
||||
///
|
||||
/// All coordinates are in points (logical pixels) with origin (0, 0) in the top left corner.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct RawInput {
|
||||
/// How many points (logical pixels) the user scrolled
|
||||
pub scroll_delta: Vec2,
|
||||
@@ -132,7 +132,7 @@ impl RawInput {
|
||||
|
||||
/// A file about to be dropped into egui.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct HoveredFile {
|
||||
/// Set by the `egui-winit` backend.
|
||||
pub path: Option<std::path::PathBuf>,
|
||||
@@ -142,7 +142,7 @@ pub struct HoveredFile {
|
||||
|
||||
/// A file dropped into egui.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct DroppedFile {
|
||||
/// Set by the `egui-winit` backend.
|
||||
pub path: Option<std::path::PathBuf>,
|
||||
@@ -158,7 +158,7 @@ pub struct DroppedFile {
|
||||
///
|
||||
/// This only covers events that egui cares about.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum Event {
|
||||
/// The integration detected a "copy" event (e.g. Cmd+C).
|
||||
Copy,
|
||||
@@ -217,7 +217,7 @@ pub enum Event {
|
||||
|
||||
/// Mouse button (or similar for touch input)
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum PointerButton {
|
||||
/// The primary mouse button is usually the left one.
|
||||
Primary = 0,
|
||||
@@ -233,7 +233,7 @@ pub const NUM_POINTER_BUTTONS: usize = 3;
|
||||
|
||||
/// State of the modifier keys. These must be fed to egui.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Modifiers {
|
||||
/// Either of the alt keys are down (option ⌥ on Mac).
|
||||
pub alt: bool,
|
||||
@@ -276,7 +276,7 @@ impl Modifiers {
|
||||
/// Many keys are omitted because they are not always physical keys (depending on keyboard language), e.g. `;` and `§`,
|
||||
/// and are therefor unsuitable as keyboard shortcuts if you want your app to be portable.
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum Key {
|
||||
ArrowDown,
|
||||
ArrowLeft,
|
||||
@@ -383,19 +383,19 @@ impl RawInput {
|
||||
|
||||
/// this is a `u64` as values of this kind can always be obtained by hashing
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct TouchDeviceId(pub u64);
|
||||
|
||||
/// Unique identification of a touch occurrence (finger or pen or ...).
|
||||
/// A Touch ID is valid until the finger is lifted.
|
||||
/// A new ID is used for the next touch.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct TouchId(pub u64);
|
||||
|
||||
/// In what phase a touch event is in.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum TouchPhase {
|
||||
/// User just placed a touch point on the touch surface
|
||||
Start,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::WidgetType;
|
||||
/// What egui emits each frame.
|
||||
/// The backend should use this.
|
||||
#[derive(Clone, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Output {
|
||||
/// Set the cursor to this icon.
|
||||
pub cursor_icon: CursorIcon,
|
||||
@@ -89,7 +89,7 @@ impl Output {
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct OpenUrl {
|
||||
pub url: String,
|
||||
/// If `true`, open the url in a new tab.
|
||||
@@ -122,7 +122,7 @@ impl OpenUrl {
|
||||
///
|
||||
/// Loosely based on <https://developer.mozilla.org/en-US/docs/Web/CSS/cursor>.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum CursorIcon {
|
||||
/// Normal cursor icon, whatever that is.
|
||||
Default,
|
||||
@@ -244,7 +244,7 @@ impl Default for CursorIcon {
|
||||
///
|
||||
/// In particular, these events may be useful for accessability, i.e. for screen readers.
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum OutputEvent {
|
||||
// A widget was clicked.
|
||||
Clicked(WidgetInfo),
|
||||
@@ -272,7 +272,7 @@ impl std::fmt::Debug for OutputEvent {
|
||||
|
||||
/// Describes a widget such as a [`crate::Button`] or a [`crate::TextEdit`].
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct WidgetInfo {
|
||||
/// The type of widget this is.
|
||||
pub typ: WidgetType,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
use crate::*;
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct State {
|
||||
col_widths: Vec<f32>,
|
||||
row_heights: Vec<f32>,
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
/// Then there are widgets that need no identifiers at all, like labels,
|
||||
/// because they have no state nor are interacted with.
|
||||
#[derive(Clone, Copy, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Id(u64);
|
||||
|
||||
impl Id {
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ use std::sync::Arc;
|
||||
|
||||
/// Different layer categories
|
||||
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum Order {
|
||||
/// Painted behind all floating windows
|
||||
Background,
|
||||
@@ -65,7 +65,7 @@ impl Order {
|
||||
/// An identifier for a paint layer.
|
||||
/// Also acts as an identifier for [`Area`]:s.
|
||||
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct LayerId {
|
||||
pub order: Order,
|
||||
pub id: Id,
|
||||
|
||||
+3
-3
@@ -76,8 +76,8 @@ impl Region {
|
||||
|
||||
/// Layout direction, one of `LeftToRight`, `RightToLeft`, `TopDown`, `BottomUp`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(rename_all = "snake_case"))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||
pub enum Direction {
|
||||
LeftToRight,
|
||||
RightToLeft,
|
||||
@@ -115,7 +115,7 @@ impl Direction {
|
||||
/// });
|
||||
/// ```
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
// #[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Layout {
|
||||
/// Main axis direction
|
||||
main_dir: Direction,
|
||||
|
||||
+1
-1
@@ -527,7 +527,7 @@ pub mod special_emojis {
|
||||
|
||||
/// The different types of built-in widgets in egui
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum WidgetType {
|
||||
Label, // TODO: emit Label events
|
||||
Hyperlink,
|
||||
|
||||
+12
-12
@@ -14,8 +14,8 @@ use crate::{any, area, window, Id, InputState, LayerId, Pos2, Rect, Style};
|
||||
/// If you want to store data for your widgets, you should look at `data`/`data_temp` and
|
||||
/// `id_data`/`id_data_temp` fields, and read the documentation of [`any`] module.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Memory {
|
||||
pub options: Options,
|
||||
|
||||
@@ -53,23 +53,23 @@ pub struct Memory {
|
||||
/// new fonts that will be applied at the start of the next frame
|
||||
pub(crate) new_font_definitions: Option<epaint::text::FontDefinitions>,
|
||||
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
pub(crate) interaction: Interaction,
|
||||
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
pub(crate) window_interaction: Option<window::WindowInteraction>,
|
||||
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
pub(crate) drag_value: crate::widgets::drag_value::MonoState,
|
||||
|
||||
pub(crate) areas: Areas,
|
||||
|
||||
/// Which popup-window is open (if any)?
|
||||
/// Could be a combo box, color picker, menu etc.
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
popup: Option<Id>,
|
||||
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
everything_is_visible: bool,
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ pub struct Memory {
|
||||
|
||||
/// Some global options that you can read and write.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Options {
|
||||
/// The default style for new `Ui`:s.
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
pub(crate) style: std::sync::Arc<Style>,
|
||||
|
||||
/// Controls the tessellator.
|
||||
@@ -432,8 +432,8 @@ impl Memory {
|
||||
/// Keeps track of `Area`s, which are free-floating `Ui`s.
|
||||
/// These `Area`s can be in any `Order`.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Areas {
|
||||
areas: HashMap<Id, area::State>,
|
||||
/// Back-to-front. Top is last.
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ use epaint::Stroke;
|
||||
|
||||
/// What is saved between frames.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub(crate) struct BarState {
|
||||
open_menu: Option<Id>,
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/// What sort of interaction is a widget sensitive to?
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
// #[cfg_attr(feature = "persistence", derive(serde::Serialize))]
|
||||
// #[cfg_attr(feature = "serde", derive(serde::Serialize))]
|
||||
pub struct Sense {
|
||||
/// buttons, sliders, windows ...
|
||||
pub click: bool,
|
||||
|
||||
+14
-14
@@ -12,8 +12,8 @@ use epaint::{Shadow, Stroke, TextStyle};
|
||||
///
|
||||
/// If you want to change fonts, use [`crate::Context::set_fonts`] instead.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Style {
|
||||
/// Default `TextStyle` for normal text (i.e. for `Label` and `TextEdit`).
|
||||
pub body_text_style: TextStyle,
|
||||
@@ -81,8 +81,8 @@ impl Style {
|
||||
|
||||
/// Controls the sizes and distances between widgets.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Spacing {
|
||||
/// Horizontal and vertical spacing between widgets.
|
||||
///
|
||||
@@ -151,8 +151,8 @@ impl Spacing {
|
||||
|
||||
/// How and when interaction happens.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Interaction {
|
||||
/// Mouse must be the close to the side of a window to resize
|
||||
pub resize_grab_radius_side: f32,
|
||||
@@ -171,8 +171,8 @@ pub struct Interaction {
|
||||
///
|
||||
/// If you want to change fonts, use [`crate::Context::set_fonts`] instead.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Visuals {
|
||||
/// If true, the visuals are overall dark with light text.
|
||||
/// If false, the visuals are overall light with dark text.
|
||||
@@ -270,8 +270,8 @@ impl Visuals {
|
||||
|
||||
/// Selected text, selected elements etc
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Selection {
|
||||
pub bg_fill: Color32,
|
||||
pub stroke: Stroke,
|
||||
@@ -279,8 +279,8 @@ pub struct Selection {
|
||||
|
||||
/// The visuals of widgets for different states of interaction.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Widgets {
|
||||
/// The style of a widget that you cannot interact with.
|
||||
/// * `noninteractive.bg_stroke` is the outline of windows.
|
||||
@@ -313,7 +313,7 @@ impl Widgets {
|
||||
|
||||
/// bg = background, fg = foreground.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct WidgetVisuals {
|
||||
/// Background color of widget.
|
||||
pub bg_fill: Color32,
|
||||
@@ -342,7 +342,7 @@ impl WidgetVisuals {
|
||||
|
||||
/// Options for help debug egui by adding extra visualization
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct DebugOptions {
|
||||
/// However over widgets to see their rectangles
|
||||
pub debug_on_hover: bool,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Settings {
|
||||
/// Maximum number of undos.
|
||||
/// If your state is resource intensive, you should keep this low.
|
||||
@@ -48,7 +48,7 @@ impl Default for Settings {
|
||||
/// Rule 1) will make sure an undo point is not created until you _stop_ dragging that slider.
|
||||
/// Rule 2) will make sure that you will get some undo points even if you are constantly changing the state.
|
||||
#[derive(Clone, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Undoer<State> {
|
||||
settings: Settings,
|
||||
|
||||
@@ -57,7 +57,7 @@ pub struct Undoer<State> {
|
||||
/// The latest undo point may (often) be the current state.
|
||||
undos: VecDeque<State>,
|
||||
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
flux: Option<Flux<State>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use color::Hsva;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// Information about the plot that has to persist between frames.
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[derive(Clone)]
|
||||
struct PlotMemory {
|
||||
bounds: Bounds,
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::*;
|
||||
/// 2D bounding box of f64 precision.
|
||||
/// The range of data values we show.
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct Bounds {
|
||||
pub min: [f64; 2],
|
||||
pub max: [f64; 2],
|
||||
|
||||
@@ -4,25 +4,25 @@ use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub(crate) struct State {
|
||||
cursorp: Option<CursorPair>,
|
||||
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
undoer: Undoer<(CCursorPair, String)>,
|
||||
|
||||
// If IME candidate window is shown on this text edit.
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
has_ime: bool,
|
||||
|
||||
// Visual offset when editing singleline text bigger than the width.
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
singleline_offset: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct CursorPair {
|
||||
/// When selecting with a mouse, this is where the mouse was released.
|
||||
/// When moving with e.g. shift+arrows, this is what moves.
|
||||
@@ -86,7 +86,7 @@ impl CursorPair {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
struct CCursorPair {
|
||||
/// When selecting with a mouse, this is where the mouse was released.
|
||||
/// When moving with e.g. shift+arrows, this is what moves.
|
||||
|
||||
Reference in New Issue
Block a user