Browse Source

[egui] make serde an optional dependency

pull/3/head
Emil Ernerfeldt 5 years ago
parent
commit
b80baf4039
  1. 6
      Cargo.lock
  2. 6
      egui/Cargo.toml
  3. 5
      egui/src/containers/area.rs
  4. 14
      egui/src/containers/collapsing_header.rs
  5. 7
      egui/src/containers/menu.rs
  6. 3
      egui/src/containers/resize.rs
  7. 5
      egui/src/containers/scroll_area.rs
  8. 31
      egui/src/examples/app.rs
  9. 6
      egui/src/examples/fractal_clock.rs
  10. 5
      egui/src/id.rs
  11. 17
      egui/src/input.rs
  12. 7
      egui/src/layers.rs
  13. 15
      egui/src/layout.rs
  14. 11
      egui/src/math.rs
  15. 16
      egui/src/memory.rs
  16. 5
      egui/src/paint/color.rs
  17. 5
      egui/src/paint/command.rs
  18. 8
      egui/src/paint/fonts.rs
  19. 6
      egui/src/paint/mesher.rs
  20. 17
      egui/src/style.rs
  21. 13
      egui/src/types.rs
  22. 3
      egui/src/widgets/text_edit.rs
  23. 4
      egui_glium/Cargo.toml
  24. 2
      egui_wasm/Cargo.toml
  25. 7
      example_glium/Cargo.toml
  26. 2
      example_glium/src/main.rs
  27. 5
      example_wasm/Cargo.toml
  28. 4
      example_wasm/src/lib.rs

6
Cargo.lock

@ -355,7 +355,6 @@ dependencies = [
"parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rusttype 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -395,7 +394,6 @@ dependencies = [
"egui_glium 0.1.0",
"glium 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -406,7 +404,6 @@ dependencies = [
"egui 0.1.0",
"egui_wasm 0.1.0",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -990,6 +987,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "serde"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive"

6
egui/Cargo.toml

@ -11,8 +11,10 @@ edition = "2018"
ahash = "0.3"
parking_lot = "0.10"
rusttype = "0.9"
serde = "1"
serde_derive = "1"
serde = { version = "1", features = ["derive"], optional = true }
[features]
with_serde = ["serde"]
[dev-dependencies]
criterion = { version = "0.3", default-features = false }

5
egui/src/containers/area.rs

@ -6,7 +6,8 @@ use std::{fmt::Debug, hash::Hash, sync::Arc};
use crate::*;
#[derive(Clone, Copy, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub(crate) struct State {
/// Last known pos
pub pos: Pos2,
@ -20,7 +21,7 @@ pub(crate) struct State {
/// You can throw a moveable Area. It's fun.
/// TODO: separate out moveable to container?
#[serde(skip)]
#[cfg_attr(feature = "with_serde", serde(skip))]
pub vel: Vec2,
}

14
egui/src/containers/collapsing_header.rs

@ -5,12 +5,14 @@ use crate::{
*,
};
#[derive(Clone, Copy, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
#[serde(default)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub(crate) struct State {
open: bool,
#[serde(skip)] // Times are relative, and we don't want to continue animations anyway
// Times are relative, and we don't want to continue animations anyway, hence `serde(skip)`
#[cfg_attr(feature = "with_serde", serde(skip))]
toggle_time: f64,
/// Height of the region when open. Used for animations
@ -33,9 +35,9 @@ impl State {
.collapsing_headers
.entry(id)
.or_insert(State {
open: default_open,
..Default::default()
})
open: default_open,
..Default::default()
})
.clone()
}

7
egui/src/containers/menu.rs

@ -2,11 +2,12 @@ use crate::{widgets::*, *};
use super::*;
#[derive(Clone, Copy, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct BarState {
#[serde(skip)]
#[cfg_attr(feature = "with_serde", serde(skip))]
open_menu: Option<Id>,
#[serde(skip)]
#[cfg_attr(feature = "with_serde", serde(skip))]
/// When did we open a menu?
open_time: f64,
}

3
egui/src/containers/resize.rs

@ -2,7 +2,8 @@
use crate::*;
#[derive(Clone, Copy, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub(crate) struct State {
pub(crate) size: Vec2,

5
egui/src/containers/scroll_area.rs

@ -1,7 +1,8 @@
use crate::*;
#[derive(Clone, Copy, Debug, Default, serde_derive::Deserialize, serde_derive::Serialize)]
#[serde(default)]
#[derive(Clone, Copy, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub(crate) struct State {
/// Positive offset means scrolling down/right
offset: Vec2,

31
egui/src/examples/app.rs

@ -1,14 +1,13 @@
// #![allow(dead_code, unused_variables)] // should be commented out
use std::sync::Arc;
use serde_derive::{Deserialize, Serialize};
use crate::{color::*, containers::*, examples::FractalClock, widgets::*, *};
// ----------------------------------------------------------------------------
#[derive(Default, Deserialize, Serialize)]
#[serde(default)]
#[derive(Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub struct ExampleApp {
previous_web_location_hash: String,
@ -87,7 +86,7 @@ impl ExampleApp {
// ----------------------------------------------------------------------------
#[derive(Deserialize, Serialize)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
struct OpenWindows {
// examples:
examples: bool,
@ -166,7 +165,7 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows) {
// ----------------------------------------------------------------------------
/// Showcase some ui code
#[derive(Deserialize, Serialize)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct ExampleWindow {
num_columns: usize,
@ -285,8 +284,8 @@ impl ExampleWindow {
// ----------------------------------------------------------------------------
#[derive(Deserialize, Serialize)]
#[serde(default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
struct Widgets {
checked: bool,
count: usize,
@ -365,8 +364,8 @@ impl Widgets {
// ----------------------------------------------------------------------------
#[derive(Deserialize, Serialize)]
#[serde(default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
struct BoxPainting {
size: Vec2,
corner_radius: f32,
@ -415,8 +414,9 @@ impl BoxPainting {
// ----------------------------------------------------------------------------
#[derive(Default, Deserialize, Serialize)]
#[serde(default)]
#[derive(Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
struct Painting {
lines: Vec<Vec<Vec2>>,
}
@ -474,8 +474,8 @@ impl Painting {
use crate::layout::*;
#[derive(Deserialize, Serialize)]
#[serde(default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
struct LayoutExample {
dir: Direction,
align: Option<Align>, // None == jusitifed
@ -560,7 +560,8 @@ enum Action {
Delete,
}
#[derive(Clone, Default, Deserialize, Serialize)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
struct Tree(Vec<Tree>);
impl Tree {

6
egui/src/examples/fractal_clock.rs

@ -1,11 +1,9 @@
use std::sync::Arc;
use serde_derive::{Deserialize, Serialize};
use crate::{containers::*, widgets::*, *};
#[derive(Deserialize, Serialize)]
#[serde(default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub struct FractalClock {
paused: bool,
time: f64,

5
egui/src/id.rs

@ -31,9 +31,8 @@ use std::hash::Hash;
use crate::math::Pos2;
#[derive(
Clone, Copy, Debug, Hash, Eq, PartialEq, serde_derive::Deserialize, serde_derive::Serialize,
)]
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Id(u64);
impl Id {

17
egui/src/input.rs

@ -1,5 +1,3 @@
use serde_derive::Deserialize;
use crate::{math::*, movement_tracker::MovementTracker};
/// If mouse moves more than this, it is no longer a click (but maybe a drag)
@ -9,8 +7,9 @@ const MAX_CLICK_DELAY: f64 = 0.3;
/// What the integration gives to the gui.
/// All coordinates in egui is in point/logical coordinates.
#[derive(Clone, Debug, Default, Deserialize)]
#[serde(default)]
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub struct RawInput {
/// Is the button currently down?
pub mouse_down: bool,
@ -134,8 +133,9 @@ impl Default for MouseInput {
}
}
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
pub enum Event {
Copy,
Cut,
@ -147,8 +147,9 @@ pub enum Event {
},
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize))]
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
pub enum Key {
Alt,
Backspace,

7
egui/src/layers.rs

@ -1,10 +1,10 @@
use ahash::AHashMap;
use serde_derive::{Deserialize, Serialize};
use crate::{math::Rect, paint::PaintCmd, Id};
/// Different layer categories
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub enum Order {
/// Painted behind all floating windows
Background,
@ -18,7 +18,8 @@ pub enum Order {
/// An ideintifer for a paint layer.
/// Also acts as an identifier for `Area`:s.
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Layer {
pub order: Order,
pub id: Id,

15
egui/src/layout.rs

@ -1,11 +1,10 @@
use serde_derive::{Deserialize, Serialize};
use crate::{math::*, style::Style};
// ----------------------------------------------------------------------------
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub enum Direction {
Horizontal,
Vertical,
@ -17,8 +16,9 @@ impl Default for Direction {
}
}
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
#[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"))]
pub enum Align {
/// Left/Top
Min,
@ -55,7 +55,8 @@ pub fn align_rect(rect: Rect, align: (Align, Align)) -> Rect {
// ----------------------------------------------------------------------------
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Layout {
/// Lay out things horizontally or vertically?
dir: Direction,

11
egui/src/math.rs

@ -1,8 +1,7 @@
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, RangeInclusive, Sub, SubAssign};
use serde_derive::{Deserialize, Serialize};
#[derive(Clone, Copy, Default, Deserialize, Serialize)]
#[derive(Clone, Copy, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Vec2 {
pub x: f32,
pub y: f32,
@ -212,7 +211,8 @@ impl std::fmt::Debug for Vec2 {
// ----------------------------------------------------------------------------
/// Sometimes called a Point. I prefer the shorter Pos2 so it is equal length to Vec2
#[derive(Clone, Copy, Default, Deserialize, Serialize)]
#[derive(Clone, Copy, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Pos2 {
pub x: f32,
pub y: f32,
@ -337,7 +337,8 @@ impl std::fmt::Debug for Pos2 {
// ----------------------------------------------------------------------------
#[derive(Clone, Copy, Default, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Clone, Copy, Default, Eq, PartialEq)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Rect {
pub min: Pos2,
pub max: Pos2,

16
egui/src/memory.rs

@ -6,14 +6,15 @@ use crate::{
Id, Layer, Pos2, Rect,
};
#[derive(Clone, Debug, Default, serde_derive::Deserialize, serde_derive::Serialize)]
#[serde(default)]
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub struct Memory {
#[serde(skip)]
#[cfg_attr(feature = "with_serde", serde(skip))]
pub(crate) interaction: Interaction,
/// The widget with keyboard focus (i.e. a text input field).
#[serde(skip)]
#[cfg_attr(feature = "with_serde", serde(skip))]
pub(crate) kb_focus_id: Option<Id>,
// states of various types of widgets
@ -23,7 +24,7 @@ pub struct Memory {
pub(crate) scroll_areas: HashMap<Id, scroll_area::State>,
pub(crate) text_edit: HashMap<Id, text_edit::State>,
#[serde(skip)]
#[cfg_attr(feature = "with_serde", serde(skip))]
pub(crate) window_interaction: Option<window::WindowInteraction>,
pub(crate) areas: Areas,
@ -60,8 +61,9 @@ pub struct Interaction {
pub drag_interest: bool,
}
#[derive(Clone, Debug, Default, serde_derive::Deserialize, serde_derive::Serialize)]
#[serde(default)]
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(default))]
pub struct Areas {
areas: HashMap<Id, area::State>,
/// Top is last

5
egui/src/paint/color.rs

@ -1,8 +1,7 @@
use serde_derive::{Deserialize, Serialize};
/// 0-255 `sRGBA`. TODO: rename `sRGBA` for clarity.
/// Uses premultiplied alpha.
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Color {
pub r: u8,
pub g: u8,

5
egui/src/paint/command.rs

@ -3,8 +3,6 @@ use {
crate::math::{Pos2, Rect},
};
use serde_derive::{Deserialize, Serialize};
// TODO: rename, e.g. `paint::Cmd`?
#[derive(Clone, Debug)]
pub enum PaintCmd {
@ -50,7 +48,8 @@ impl PaintCmd {
}
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct LineStyle {
pub width: f32,
pub color: Color,

8
egui/src/paint/fonts.rs

@ -4,7 +4,7 @@ use std::{
sync::Arc,
};
use {parking_lot::Mutex, serde_derive::Serialize};
use parking_lot::Mutex;
use super::{
font::Font,
@ -12,7 +12,8 @@ use super::{
};
/// TODO: rename
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub enum TextStyle {
Body,
Button,
@ -20,7 +21,8 @@ pub enum TextStyle {
Monospace,
}
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub enum FontFamily {
Monospace,
VariableWidth,

6
egui/src/paint/mesher.rs

@ -12,7 +12,8 @@ use {
const WHITE_UV: (u16, u16) = (1, 1);
#[derive(Clone, Copy, Debug, Default, serde_derive::Serialize)]
#[derive(Clone, Copy, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Vertex {
/// Pixel coordinates
pub pos: Pos2,
@ -22,7 +23,8 @@ pub struct Vertex {
pub color: Color,
}
#[derive(Clone, Debug, Default, serde_derive::Serialize)]
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Triangles {
/// Draw as triangles (i.e. the length is a multiple of three)
pub indices: Vec<u32>,

17
egui/src/style.rs

@ -1,11 +1,10 @@
#![allow(clippy::if_same_then_else)]
use serde_derive::{Deserialize, Serialize};
use crate::{color::*, math::*, paint::LineStyle, types::*};
// TODO: split into Spacing and Style?
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Style {
/// Horizontal and vertical padding within a window frame.
pub window_padding: Vec2,
@ -89,7 +88,8 @@ impl Default for Style {
}
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Interact {
pub active: WidgetStyle,
pub hovered: WidgetStyle,
@ -139,7 +139,8 @@ impl Interact {
}
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct WidgetStyle {
/// Background color of widget
pub bg_fill: Option<Color>,
@ -162,7 +163,8 @@ pub struct WidgetStyle {
pub corner_radius: f32,
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Window {
pub corner_radius: f32,
}
@ -175,7 +177,8 @@ impl Default for Window {
}
}
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub struct MenuBar {
pub height: f32,
}

13
egui/src/types.rs

@ -1,12 +1,11 @@
use std::sync::Arc;
use serde_derive::Serialize;
use crate::{math::Rect, Context, Ui};
// ----------------------------------------------------------------------------
#[derive(Clone, Default, Serialize)]
#[derive(Clone, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
pub struct Output {
pub cursor_icon: CursorIcon,
@ -17,8 +16,9 @@ pub struct Output {
pub copied_text: String,
}
#[derive(Clone, Copy, Serialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, Copy)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
#[cfg_attr(feature = "with_serde", serde(rename_all = "snake_case"))]
pub enum CursorIcon {
Default,
/// Pointing hand, used for e.g. web links
@ -38,7 +38,8 @@ impl Default for CursorIcon {
// ----------------------------------------------------------------------------
#[derive(Clone, Copy, Debug, Serialize)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize))]
pub struct InteractInfo {
/// The mouse is hovering above this thing
pub hovered: bool,

3
egui/src/widgets/text_edit.rs

@ -1,6 +1,7 @@
use crate::{paint::*, *};
#[derive(Clone, Copy, Debug, Default, serde_derive::Deserialize, serde_derive::Serialize)]
#[derive(Clone, Copy, Debug, Default)]
#[cfg_attr(feature = "with_serde", derive(serde::Deserialize, serde::Serialize))]
pub(crate) struct State {
/// Charctaer based, NOT bytes.
/// TODO: store as line + row

4
egui_glium/Cargo.toml

@ -1,12 +1,12 @@
[package]
name = "egui_glium"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"
[dependencies]
egui = { path = "../egui" }
egui = { path = "../egui", features = ["with_serde"] }
chrono = { version = "0.4" }
clipboard = "0.5"

2
egui_wasm/Cargo.toml

@ -1,7 +1,7 @@
[package]
name = "egui_wasm"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"

7
example_glium/Cargo.toml

@ -1,15 +1,14 @@
[package]
name = "example_glium"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"
[dependencies]
egui = { path = "../egui" }
egui = { path = "../egui", features = ["with_serde"] }
egui_glium = { path = "../egui_glium" }
serde = "1"
serde_derive = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
glium = "0.24"

2
example_glium/src/main.rs

@ -8,7 +8,7 @@ use {
glium::glutin,
};
#[derive(Default, serde_derive::Deserialize, serde_derive::Serialize)]
#[derive(Default, serde::Deserialize, serde::Serialize)]
struct Window {
pos: Option<Pos2>,
size: Option<Vec2>,

5
example_wasm/Cargo.toml

@ -1,7 +1,7 @@
[package]
name = "example_wasm"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emilernerfeldt@gmail.com>"]
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2018"
@ -9,8 +9,7 @@ edition = "2018"
crate-type = ["cdylib", "rlib"]
[dependencies]
serde = "1"
serde_derive = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
wasm-bindgen = "0.2"

4
example_wasm/src/lib.rs

@ -13,14 +13,14 @@ use {
use wasm_bindgen::prelude::*;
#[derive(Clone, Debug, Default, serde_derive::Deserialize)]
#[derive(Clone, Debug, Default, serde::Deserialize)]
#[serde(default)]
struct WebInput {
egui: RawInput,
web: Web,
}
#[derive(Clone, Debug, Default, serde_derive::Deserialize)]
#[derive(Clone, Debug, Default, serde::Deserialize)]
#[serde(default)]
pub struct Web {
pub location: String,

Loading…
Cancel
Save