diff --git a/demo_glium/Cargo.toml b/demo_glium/Cargo.toml index 83db19e9..2b0ab9d4 100644 --- a/demo_glium/Cargo.toml +++ b/demo_glium/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] #egui = { git = "https://github.com/emilk/emigui" } -egui = { path = "../egui", features = ["with_serde"] } +egui = { path = "../egui", features = ["serde"] } #egui_glium = { git = "https://github.com/emilk/emigui" } egui_glium = { path = "../egui_glium" } serde = { version = "1", features = ["derive"] } diff --git a/demo_web/Cargo.toml b/demo_web/Cargo.toml index abdfbd72..d69721e2 100644 --- a/demo_web/Cargo.toml +++ b/demo_web/Cargo.toml @@ -9,8 +9,8 @@ edition = "2018" crate-type = ["cdylib", "rlib"] [dependencies] -# egui = { git = "https://github.com/emilk/emigui", features = ["with_serde"] } -egui = { path = "../egui", features = ["with_serde"] } +# egui = { git = "https://github.com/emilk/emigui", features = ["serde"] } +egui = { path = "../egui", features = ["serde"] } # egui_web = { git = "https://github.com/emilk/emigui" } egui_web = { path = "../egui_web" } js-sys = "0.3" diff --git a/docs/demo_web.js b/docs/demo_web.js index bfd17ee9..7eadbfb0 100644 --- a/docs/demo_web.js +++ b/docs/demo_web.js @@ -212,12 +212,12 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } -function __wbg_adapter_24(arg0, arg1) { - wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h74e3475b1fcd9cd1(arg0, arg1); +function __wbg_adapter_24(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8ac16b787f5fa676(arg0, arg1, addHeapObject(arg2)); } -function __wbg_adapter_27(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8ac16b787f5fa676(arg0, arg1, addHeapObject(arg2)); +function __wbg_adapter_27(arg0, arg1) { + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf394391f07d20fc8(arg0, arg1); } function __wbg_adapter_30(arg0, arg1, arg2) { @@ -225,7 +225,7 @@ function __wbg_adapter_30(arg0, arg1, arg2) { } function __wbg_adapter_33(arg0, arg1) { - wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf394391f07d20fc8(arg0, arg1); + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h74e3475b1fcd9cd1(arg0, arg1); } function __wbg_adapter_36(arg0, arg1, arg2) { @@ -727,28 +727,28 @@ async function init(input) { var ret = wasm.memory; return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper366 = function(arg0, arg1, arg2) { - var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_24); + imports.wbg.__wbindgen_closure_wrapper363 = function(arg0, arg1, arg2) { + var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_30); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper364 = function(arg0, arg1, arg2) { - var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_36); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_closure_wrapper370 = function(arg0, arg1, arg2) { - var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_27); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_closure_wrapper361 = function(arg0, arg1, arg2) { + imports.wbg.__wbindgen_closure_wrapper367 = function(arg0, arg1, arg2) { var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_33); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper362 = function(arg0, arg1, arg2) { - var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_39); + var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_27); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper368 = function(arg0, arg1, arg2) { - var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_30); + imports.wbg.__wbindgen_closure_wrapper365 = function(arg0, arg1, arg2) { + var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_24); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper369 = function(arg0, arg1, arg2) { + var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_36); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper371 = function(arg0, arg1, arg2) { + var ret = makeMutClosure(arg0, arg1, 76, __wbg_adapter_39); return addHeapObject(ret); }; diff --git a/docs/demo_web_bg.wasm b/docs/demo_web_bg.wasm index fcc2693d..a86a7ade 100644 Binary files a/docs/demo_web_bg.wasm and b/docs/demo_web_bg.wasm differ diff --git a/egui/Cargo.toml b/egui/Cargo.toml index fa483c7b..ac877ac4 100644 --- a/egui/Cargo.toml +++ b/egui/Cargo.toml @@ -21,9 +21,6 @@ rusttype = "0.9" serde = { version = "1", features = ["derive"], optional = true } serde_json = { version = "1", optional = true } -[features] -with_serde = ["serde", "serde_json"] - [dev-dependencies] criterion = { version = "0.3", default-features = false } diff --git a/egui/src/app.rs b/egui/src/app.rs index c1889788..ee5d7887 100644 --- a/egui/src/app.rs +++ b/egui/src/app.rs @@ -63,14 +63,14 @@ pub trait Storage { fn set_string(&mut self, key: &str, value: String); } -#[cfg(feature = "with_serde")] +#[cfg(feature = "serde_json")] pub fn get_value(storage: &dyn Storage, key: &str) -> Option { storage .get_string(key) .and_then(|value| serde_json::from_str(value).ok()) } -#[cfg(feature = "with_serde")] +#[cfg(feature = "serde_json")] pub fn set_value(storage: &mut dyn Storage, key: &str, value: &T) { storage.set_string(key, serde_json::to_string(value).unwrap()); } diff --git a/egui/src/containers/area.rs b/egui/src/containers/area.rs index 99fe4966..c76a398b 100644 --- a/egui/src/containers/area.rs +++ b/egui/src/containers/area.rs @@ -8,7 +8,7 @@ use crate::*; /// State that is persisted between frames #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub(crate) struct State { /// Last known pos pub pos: Pos2, @@ -22,7 +22,7 @@ pub(crate) struct State { /// You can throw a moveable Area. It's fun. /// TODO: separate out moveable to container? - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] pub vel: Vec2, } diff --git a/egui/src/containers/collapsing_header.rs b/egui/src/containers/collapsing_header.rs index 5518ed82..88270d64 100644 --- a/egui/src/containers/collapsing_header.rs +++ b/egui/src/containers/collapsing_header.rs @@ -8,13 +8,13 @@ use crate::{ }; #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] pub(crate) struct State { open: bool, // Times are relative, and we don't want to continue animations anyway, hence `serde(skip)` - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] toggle_time: f64, /// Height of the region when open. Used for animations diff --git a/egui/src/containers/resize.rs b/egui/src/containers/resize.rs index fd6b3bd5..e82537af 100644 --- a/egui/src/containers/resize.rs +++ b/egui/src/containers/resize.rs @@ -1,7 +1,7 @@ use crate::*; #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", 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. diff --git a/egui/src/containers/scroll_area.rs b/egui/src/containers/scroll_area.rs index c63c1083..d8b4b4c3 100644 --- a/egui/src/containers/scroll_area.rs +++ b/egui/src/containers/scroll_area.rs @@ -1,8 +1,8 @@ use crate::*; #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", 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, @@ -11,7 +11,7 @@ pub(crate) struct State { // Times are relative, and we don't want to continue animations anyway, hence `serde(skip)` /// Used to animate the showing of the scroll bar - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] toggle_time: f64, } diff --git a/egui/src/demos/app.rs b/egui/src/demos/app.rs index 3ed52730..08f90de8 100644 --- a/egui/src/demos/app.rs +++ b/egui/src/demos/app.rs @@ -5,8 +5,8 @@ use crate::{app, color::*, containers::*, demos::FractalClock, paint::*, widgets // ---------------------------------------------------------------------------- #[derive(Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] pub struct DemoApp { previous_web_location_hash: String, open_windows: OpenWindows, @@ -144,7 +144,7 @@ impl app::App for DemoApp { self.ui(ui, web_location_hash); } - #[cfg(feature = "with_serde")] + #[cfg(feature = "serde_json")] fn on_exit(&mut self, storage: &mut dyn app::Storage) { app::set_value(storage, app::APP_KEY, self); } @@ -152,7 +152,7 @@ impl app::App for DemoApp { // ---------------------------------------------------------------------------- -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] struct OpenWindows { demo: bool, fractal_clock: bool, @@ -228,7 +228,7 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows) { // ---------------------------------------------------------------------------- /// Showcase some ui code -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct DemoWindow { num_columns: usize, @@ -343,8 +343,8 @@ impl DemoWindow { // ---------------------------------------------------------------------------- -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] struct Widgets { button_enabled: bool, count: usize, @@ -425,8 +425,8 @@ impl Widgets { // ---------------------------------------------------------------------------- -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] struct BoxPainting { size: Vec2, corner_radius: f32, @@ -476,8 +476,8 @@ impl BoxPainting { // ---------------------------------------------------------------------------- #[derive(Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] struct Painting { lines: Vec>, } @@ -536,8 +536,8 @@ impl Painting { use crate::layout::*; -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] struct LayoutDemo { dir: Direction, align: Option, // None == jusitifed @@ -623,7 +623,7 @@ enum Action { } #[derive(Clone, Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] struct Tree(Vec); impl Tree { diff --git a/egui/src/demos/fractal_clock.rs b/egui/src/demos/fractal_clock.rs index a88a1cae..2c8caa95 100644 --- a/egui/src/demos/fractal_clock.rs +++ b/egui/src/demos/fractal_clock.rs @@ -2,8 +2,8 @@ use std::sync::Arc; use crate::{containers::*, paint::PaintCmd, widgets::*, *}; -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] pub struct FractalClock { paused: bool, time: f64, diff --git a/egui/src/id.rs b/egui/src/id.rs index f1c58f68..c0ae75d4 100644 --- a/egui/src/id.rs +++ b/egui/src/id.rs @@ -28,7 +28,7 @@ use std::hash::Hash; /// Then there are widgets that need no identifiers at all, like labels, /// because they have no state nor are interacted with. #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Id(u64); impl Id { diff --git a/egui/src/layers.rs b/egui/src/layers.rs index 5f7838e7..5d6be6d1 100644 --- a/egui/src/layers.rs +++ b/egui/src/layers.rs @@ -4,7 +4,7 @@ use crate::{math::Rect, paint::PaintCmd, Id}; /// Different layer categories #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum Order { /// Painted behind all floating windows Background, @@ -19,7 +19,7 @@ pub enum 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 = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Layer { pub order: Order, pub id: Id, diff --git a/egui/src/layout.rs b/egui/src/layout.rs index f3c34b7c..7f240d73 100644 --- a/egui/src/layout.rs +++ b/egui/src/layout.rs @@ -4,8 +4,8 @@ use crate::{math::*, style::Style}; /// `Layout` direction (horizontal or vertical). #[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", 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 { Horizontal, Vertical, @@ -19,8 +19,8 @@ impl Default for Direction { /// left/center/right or top/center/bottom alignment for e.g. anchors and `Layout`s. #[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", 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 Align { /// Left/Top Min, @@ -59,7 +59,7 @@ pub(crate) fn anchor_rect(rect: Rect, anchor: (Align, Align)) -> Rect { /// The layout of a `Ui`, e.g. horizontal left-aligned. #[derive(Clone, Copy, Debug, PartialEq)] -// #[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Layout { /// Lay out things horizontally or vertically? dir: Direction, diff --git a/egui/src/math.rs b/egui/src/math.rs index a20a0d95..0e5d0971 100644 --- a/egui/src/math.rs +++ b/egui/src/math.rs @@ -6,7 +6,7 @@ use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, RangeInclusive, Sub, Su /// /// Normally given in points, e.g. logical pixels. #[derive(Clone, Copy, Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Vec2 { pub x: f32, pub y: f32, @@ -248,7 +248,7 @@ impl std::fmt::Debug for Vec2 { /// /// Normally given in points, e.g. logical pixels. #[derive(Clone, Copy, Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Pos2 { pub x: f32, pub y: f32, @@ -393,7 +393,7 @@ impl std::fmt::Debug for Pos2 { /// /// Normally given in points, e.g. logical pixels. #[derive(Clone, Copy, Default, Eq, PartialEq)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Rect { pub min: Pos2, pub max: Pos2, diff --git a/egui/src/memory.rs b/egui/src/memory.rs index 535efa32..d2db8e3c 100644 --- a/egui/src/memory.rs +++ b/egui/src/memory.rs @@ -12,10 +12,10 @@ use crate::{ /// /// If you want this to persist when closing your app you should serialize `Memory` and store it. #[derive(Clone, Debug, Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] pub struct Memory { - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] pub(crate) interaction: Interaction, // states of various types of widgets @@ -25,7 +25,7 @@ pub struct Memory { pub(crate) scroll_areas: HashMap, pub(crate) text_edit: HashMap, - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] pub(crate) window_interaction: Option, pub(crate) areas: Areas, @@ -87,8 +87,8 @@ impl Interaction { } #[derive(Clone, Debug, Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] -#[cfg_attr(feature = "with_serde", serde(default))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", serde(default))] pub struct Areas { areas: HashMap, /// Top is last diff --git a/egui/src/menu.rs b/egui/src/menu.rs index f344c870..82380b02 100644 --- a/egui/src/menu.rs +++ b/egui/src/menu.rs @@ -19,11 +19,11 @@ use crate::{widgets::*, *}; /// What is saved between frames. #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub(crate) struct BarState { - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] open_menu: Option, - #[cfg_attr(feature = "with_serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] /// When did we open a menu? open_time: f64, } diff --git a/egui/src/paint/color.rs b/egui/src/paint/color.rs index ed747bdc..d3788e8b 100644 --- a/egui/src/paint/color.rs +++ b/egui/src/paint/color.rs @@ -1,7 +1,7 @@ // TODO: rename `Color` to `sRGBA` for clarity. /// 0-255 `sRGBA`. Uses premultiplied alpha. #[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Color { pub r: u8, pub g: u8, diff --git a/egui/src/paint/command.rs b/egui/src/paint/command.rs index 63042a44..420cf799 100644 --- a/egui/src/paint/command.rs +++ b/egui/src/paint/command.rs @@ -69,7 +69,7 @@ impl PaintCmd { } #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct LineStyle { pub width: f32, pub color: Color, diff --git a/egui/src/paint/fonts.rs b/egui/src/paint/fonts.rs index c1b5f8e3..174fd605 100644 --- a/egui/src/paint/fonts.rs +++ b/egui/src/paint/fonts.rs @@ -13,7 +13,7 @@ use super::{ // TODO: rename #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -// #[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum TextStyle { Body, Button, @@ -22,7 +22,7 @@ pub enum TextStyle { } #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -// #[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum FontFamily { Monospace, VariableWidth, diff --git a/egui/src/style.rs b/egui/src/style.rs index 10dba49c..6876c208 100644 --- a/egui/src/style.rs +++ b/egui/src/style.rs @@ -5,7 +5,7 @@ use crate::{color::*, math::*, paint::LineStyle, types::*}; // TODO: split into Spacing and Style? /// Specifies the look and feel of a `Ui`. #[derive(Clone, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Style { /// Horizontal and vertical padding within a window frame. pub window_padding: Vec2, @@ -101,7 +101,7 @@ impl Default for Style { } #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Interact { pub active: WidgetStyle, pub hovered: WidgetStyle, @@ -163,7 +163,7 @@ impl Interact { } #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct WidgetStyle { /// Background color of widget pub bg_fill: Option, @@ -187,7 +187,7 @@ pub struct WidgetStyle { } #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Window { pub corner_radius: f32, } @@ -201,7 +201,7 @@ impl Default for Window { } #[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct MenuBar { pub height: f32, } diff --git a/egui/src/types.rs b/egui/src/types.rs index 20a3afc1..82a49d21 100644 --- a/egui/src/types.rs +++ b/egui/src/types.rs @@ -7,7 +7,7 @@ use crate::{math::Rect, Context, Ui}; /// What Egui emits each frame. /// The backend should use this. #[derive(Clone, Default)] -// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))] +// #[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Output { /// Set the cursor to this icon. pub cursor_icon: CursorIcon, @@ -25,8 +25,8 @@ pub struct Output { } #[derive(Clone, Copy)] -// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))] -// #[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))] +// #[cfg_attr(feature = "serde", derive(serde::Serialize))] +// #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum CursorIcon { Default, /// Pointing hand, used for e.g. web links @@ -50,7 +50,7 @@ impl Default for CursorIcon { /// /// For instance, this lets you know whether or not a widget has been clicked this frame. #[derive(Clone, Copy, Debug)] -// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))] +// #[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InteractInfo { /// The senses (click or drag) that the widget is interested in (if any). pub sense: Sense, @@ -165,7 +165,7 @@ impl Into for GuiResponse { /// What sort of interaction is a widget sensitive to? #[derive(Clone, Copy, Debug, Eq, PartialEq)] -// #[cfg_attr(feature = "with_serde", derive(serde::Serialize))] +// #[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Sense { /// buttons, sliders, windows ... pub click: bool, diff --git a/egui/src/widgets/text_edit.rs b/egui/src/widgets/text_edit.rs index 6e61af8f..70c7abf3 100644 --- a/egui/src/widgets/text_edit.rs +++ b/egui/src/widgets/text_edit.rs @@ -1,7 +1,7 @@ use crate::{paint::*, *}; #[derive(Clone, Copy, Debug, Default)] -#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub(crate) struct State { /// Charctaer based, NOT bytes. /// TODO: store as line + row diff --git a/egui_glium/Cargo.toml b/egui_glium/Cargo.toml index c959a34f..14e8a94e 100644 --- a/egui_glium/Cargo.toml +++ b/egui_glium/Cargo.toml @@ -14,7 +14,7 @@ include = [ "**/*.rs", "Cargo.toml"] [dependencies] chrono = { version = "0.4" } clipboard = "0.5" -egui = { version = "0.1.3", path = "../egui", features = ["with_serde"] } +egui = { version = "0.1.3", path = "../egui", features = ["serde", "serde_json"] } glium = "0.27" serde = "1" serde_json = "1" diff --git a/egui_web/Cargo.toml b/egui_web/Cargo.toml index 66c01ccc..413182b4 100644 --- a/egui_web/Cargo.toml +++ b/egui_web/Cargo.toml @@ -15,7 +15,7 @@ include = [ "**/*.rs", "Cargo.toml"] crate-type = ["cdylib", "rlib"] [dependencies] -egui = { version = "0.1.3", path = "../egui", features = ["with_serde"] } +egui = { version = "0.1.3", path = "../egui", features = ["serde"] } js-sys = "0.3" parking_lot = "0.11" serde = "1"