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:
parent
f2dd3dfdd9
commit
5539dbe620
58 changed files with 226 additions and 194 deletions
|
@ -11,13 +11,14 @@ NOTE: [`eframe`](eframe/CHANGELOG.md), [`egui_web`](egui_web/CHANGELOG.md), [`eg
|
||||||
* Add horizontal scrolling support to `ScrollArea` and `Window` (opt-in).
|
* Add horizontal scrolling support to `ScrollArea` and `Window` (opt-in).
|
||||||
* `TextEdit::layouter`: Add custom text layout for e.g. syntax highlighting or WYSIWYG.
|
* `TextEdit::layouter`: Add custom text layout for e.g. syntax highlighting or WYSIWYG.
|
||||||
* `Fonts::layout_job*`: New text layout engine allowing mixing fonts, colors and styles, with underlining and strikethrough.
|
* `Fonts::layout_job*`: New text layout engine allowing mixing fonts, colors and styles, with underlining and strikethrough.
|
||||||
|
* Add feature `"serialize"` separatedly from `"persistence"`.
|
||||||
|
|
||||||
### Changed 🔧
|
### Changed 🔧
|
||||||
* Label text will now be centered, right-aligned and/or justified based on the layout.
|
* Label text will now be centered, right-aligned and/or justified based on the layout.
|
||||||
* `Hyperlink` will now word-wrap just like a `Label`.
|
* `Hyperlink` will now word-wrap just like a `Label`.
|
||||||
* All `Ui`:s must now have a finite `max_rect`.
|
* All `Ui`:s must now have a finite `max_rect`.
|
||||||
* Deprecated: `max_rect_finite`, `available_size_before_wrap_finite` and `available_rect_before_wrap_finite`.
|
* Deprecated: `max_rect_finite`, `available_size_before_wrap_finite` and `available_rect_before_wrap_finite`.
|
||||||
* `Painter`/`Fonts`: text layout now expect color when creating a `Galley`. You may override that color with `Painter::galley_with_color`.
|
* `Painter`/`Fonts`: text layout now expect a color when creating a `Galley`. You may override that color with `Painter::galley_with_color`.
|
||||||
* MSRV (Minimum Supported Rust Version) is now `1.54.0`.
|
* MSRV (Minimum Supported Rust Version) is now `1.54.0`.
|
||||||
* By default, `DragValue`:s no longer show a tooltip when hovered. Change with `Style::explanation_tooltips`.
|
* By default, `DragValue`:s no longer show a tooltip when hovered. Change with `Style::explanation_tooltips`.
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# Changelog for eframe
|
# Changelog for eframe
|
||||||
All notable changes to the `eframe` crate.
|
All notable changes to the `eframe` and `epi` crates.
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
* `Frame` now provides `set_decorations` to set whether to show window decorations.
|
* `Frame` now provides `set_decorations` to set whether to show window decorations.
|
||||||
* Remove "http" feature (use https://github.com/emilk/ehttp instead!).
|
* Remove "http" feature (use https://github.com/emilk/ehttp instead!).
|
||||||
* Increase native scroll speed.
|
* Increase native scroll speed.
|
||||||
|
* Add `App::persist_native_window` and `App::persist_egui_memory` to control what gets persisted.
|
||||||
|
|
||||||
|
|
||||||
## 0.14.0 - 2021-08-24
|
## 0.14.0 - 2021-08-24
|
||||||
|
|
|
@ -30,6 +30,9 @@ ron = { version = "0.6.4", optional = true }
|
||||||
[features]
|
[features]
|
||||||
default = ["default_fonts", "single_threaded"]
|
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 set, egui will use `include_bytes!` to bundle some fonts.
|
||||||
# If you plan on specifying your own fonts you may disable this feature.
|
# If you plan on specifying your own fonts you may disable this feature.
|
||||||
default_fonts = ["epaint/default_fonts"]
|
default_fonts = ["epaint/default_fonts"]
|
||||||
|
@ -42,10 +45,11 @@ extra_asserts = ["epaint/extra_asserts"]
|
||||||
# Add compatability with https://github.com/kvark/mint
|
# Add compatability with https://github.com/kvark/mint
|
||||||
mint = ["epaint/mint"]
|
mint = ["epaint/mint"]
|
||||||
|
|
||||||
# add compatibility with https://crates.io/crates/cint
|
# enable persistence of memory (window positions etc).
|
||||||
cint = ["epaint/cint"]
|
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
|
# multi_threaded is only needed if you plan to use the same egui::Context
|
||||||
# from multiple threads. It comes with a minor performance impact.
|
# 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.
|
/// 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)]
|
#[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);
|
pub struct TypeId(u64);
|
||||||
|
|
||||||
impl TypeId {
|
impl TypeId {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::*;
|
||||||
|
|
||||||
/// State that is persisted between frames
|
/// State that is persisted between frames
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[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 {
|
pub(crate) struct State {
|
||||||
/// Last known pos
|
/// Last known pos
|
||||||
pub pos: Pos2,
|
pub pos: Pos2,
|
||||||
|
|
|
@ -4,8 +4,8 @@ use crate::{widgets::Label, *};
|
||||||
use epaint::{Shape, TextStyle};
|
use epaint::{Shape, TextStyle};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub(crate) struct State {
|
pub(crate) struct State {
|
||||||
open: bool,
|
open: bool,
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use std::ops::RangeInclusive;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
struct PanelState {
|
struct PanelState {
|
||||||
rect: Rect,
|
rect: Rect,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[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 {
|
pub(crate) struct State {
|
||||||
/// This is the size that the user has picked by dragging the resize handles.
|
/// 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.
|
/// This may be smaller and/or larger than the actual size.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub(crate) struct State {
|
pub(crate) struct State {
|
||||||
/// Positive offset means scrolling down/right
|
/// Positive offset means scrolling down/right
|
||||||
offset: Vec2,
|
offset: Vec2,
|
||||||
|
@ -17,7 +17,7 @@ pub(crate) struct State {
|
||||||
show_scroll: [bool; 2],
|
show_scroll: [bool; 2],
|
||||||
|
|
||||||
/// Momentum, used for kinetic scrolling
|
/// Momentum, used for kinetic scrolling
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
pub vel: Vec2,
|
pub vel: Vec2,
|
||||||
|
|
||||||
/// Mouse offset relative to the top of the handle when started moving the handle.
|
/// Mouse offset relative to the top of the handle when started moving the handle.
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::emath::*;
|
||||||
///
|
///
|
||||||
/// All coordinates are in points (logical pixels) with origin (0, 0) in the top left corner.
|
/// All coordinates are in points (logical pixels) with origin (0, 0) in the top left corner.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[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 {
|
pub struct RawInput {
|
||||||
/// How many points (logical pixels) the user scrolled
|
/// How many points (logical pixels) the user scrolled
|
||||||
pub scroll_delta: Vec2,
|
pub scroll_delta: Vec2,
|
||||||
|
@ -132,7 +132,7 @@ impl RawInput {
|
||||||
|
|
||||||
/// A file about to be dropped into egui.
|
/// A file about to be dropped into egui.
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[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 {
|
pub struct HoveredFile {
|
||||||
/// Set by the `egui-winit` backend.
|
/// Set by the `egui-winit` backend.
|
||||||
pub path: Option<std::path::PathBuf>,
|
pub path: Option<std::path::PathBuf>,
|
||||||
|
@ -142,7 +142,7 @@ pub struct HoveredFile {
|
||||||
|
|
||||||
/// A file dropped into egui.
|
/// A file dropped into egui.
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[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 {
|
pub struct DroppedFile {
|
||||||
/// Set by the `egui-winit` backend.
|
/// Set by the `egui-winit` backend.
|
||||||
pub path: Option<std::path::PathBuf>,
|
pub path: Option<std::path::PathBuf>,
|
||||||
|
@ -158,7 +158,7 @@ pub struct DroppedFile {
|
||||||
///
|
///
|
||||||
/// This only covers events that egui cares about.
|
/// This only covers events that egui cares about.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[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 {
|
pub enum Event {
|
||||||
/// The integration detected a "copy" event (e.g. Cmd+C).
|
/// The integration detected a "copy" event (e.g. Cmd+C).
|
||||||
Copy,
|
Copy,
|
||||||
|
@ -217,7 +217,7 @@ pub enum Event {
|
||||||
|
|
||||||
/// Mouse button (or similar for touch input)
|
/// Mouse button (or similar for touch input)
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[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 {
|
pub enum PointerButton {
|
||||||
/// The primary mouse button is usually the left one.
|
/// The primary mouse button is usually the left one.
|
||||||
Primary = 0,
|
Primary = 0,
|
||||||
|
@ -233,7 +233,7 @@ pub const NUM_POINTER_BUTTONS: usize = 3;
|
||||||
|
|
||||||
/// State of the modifier keys. These must be fed to egui.
|
/// State of the modifier keys. These must be fed to egui.
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
#[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 {
|
pub struct Modifiers {
|
||||||
/// Either of the alt keys are down (option ⌥ on Mac).
|
/// Either of the alt keys are down (option ⌥ on Mac).
|
||||||
pub alt: bool,
|
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 `§`,
|
/// 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.
|
/// and are therefor unsuitable as keyboard shortcuts if you want your app to be portable.
|
||||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
|
#[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 {
|
pub enum Key {
|
||||||
ArrowDown,
|
ArrowDown,
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
|
@ -383,19 +383,19 @@ impl RawInput {
|
||||||
|
|
||||||
/// this is a `u64` as values of this kind can always be obtained by hashing
|
/// this is a `u64` as values of this kind can always be obtained by hashing
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
#[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);
|
pub struct TouchDeviceId(pub u64);
|
||||||
|
|
||||||
/// Unique identification of a touch occurrence (finger or pen or ...).
|
/// Unique identification of a touch occurrence (finger or pen or ...).
|
||||||
/// A Touch ID is valid until the finger is lifted.
|
/// A Touch ID is valid until the finger is lifted.
|
||||||
/// A new ID is used for the next touch.
|
/// A new ID is used for the next touch.
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
#[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);
|
pub struct TouchId(pub u64);
|
||||||
|
|
||||||
/// In what phase a touch event is in.
|
/// In what phase a touch event is in.
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[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 {
|
pub enum TouchPhase {
|
||||||
/// User just placed a touch point on the touch surface
|
/// User just placed a touch point on the touch surface
|
||||||
Start,
|
Start,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::WidgetType;
|
||||||
/// What egui emits each frame.
|
/// What egui emits each frame.
|
||||||
/// The backend should use this.
|
/// The backend should use this.
|
||||||
#[derive(Clone, Default, PartialEq)]
|
#[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 {
|
pub struct Output {
|
||||||
/// Set the cursor to this icon.
|
/// Set the cursor to this icon.
|
||||||
pub cursor_icon: CursorIcon,
|
pub cursor_icon: CursorIcon,
|
||||||
|
@ -89,7 +89,7 @@ impl Output {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[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 struct OpenUrl {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
/// If `true`, open the url in a new tab.
|
/// 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>.
|
/// Loosely based on <https://developer.mozilla.org/en-US/docs/Web/CSS/cursor>.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[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 {
|
pub enum CursorIcon {
|
||||||
/// Normal cursor icon, whatever that is.
|
/// Normal cursor icon, whatever that is.
|
||||||
Default,
|
Default,
|
||||||
|
@ -244,7 +244,7 @@ impl Default for CursorIcon {
|
||||||
///
|
///
|
||||||
/// In particular, these events may be useful for accessability, i.e. for screen readers.
|
/// In particular, these events may be useful for accessability, i.e. for screen readers.
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum OutputEvent {
|
pub enum OutputEvent {
|
||||||
// A widget was clicked.
|
// A widget was clicked.
|
||||||
Clicked(WidgetInfo),
|
Clicked(WidgetInfo),
|
||||||
|
@ -272,7 +272,7 @@ impl std::fmt::Debug for OutputEvent {
|
||||||
|
|
||||||
/// Describes a widget such as a [`crate::Button`] or a [`crate::TextEdit`].
|
/// Describes a widget such as a [`crate::Button`] or a [`crate::TextEdit`].
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct WidgetInfo {
|
pub struct WidgetInfo {
|
||||||
/// The type of widget this is.
|
/// The type of widget this is.
|
||||||
pub typ: WidgetType,
|
pub typ: WidgetType,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[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 {
|
pub(crate) struct State {
|
||||||
col_widths: Vec<f32>,
|
col_widths: Vec<f32>,
|
||||||
row_heights: Vec<f32>,
|
row_heights: Vec<f32>,
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
/// Then there are widgets that need no identifiers at all, like labels,
|
/// Then there are widgets that need no identifiers at all, like labels,
|
||||||
/// because they have no state nor are interacted with.
|
/// because they have no state nor are interacted with.
|
||||||
#[derive(Clone, Copy, Hash, Eq, PartialEq)]
|
#[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);
|
pub struct Id(u64);
|
||||||
|
|
||||||
impl Id {
|
impl Id {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
/// Different layer categories
|
/// Different layer categories
|
||||||
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]
|
#[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 {
|
pub enum Order {
|
||||||
/// Painted behind all floating windows
|
/// Painted behind all floating windows
|
||||||
Background,
|
Background,
|
||||||
|
@ -65,7 +65,7 @@ impl Order {
|
||||||
/// An identifier for a paint layer.
|
/// An identifier for a paint layer.
|
||||||
/// Also acts as an identifier for [`Area`]:s.
|
/// Also acts as an identifier for [`Area`]:s.
|
||||||
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
|
#[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 struct LayerId {
|
||||||
pub order: Order,
|
pub order: Order,
|
||||||
pub id: Id,
|
pub id: Id,
|
||||||
|
|
|
@ -76,8 +76,8 @@ impl Region {
|
||||||
|
|
||||||
/// Layout direction, one of `LeftToRight`, `RightToLeft`, `TopDown`, `BottomUp`.
|
/// Layout direction, one of `LeftToRight`, `RightToLeft`, `TopDown`, `BottomUp`.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(rename_all = "snake_case"))]
|
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
LeftToRight,
|
LeftToRight,
|
||||||
RightToLeft,
|
RightToLeft,
|
||||||
|
@ -115,7 +115,7 @@ impl Direction {
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[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 {
|
pub struct Layout {
|
||||||
/// Main axis direction
|
/// Main axis direction
|
||||||
main_dir: Direction,
|
main_dir: Direction,
|
||||||
|
|
|
@ -527,7 +527,7 @@ pub mod special_emojis {
|
||||||
|
|
||||||
/// The different types of built-in widgets in egui
|
/// The different types of built-in widgets in egui
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[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 {
|
pub enum WidgetType {
|
||||||
Label, // TODO: emit Label events
|
Label, // TODO: emit Label events
|
||||||
Hyperlink,
|
Hyperlink,
|
||||||
|
|
|
@ -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
|
/// 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.
|
/// `id_data`/`id_data_temp` fields, and read the documentation of [`any`] module.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Memory {
|
pub struct Memory {
|
||||||
pub options: Options,
|
pub options: Options,
|
||||||
|
|
||||||
|
@ -53,23 +53,23 @@ pub struct Memory {
|
||||||
/// new fonts that will be applied at the start of the next frame
|
/// new fonts that will be applied at the start of the next frame
|
||||||
pub(crate) new_font_definitions: Option<epaint::text::FontDefinitions>,
|
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,
|
pub(crate) interaction: Interaction,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
pub(crate) window_interaction: Option<window::WindowInteraction>,
|
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) drag_value: crate::widgets::drag_value::MonoState,
|
||||||
|
|
||||||
pub(crate) areas: Areas,
|
pub(crate) areas: Areas,
|
||||||
|
|
||||||
/// Which popup-window is open (if any)?
|
/// Which popup-window is open (if any)?
|
||||||
/// Could be a combo box, color picker, menu etc.
|
/// Could be a combo box, color picker, menu etc.
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
popup: Option<Id>,
|
popup: Option<Id>,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
everything_is_visible: bool,
|
everything_is_visible: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +77,11 @@ pub struct Memory {
|
||||||
|
|
||||||
/// Some global options that you can read and write.
|
/// Some global options that you can read and write.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
/// The default style for new `Ui`:s.
|
/// 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>,
|
pub(crate) style: std::sync::Arc<Style>,
|
||||||
|
|
||||||
/// Controls the tessellator.
|
/// Controls the tessellator.
|
||||||
|
@ -432,8 +432,8 @@ impl Memory {
|
||||||
/// Keeps track of `Area`s, which are free-floating `Ui`s.
|
/// Keeps track of `Area`s, which are free-floating `Ui`s.
|
||||||
/// These `Area`s can be in any `Order`.
|
/// These `Area`s can be in any `Order`.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Areas {
|
pub struct Areas {
|
||||||
areas: HashMap<Id, area::State>,
|
areas: HashMap<Id, area::State>,
|
||||||
/// Back-to-front. Top is last.
|
/// Back-to-front. Top is last.
|
||||||
|
|
|
@ -20,8 +20,8 @@ use epaint::Stroke;
|
||||||
|
|
||||||
/// What is saved between frames.
|
/// What is saved between frames.
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub(crate) struct BarState {
|
pub(crate) struct BarState {
|
||||||
open_menu: Option<Id>,
|
open_menu: Option<Id>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/// What sort of interaction is a widget sensitive to?
|
/// What sort of interaction is a widget sensitive to?
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
// #[cfg_attr(feature = "persistence", derive(serde::Serialize))]
|
// #[cfg_attr(feature = "serde", derive(serde::Serialize))]
|
||||||
pub struct Sense {
|
pub struct Sense {
|
||||||
/// buttons, sliders, windows ...
|
/// buttons, sliders, windows ...
|
||||||
pub click: bool,
|
pub click: bool,
|
||||||
|
|
|
@ -12,8 +12,8 @@ use epaint::{Shadow, Stroke, TextStyle};
|
||||||
///
|
///
|
||||||
/// If you want to change fonts, use [`crate::Context::set_fonts`] instead.
|
/// If you want to change fonts, use [`crate::Context::set_fonts`] instead.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Style {
|
pub struct Style {
|
||||||
/// Default `TextStyle` for normal text (i.e. for `Label` and `TextEdit`).
|
/// Default `TextStyle` for normal text (i.e. for `Label` and `TextEdit`).
|
||||||
pub body_text_style: TextStyle,
|
pub body_text_style: TextStyle,
|
||||||
|
@ -81,8 +81,8 @@ impl Style {
|
||||||
|
|
||||||
/// Controls the sizes and distances between widgets.
|
/// Controls the sizes and distances between widgets.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Spacing {
|
pub struct Spacing {
|
||||||
/// Horizontal and vertical spacing between widgets.
|
/// Horizontal and vertical spacing between widgets.
|
||||||
///
|
///
|
||||||
|
@ -151,8 +151,8 @@ impl Spacing {
|
||||||
|
|
||||||
/// How and when interaction happens.
|
/// How and when interaction happens.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Interaction {
|
pub struct Interaction {
|
||||||
/// Mouse must be the close to the side of a window to resize
|
/// Mouse must be the close to the side of a window to resize
|
||||||
pub resize_grab_radius_side: f32,
|
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.
|
/// If you want to change fonts, use [`crate::Context::set_fonts`] instead.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Visuals {
|
pub struct Visuals {
|
||||||
/// If true, the visuals are overall dark with light text.
|
/// If true, the visuals are overall dark with light text.
|
||||||
/// If false, the visuals are overall light with dark text.
|
/// If false, the visuals are overall light with dark text.
|
||||||
|
@ -270,8 +270,8 @@ impl Visuals {
|
||||||
|
|
||||||
/// Selected text, selected elements etc
|
/// Selected text, selected elements etc
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Selection {
|
pub struct Selection {
|
||||||
pub bg_fill: Color32,
|
pub bg_fill: Color32,
|
||||||
pub stroke: Stroke,
|
pub stroke: Stroke,
|
||||||
|
@ -279,8 +279,8 @@ pub struct Selection {
|
||||||
|
|
||||||
/// The visuals of widgets for different states of interaction.
|
/// The visuals of widgets for different states of interaction.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Widgets {
|
pub struct Widgets {
|
||||||
/// The style of a widget that you cannot interact with.
|
/// The style of a widget that you cannot interact with.
|
||||||
/// * `noninteractive.bg_stroke` is the outline of windows.
|
/// * `noninteractive.bg_stroke` is the outline of windows.
|
||||||
|
@ -313,7 +313,7 @@ impl Widgets {
|
||||||
|
|
||||||
/// bg = background, fg = foreground.
|
/// bg = background, fg = foreground.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[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 {
|
pub struct WidgetVisuals {
|
||||||
/// Background color of widget.
|
/// Background color of widget.
|
||||||
pub bg_fill: Color32,
|
pub bg_fill: Color32,
|
||||||
|
@ -342,7 +342,7 @@ impl WidgetVisuals {
|
||||||
|
|
||||||
/// Options for help debug egui by adding extra visualization
|
/// Options for help debug egui by adding extra visualization
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 {
|
pub struct DebugOptions {
|
||||||
/// However over widgets to see their rectangles
|
/// However over widgets to see their rectangles
|
||||||
pub debug_on_hover: bool,
|
pub debug_on_hover: bool,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[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 {
|
pub struct Settings {
|
||||||
/// Maximum number of undos.
|
/// Maximum number of undos.
|
||||||
/// If your state is resource intensive, you should keep this low.
|
/// 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 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.
|
/// Rule 2) will make sure that you will get some undo points even if you are constantly changing the state.
|
||||||
#[derive(Clone, Default)]
|
#[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> {
|
pub struct Undoer<State> {
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ pub struct Undoer<State> {
|
||||||
/// The latest undo point may (often) be the current state.
|
/// The latest undo point may (often) be the current state.
|
||||||
undos: VecDeque<State>,
|
undos: VecDeque<State>,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
flux: Option<Flux<State>>,
|
flux: Option<Flux<State>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use color::Hsva;
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Information about the plot that has to persist between frames.
|
/// 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)]
|
#[derive(Clone)]
|
||||||
struct PlotMemory {
|
struct PlotMemory {
|
||||||
bounds: Bounds,
|
bounds: Bounds,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::*;
|
||||||
/// 2D bounding box of f64 precision.
|
/// 2D bounding box of f64 precision.
|
||||||
/// The range of data values we show.
|
/// The range of data values we show.
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[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(crate) struct Bounds {
|
||||||
pub min: [f64; 2],
|
pub min: [f64; 2],
|
||||||
pub max: [f64; 2],
|
pub max: [f64; 2],
|
||||||
|
|
|
@ -4,25 +4,25 @@ use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub(crate) struct State {
|
pub(crate) struct State {
|
||||||
cursorp: Option<CursorPair>,
|
cursorp: Option<CursorPair>,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
undoer: Undoer<(CCursorPair, String)>,
|
undoer: Undoer<(CCursorPair, String)>,
|
||||||
|
|
||||||
// If IME candidate window is shown on this text edit.
|
// 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,
|
has_ime: bool,
|
||||||
|
|
||||||
// Visual offset when editing singleline text bigger than the width.
|
// 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,
|
singleline_offset: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[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 {
|
pub struct CursorPair {
|
||||||
/// When selecting with a mouse, this is where the mouse was released.
|
/// When selecting with a mouse, this is where the mouse was released.
|
||||||
/// When moving with e.g. shift+arrows, this is what moves.
|
/// When moving with e.g. shift+arrows, this is what moves.
|
||||||
|
@ -86,7 +86,7 @@ impl CursorPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 {
|
struct CCursorPair {
|
||||||
/// When selecting with a mouse, this is where the mouse was released.
|
/// When selecting with a mouse, this is where the mouse was released.
|
||||||
/// When moving with e.g. shift+arrows, this is what moves.
|
/// When moving with e.g. shift+arrows, this is what moves.
|
||||||
|
|
|
@ -42,15 +42,17 @@ criterion = { version = "0.3", default-features = false }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
http = ["ehttp", "image"]
|
|
||||||
persistence = ["egui/persistence", "epi/persistence", "serde"]
|
|
||||||
syntax_highlighting = ["syntect"]
|
|
||||||
|
|
||||||
# Enable additional checks if debug assertions are enabled (debug builds).
|
# Enable additional checks if debug assertions are enabled (debug builds).
|
||||||
extra_debug_asserts = ["egui/extra_debug_asserts"]
|
extra_debug_asserts = ["egui/extra_debug_asserts"]
|
||||||
# Always enable additional checks.
|
# Always enable additional checks.
|
||||||
extra_asserts = ["egui/extra_asserts"]
|
extra_asserts = ["egui/extra_asserts"]
|
||||||
|
|
||||||
|
http = ["ehttp", "image"]
|
||||||
|
persistence = ["egui/persistence", "epi/persistence", "serde"]
|
||||||
|
serialize = ["egui/serialize", "serde"]
|
||||||
|
syntax_highlighting = ["syntect"]
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "benchmark"
|
name = "benchmark"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
|
@ -9,9 +9,9 @@ const RED: Color32 = Color32::RED;
|
||||||
const TRANSPARENT: Color32 = Color32::TRANSPARENT;
|
const TRANSPARENT: Color32 = Color32::TRANSPARENT;
|
||||||
const WHITE: Color32 = Color32::WHITE;
|
const WHITE: Color32 = Color32::WHITE;
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct ColorTest {
|
pub struct ColorTest {
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
tex_mngr: TextureManager,
|
tex_mngr: TextureManager,
|
||||||
vertex_gradients: bool,
|
vertex_gradients: bool,
|
||||||
texture_gradients: bool,
|
texture_gradients: bool,
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
/// Implements `epi::App` so it can be used with
|
/// Implements `epi::App` so it can be used with
|
||||||
/// [`egui_glium`](https://crates.io/crates/egui_glium) and [`egui_web`](https://crates.io/crates/egui_web).
|
/// [`egui_glium`](https://crates.io/crates/egui_glium) and [`egui_web`](https://crates.io/crates/egui_web).
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct DemoApp {
|
pub struct DemoApp {
|
||||||
demo_windows: super::DemoWindows,
|
demo_windows: super::DemoWindows,
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,14 @@ impl epi::App for DemoApp {
|
||||||
"✨ Demos"
|
"✨ Demos"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "persistence")]
|
|
||||||
fn setup(
|
fn setup(
|
||||||
&mut self,
|
&mut self,
|
||||||
_ctx: &egui::CtxRef,
|
_ctx: &egui::CtxRef,
|
||||||
_frame: &mut epi::Frame<'_>,
|
_frame: &mut epi::Frame<'_>,
|
||||||
storage: Option<&dyn epi::Storage>,
|
_storage: Option<&dyn epi::Storage>,
|
||||||
) {
|
) {
|
||||||
if let Some(storage) = storage {
|
#[cfg(feature = "persistence")]
|
||||||
|
if let Some(storage) = _storage {
|
||||||
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
|
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use egui::text::LayoutJob;
|
use egui::text::LayoutJob;
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct CodeEditor {
|
pub struct CodeEditor {
|
||||||
code: String,
|
code: String,
|
||||||
language: String,
|
language: String,
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
highlighter: MemoizedSyntaxHighlighter,
|
highlighter: MemoizedSyntaxHighlighter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use egui::{containers::*, *};
|
use egui::{containers::*, *};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct DancingStrings {}
|
pub struct DancingStrings {}
|
||||||
|
|
||||||
impl super::Demo for DancingStrings {
|
impl super::Demo for DancingStrings {
|
||||||
|
|
|
@ -4,10 +4,10 @@ use std::collections::BTreeSet;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
struct Demos {
|
struct Demos {
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
demos: Vec<Box<dyn Demo>>,
|
demos: Vec<Box<dyn Demo>>,
|
||||||
|
|
||||||
open: BTreeSet<String>,
|
open: BTreeSet<String>,
|
||||||
|
@ -67,10 +67,10 @@ impl Demos {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
struct Tests {
|
struct Tests {
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
demos: Vec<Box<dyn Demo>>,
|
demos: Vec<Box<dyn Demo>>,
|
||||||
|
|
||||||
open: BTreeSet<String>,
|
open: BTreeSet<String>,
|
||||||
|
@ -136,8 +136,8 @@ fn set_open(open: &mut BTreeSet<String>, key: &'static str, is_open: bool) {
|
||||||
|
|
||||||
/// A menu bar in which you can select different demo windows to show.
|
/// A menu bar in which you can select different demo windows to show.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct DemoWindows {
|
pub struct DemoWindows {
|
||||||
demos: Demos,
|
demos: Demos,
|
||||||
tests: Tests,
|
tests: Tests,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use egui::*;
|
use egui::*;
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct LayoutTest {
|
pub struct LayoutTest {
|
||||||
// Identical to contents of `egui::Layout`
|
// Identical to contents of `egui::Layout`
|
||||||
layout: LayoutSettings,
|
layout: LayoutSettings,
|
||||||
|
@ -22,8 +22,8 @@ impl Default for LayoutTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct LayoutSettings {
|
pub struct LayoutSettings {
|
||||||
// Similar to the contents of `egui::Layout`
|
// Similar to the contents of `egui::Layout`
|
||||||
main_dir: Direction,
|
main_dir: Direction,
|
||||||
|
|
|
@ -2,8 +2,8 @@ use super::*;
|
||||||
use egui::{color::*, *};
|
use egui::{color::*, *};
|
||||||
|
|
||||||
/// Showcase some ui code
|
/// Showcase some ui code
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct MiscDemoWindow {
|
pub struct MiscDemoWindow {
|
||||||
num_columns: usize,
|
num_columns: usize,
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ impl View for MiscDemoWindow {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Widgets {
|
pub struct Widgets {
|
||||||
angle: f32,
|
angle: f32,
|
||||||
password: String,
|
password: String,
|
||||||
|
@ -194,8 +194,8 @@ impl Widgets {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
struct ColorWidgets {
|
struct ColorWidgets {
|
||||||
srgba_unmul: [u8; 4],
|
srgba_unmul: [u8; 4],
|
||||||
srgba_premul: [u8; 4],
|
srgba_premul: [u8; 4],
|
||||||
|
@ -264,8 +264,8 @@ impl ColorWidgets {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
struct BoxPainting {
|
struct BoxPainting {
|
||||||
size: Vec2,
|
size: Vec2,
|
||||||
corner_radius: f32,
|
corner_radius: f32,
|
||||||
|
@ -315,7 +315,7 @@ enum Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
struct Tree(String, SubTree);
|
struct Tree(String, SubTree);
|
||||||
|
|
||||||
impl Tree {
|
impl Tree {
|
||||||
|
@ -334,7 +334,7 @@ impl Tree {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
struct SubTree(Vec<SubTree>);
|
struct SubTree(Vec<SubTree>);
|
||||||
|
|
||||||
impl SubTree {
|
impl SubTree {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use egui::*;
|
use egui::*;
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Painting {
|
pub struct Painting {
|
||||||
/// in 0-1 normalized coordinates
|
/// in 0-1 normalized coordinates
|
||||||
lines: Vec<Vec<Pos2>>,
|
lines: Vec<Vec<Pos2>>,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use egui::{color::*, *};
|
use egui::{color::*, *};
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
enum ScrollDemo {
|
enum ScrollDemo {
|
||||||
ScrollTo,
|
ScrollTo,
|
||||||
|
@ -14,8 +14,8 @@ impl Default for ScrollDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
#[derive(Default, PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
pub struct Scrolling {
|
pub struct Scrolling {
|
||||||
demo: ScrollDemo,
|
demo: ScrollDemo,
|
||||||
|
@ -124,8 +124,8 @@ fn huge_content_painter(ui: &mut egui::Ui) {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
struct ScrollTo {
|
struct ScrollTo {
|
||||||
track_item: usize,
|
track_item: usize,
|
||||||
|
|
|
@ -3,8 +3,8 @@ use std::f64::INFINITY;
|
||||||
|
|
||||||
/// Showcase sliders
|
/// Showcase sliders
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Sliders {
|
pub struct Sliders {
|
||||||
pub min: f64,
|
pub min: f64,
|
||||||
pub max: f64,
|
pub max: f64,
|
||||||
|
|
|
@ -303,7 +303,7 @@ impl super::View for TableTest {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct InputTest {
|
pub struct InputTest {
|
||||||
info: String,
|
info: String,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
enum Enum {
|
enum Enum {
|
||||||
First,
|
First,
|
||||||
Second,
|
Second,
|
||||||
|
@ -7,7 +7,7 @@ enum Enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shows off one example of each major type of widget.
|
/// Shows off one example of each major type of widget.
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct WidgetGallery {
|
pub struct WidgetGallery {
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct WindowOptions {
|
pub struct WindowOptions {
|
||||||
title: String,
|
title: String,
|
||||||
title_bar: bool,
|
title_bar: bool,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#[derive(Clone, PartialEq, Default)]
|
#[derive(Clone, PartialEq, Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct WindowWithPanels {}
|
pub struct WindowWithPanels {}
|
||||||
|
|
||||||
impl super::Demo for WindowWithPanels {
|
impl super::Demo for WindowWithPanels {
|
||||||
|
|
|
@ -2,8 +2,8 @@ use egui::{containers::*, widgets::*, *};
|
||||||
use std::f32::consts::TAU;
|
use std::f32::consts::TAU;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct FractalClock {
|
pub struct FractalClock {
|
||||||
paused: bool,
|
paused: bool,
|
||||||
time: f64,
|
time: f64,
|
||||||
|
|
|
@ -38,13 +38,13 @@ impl Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Copy, Clone)]
|
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
enum Method {
|
enum Method {
|
||||||
Get,
|
Get,
|
||||||
Post,
|
Post,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct HttpApp {
|
pub struct HttpApp {
|
||||||
url: String,
|
url: String,
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ pub struct HttpApp {
|
||||||
|
|
||||||
request_body: String,
|
request_body: String,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
in_progress: Option<Receiver<Result<ehttp::Response, String>>>,
|
in_progress: Option<Receiver<Result<ehttp::Response, String>>>,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
result: Option<Result<Resource, String>>,
|
result: Option<Result<Resource, String>>,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
tex_mngr: TexMngr,
|
tex_mngr: TexMngr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@ impl Default for RunMode {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct BackendPanel {
|
pub struct BackendPanel {
|
||||||
pub open: bool,
|
pub open: bool,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
// go back to `Reactive` mode each time we start
|
// go back to `Reactive` mode each time we start
|
||||||
run_mode: RunMode,
|
run_mode: RunMode,
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@ pub struct BackendPanel {
|
||||||
max_size_points_ui: egui::Vec2,
|
max_size_points_ui: egui::Vec2,
|
||||||
pub max_size_points_active: egui::Vec2,
|
pub max_size_points_active: egui::Vec2,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
frame_history: crate::frame_history::FrameHistory,
|
frame_history: crate::frame_history::FrameHistory,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
output_event_history: std::collections::VecDeque<egui::output::OutputEvent>,
|
output_event_history: std::collections::VecDeque<egui::output::OutputEvent>,
|
||||||
|
|
||||||
egui_windows: EguiWindows,
|
egui_windows: EguiWindows,
|
||||||
|
@ -286,7 +286,7 @@ impl BackendPanel {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
struct EguiWindows {
|
struct EguiWindows {
|
||||||
// egui stuff:
|
// egui stuff:
|
||||||
settings: bool,
|
settings: bool,
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use egui::*;
|
use egui::*;
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct EasyMarkEditor {
|
pub struct EasyMarkEditor {
|
||||||
code: String,
|
code: String,
|
||||||
highlight_editor: bool,
|
highlight_editor: bool,
|
||||||
show_rendered: bool,
|
show_rendered: bool,
|
||||||
|
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
highlighter: crate::easy_mark::MemoizedEasymarkHighlighter,
|
highlighter: crate::easy_mark::MemoizedEasymarkHighlighter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// All the different demo apps.
|
/// All the different demo apps.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct Apps {
|
pub struct Apps {
|
||||||
demo: crate::apps::DemoApp,
|
demo: crate::apps::DemoApp,
|
||||||
easy_mark_editor: crate::easy_mark::EasyMarkEditor,
|
easy_mark_editor: crate::easy_mark::EasyMarkEditor,
|
||||||
|
@ -27,13 +27,13 @@ impl Apps {
|
||||||
|
|
||||||
/// Wraps many demo/test apps into one.
|
/// Wraps many demo/test apps into one.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct WrapApp {
|
pub struct WrapApp {
|
||||||
selected_anchor: String,
|
selected_anchor: String,
|
||||||
apps: Apps,
|
apps: Apps,
|
||||||
backend_panel: super::backend_panel::BackendPanel,
|
backend_panel: super::backend_panel::BackendPanel,
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
dropped_files: Vec<egui::DroppedFile>,
|
dropped_files: Vec<egui::DroppedFile>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,15 +42,14 @@ impl epi::App for WrapApp {
|
||||||
"egui demo apps"
|
"egui demo apps"
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn setup(
|
fn setup(
|
||||||
&mut self,
|
&mut self,
|
||||||
_ctx: &egui::CtxRef,
|
_ctx: &egui::CtxRef,
|
||||||
_frame: &mut epi::Frame<'_>,
|
_frame: &mut epi::Frame<'_>,
|
||||||
storage: Option<&dyn epi::Storage>,
|
_storage: Option<&dyn epi::Storage>,
|
||||||
) {
|
) {
|
||||||
#[cfg(feature = "persistence")]
|
#[cfg(feature = "persistence")]
|
||||||
if let Some(storage) = storage {
|
if let Some(storage) = _storage {
|
||||||
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
|
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,12 +361,16 @@ pub fn run(mut app: Box<dyn epi::App>, native_options: &epi::NativeOptions) {
|
||||||
if let Some(storage) = &mut storage {
|
if let Some(storage) = &mut storage {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
if now - last_auto_save > app.auto_save_interval() {
|
if now - last_auto_save > app.auto_save_interval() {
|
||||||
epi::set_value(
|
if app.persist_native_window() {
|
||||||
storage.as_mut(),
|
epi::set_value(
|
||||||
WINDOW_KEY,
|
storage.as_mut(),
|
||||||
&WindowSettings::from_display(&display),
|
WINDOW_KEY,
|
||||||
);
|
&WindowSettings::from_display(&display),
|
||||||
epi::set_value(storage.as_mut(), EGUI_MEMORY_KEY, &*egui.ctx().memory());
|
);
|
||||||
|
}
|
||||||
|
if app.persist_egui_memory() {
|
||||||
|
epi::set_value(storage.as_mut(), EGUI_MEMORY_KEY, &*egui.ctx().memory());
|
||||||
|
}
|
||||||
app.save(storage.as_mut());
|
app.save(storage.as_mut());
|
||||||
storage.flush();
|
storage.flush();
|
||||||
last_auto_save = now;
|
last_auto_save = now;
|
||||||
|
@ -379,12 +383,16 @@ pub fn run(mut app: Box<dyn epi::App>, native_options: &epi::NativeOptions) {
|
||||||
|
|
||||||
#[cfg(feature = "persistence")]
|
#[cfg(feature = "persistence")]
|
||||||
if let Some(storage) = &mut storage {
|
if let Some(storage) = &mut storage {
|
||||||
epi::set_value(
|
if app.persist_native_window() {
|
||||||
storage.as_mut(),
|
epi::set_value(
|
||||||
WINDOW_KEY,
|
storage.as_mut(),
|
||||||
&WindowSettings::from_display(&display),
|
WINDOW_KEY,
|
||||||
);
|
&WindowSettings::from_display(&display),
|
||||||
epi::set_value(storage.as_mut(), EGUI_MEMORY_KEY, &*egui.ctx().memory());
|
);
|
||||||
|
}
|
||||||
|
if app.persist_egui_memory() {
|
||||||
|
epi::set_value(storage.as_mut(), EGUI_MEMORY_KEY, &*egui.ctx().memory());
|
||||||
|
}
|
||||||
app.save(storage.as_mut());
|
app.save(storage.as_mut());
|
||||||
storage.flush();
|
storage.flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,9 @@ impl AppRunner {
|
||||||
let time_since_last_save = now - self.last_save_time;
|
let time_since_last_save = now - self.last_save_time;
|
||||||
|
|
||||||
if time_since_last_save > self.app.auto_save_interval().as_secs_f64() {
|
if time_since_last_save > self.app.auto_save_interval().as_secs_f64() {
|
||||||
save_memory(&self.web_backend.egui_ctx);
|
if self.app.persist_egui_memory() {
|
||||||
|
save_memory(&self.web_backend.egui_ctx);
|
||||||
|
}
|
||||||
self.app.save(&mut self.storage);
|
self.app.save(&mut self.storage);
|
||||||
self.last_save_time = now;
|
self.last_save_time = now;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ extra_asserts = ["emath/extra_asserts"]
|
||||||
# Add compatability with https://github.com/kvark/mint
|
# Add compatability with https://github.com/kvark/mint
|
||||||
mint = ["emath/mint"]
|
mint = ["emath/mint"]
|
||||||
|
|
||||||
persistence = ["serde", "emath/serde"]
|
# implement serde on most types.
|
||||||
|
serialize = ["serde", "emath/serde"]
|
||||||
|
|
||||||
single_threaded = ["atomic_refcell"]
|
single_threaded = ["atomic_refcell"]
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
/// Internally this uses 0-255 gamma space `sRGBA` color with premultiplied alpha.
|
/// Internally this uses 0-255 gamma space `sRGBA` color with premultiplied alpha.
|
||||||
/// Alpha channel is in linear space.
|
/// Alpha channel is in linear space.
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct Color32(pub(crate) [u8; 4]);
|
pub struct Color32(pub(crate) [u8; 4]);
|
||||||
|
|
||||||
impl std::ops::Index<usize> for Color32 {
|
impl std::ops::Index<usize> for Color32 {
|
||||||
|
@ -184,7 +184,7 @@ impl Color32 {
|
||||||
|
|
||||||
/// 0-1 linear space `RGBA` color with premultiplied alpha.
|
/// 0-1 linear space `RGBA` color with premultiplied alpha.
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 Rgba(pub(crate) [f32; 4]);
|
pub struct Rgba(pub(crate) [f32; 4]);
|
||||||
|
|
||||||
impl std::ops::Index<usize> for Rgba {
|
impl std::ops::Index<usize> for Rgba {
|
||||||
|
|
|
@ -109,7 +109,7 @@ pub const WHITE_UV: emath::Pos2 = emath::pos2(0.0, 0.0);
|
||||||
|
|
||||||
/// What texture to use in a [`Mesh`] mesh.
|
/// What texture to use in a [`Mesh`] mesh.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum TextureId {
|
pub enum TextureId {
|
||||||
/// The egui font texture.
|
/// The egui font texture.
|
||||||
/// If you don't want to use a texture, pick this and the [`WHITE_UV`] for uv-coord.
|
/// If you don't want to use a texture, pick this and the [`WHITE_UV`] for uv-coord.
|
||||||
|
@ -142,7 +142,7 @@ pub struct ClippedShape(
|
||||||
///
|
///
|
||||||
/// Everything is using logical points.
|
/// Everything is using logical points.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct ClippedMesh(
|
pub struct ClippedMesh(
|
||||||
/// Clip / scissor rectangle.
|
/// Clip / scissor rectangle.
|
||||||
/// Only show the part of the [`Mesh`] that falls within this.
|
/// Only show the part of the [`Mesh`] that falls within this.
|
||||||
|
|
|
@ -6,7 +6,7 @@ use emath::*;
|
||||||
/// Should be friendly to send to GPU as is.
|
/// Should be friendly to send to GPU as is.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 Vertex {
|
pub struct Vertex {
|
||||||
/// Logical pixel coordinates (points).
|
/// Logical pixel coordinates (points).
|
||||||
/// (0,0) is the top left corner of the screen.
|
/// (0,0) is the top left corner of the screen.
|
||||||
|
@ -23,7 +23,7 @@ pub struct Vertex {
|
||||||
|
|
||||||
/// Textured triangles in two dimensions.
|
/// Textured triangles in two dimensions.
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[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 Mesh {
|
pub struct Mesh {
|
||||||
/// Draw as triangles (i.e. the length is always multiple of three).
|
/// Draw as triangles (i.e. the length is always multiple of three).
|
||||||
///
|
///
|
||||||
|
|
|
@ -3,7 +3,7 @@ use super::*;
|
||||||
/// The color and fuzziness of a fuzzy shape.
|
/// The color and fuzziness of a fuzzy shape.
|
||||||
/// Can be used for a rectangular shadow with a soft penumbra.
|
/// Can be used for a rectangular shadow with a soft penumbra.
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 Shadow {
|
pub struct Shadow {
|
||||||
/// The shadow extends this much outside the rect.
|
/// The shadow extends this much outside the rect.
|
||||||
/// The size of the fuzzy penumbra.
|
/// The size of the fuzzy penumbra.
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl Shape {
|
||||||
|
|
||||||
/// How to paint a circle.
|
/// How to paint a circle.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct CircleShape {
|
pub struct CircleShape {
|
||||||
pub center: Pos2,
|
pub center: Pos2,
|
||||||
pub radius: f32,
|
pub radius: f32,
|
||||||
|
@ -170,7 +170,7 @@ impl From<CircleShape> for Shape {
|
||||||
|
|
||||||
/// A path which can be stroked and/or filled (if closed).
|
/// A path which can be stroked and/or filled (if closed).
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct PathShape {
|
pub struct PathShape {
|
||||||
pub points: Vec<Pos2>,
|
pub points: Vec<Pos2>,
|
||||||
/// If true, connect the first and last of the points together.
|
/// If true, connect the first and last of the points together.
|
||||||
|
@ -239,7 +239,7 @@ impl From<PathShape> for Shape {
|
||||||
|
|
||||||
/// How to paint a rectangle.
|
/// How to paint a rectangle.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct RectShape {
|
pub struct RectShape {
|
||||||
pub rect: Rect,
|
pub rect: Rect,
|
||||||
/// How rounded the corners are. Use `0.0` for no rounding.
|
/// How rounded the corners are. Use `0.0` for no rounding.
|
||||||
|
|
|
@ -6,7 +6,7 @@ use super::*;
|
||||||
///
|
///
|
||||||
/// The default stroke is the same as [`Stroke::none`].
|
/// The default stroke is the same as [`Stroke::none`].
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 Stroke {
|
pub struct Stroke {
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
pub color: Color32,
|
pub color: Color32,
|
||||||
|
|
|
@ -254,8 +254,8 @@ pub enum PathType {
|
||||||
|
|
||||||
/// Tessellation quality options
|
/// Tessellation quality options
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct TessellationOptions {
|
pub struct TessellationOptions {
|
||||||
/// Size of a point in pixels, e.g. 2.0. Used to snap text to pixel boundaries.
|
/// Size of a point in pixels, e.g. 2.0. Used to snap text to pixel boundaries.
|
||||||
pub pixels_per_point: f32,
|
pub pixels_per_point: f32,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/// Character cursor
|
/// Character cursor
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[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 CCursor {
|
pub struct CCursor {
|
||||||
/// Character offset (NOT byte offset!).
|
/// Character offset (NOT byte offset!).
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
|
@ -65,7 +65,7 @@ impl std::ops::SubAssign<usize> for CCursor {
|
||||||
|
|
||||||
/// Row Cursor
|
/// Row Cursor
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[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 RCursor {
|
pub struct RCursor {
|
||||||
/// 0 is first row, and so on.
|
/// 0 is first row, and so on.
|
||||||
/// Note that a single paragraph can span multiple rows.
|
/// Note that a single paragraph can span multiple rows.
|
||||||
|
@ -80,7 +80,7 @@ pub struct RCursor {
|
||||||
|
|
||||||
/// Paragraph Cursor
|
/// Paragraph Cursor
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[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 PCursor {
|
pub struct PCursor {
|
||||||
/// 0 is first paragraph, and so on.
|
/// 0 is first paragraph, and so on.
|
||||||
/// Note that a single paragraph can span multiple rows.
|
/// Note that a single paragraph can span multiple rows.
|
||||||
|
@ -112,7 +112,7 @@ impl PartialEq for PCursor {
|
||||||
/// pcursor/rcursor can also point to after the end of the paragraph/row.
|
/// pcursor/rcursor can also point to after the end of the paragraph/row.
|
||||||
/// Does not implement `PartialEq` because you must think which cursor should be equivalent.
|
/// Does not implement `PartialEq` because you must think which cursor should be equivalent.
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[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 Cursor {
|
pub struct Cursor {
|
||||||
pub ccursor: CCursor,
|
pub ccursor: CCursor,
|
||||||
pub rcursor: RCursor,
|
pub rcursor: RCursor,
|
||||||
|
|
|
@ -12,8 +12,8 @@ use crate::{
|
||||||
// TODO: rename
|
// TODO: rename
|
||||||
/// One of a few categories of styles of text, e.g. body, button or heading.
|
/// One of a few categories of styles of text, e.g. body, button or heading.
|
||||||
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(rename_all = "snake_case"))]
|
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||||
pub enum TextStyle {
|
pub enum TextStyle {
|
||||||
/// Used when small text is needed.
|
/// Used when small text is needed.
|
||||||
Small,
|
Small,
|
||||||
|
@ -43,8 +43,8 @@ impl TextStyle {
|
||||||
|
|
||||||
/// Which style of font: [`Monospace`][`FontFamily::Monospace`] or [`Proportional`][`FontFamily::Proportional`].
|
/// Which style of font: [`Monospace`][`FontFamily::Monospace`] or [`Proportional`][`FontFamily::Proportional`].
|
||||||
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(rename_all = "snake_case"))]
|
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||||
pub enum FontFamily {
|
pub enum FontFamily {
|
||||||
/// A font where each character is the same width (`w` is the same width as `i`).
|
/// A font where each character is the same width (`w` is the same width as `i`).
|
||||||
Monospace,
|
Monospace,
|
||||||
|
@ -106,8 +106,8 @@ fn ab_glyph_font_from_font_data(name: &str, data: &FontData) -> ab_glyph::FontAr
|
||||||
/// ctx.set_fonts(fonts);
|
/// ctx.set_fonts(fonts);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct FontDefinitions {
|
pub struct FontDefinitions {
|
||||||
/// List of font names and their definitions.
|
/// List of font names and their definitions.
|
||||||
/// The definition must be the contents of either a `.ttf` or `.otf` font file.
|
/// The definition must be the contents of either a `.ttf` or `.otf` font file.
|
||||||
|
|
|
@ -13,7 +13,7 @@ use emath::*;
|
||||||
///
|
///
|
||||||
/// Pass this to [`Fonts::layout_job]` or [`crate::text::layout`].
|
/// Pass this to [`Fonts::layout_job]` or [`crate::text::layout`].
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct LayoutJob {
|
pub struct LayoutJob {
|
||||||
/// The complete text of this job, referenced by `LayoutSection`.
|
/// The complete text of this job, referenced by `LayoutSection`.
|
||||||
pub text: String, // TODO: Cow<'static, str>
|
pub text: String, // TODO: Cow<'static, str>
|
||||||
|
@ -137,7 +137,7 @@ impl std::hash::Hash for LayoutJob {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct LayoutSection {
|
pub struct LayoutSection {
|
||||||
/// Can be used for first row indentation.
|
/// Can be used for first row indentation.
|
||||||
pub leading_space: f32,
|
pub leading_space: f32,
|
||||||
|
@ -163,7 +163,7 @@ impl std::hash::Hash for LayoutSection {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Hash, PartialEq)]
|
#[derive(Copy, Clone, Debug, Hash, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct TextFormat {
|
pub struct TextFormat {
|
||||||
pub style: TextStyle,
|
pub style: TextStyle,
|
||||||
/// Text color
|
/// Text color
|
||||||
|
|
|
@ -94,7 +94,7 @@ pub trait App {
|
||||||
/// Allows you to do setup code, e.g to call `[egui::Context::set_fonts]`,
|
/// Allows you to do setup code, e.g to call `[egui::Context::set_fonts]`,
|
||||||
/// `[egui::Context::set_visuals]` etc.
|
/// `[egui::Context::set_visuals]` etc.
|
||||||
///
|
///
|
||||||
/// Also allows you to restore state, if there is a storage.
|
/// Also allows you to restore state, if there is a storage (required the "persistence" feature).
|
||||||
fn setup(
|
fn setup(
|
||||||
&mut self,
|
&mut self,
|
||||||
_ctx: &egui::CtxRef,
|
_ctx: &egui::CtxRef,
|
||||||
|
@ -113,6 +113,8 @@ pub trait App {
|
||||||
|
|
||||||
/// Called on shutdown, and perhaps at regular intervals. Allows you to save state.
|
/// Called on shutdown, and perhaps at regular intervals. Allows you to save state.
|
||||||
///
|
///
|
||||||
|
/// Only called when the "persistence" feature is enabled.
|
||||||
|
///
|
||||||
/// On web the states is stored to "Local Storage".
|
/// On web the states is stored to "Local Storage".
|
||||||
/// On native the path is picked using [`directories_next::ProjectDirs::data_dir`](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir) which is:
|
/// On native the path is picked using [`directories_next::ProjectDirs::data_dir`](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir) which is:
|
||||||
/// * Linux: `/home/UserName/.local/share/APPNAME`
|
/// * Linux: `/home/UserName/.local/share/APPNAME`
|
||||||
|
@ -150,6 +152,18 @@ pub trait App {
|
||||||
// `transparent()` option they get immediate results.
|
// `transparent()` option they get immediate results.
|
||||||
egui::Color32::from_rgba_unmultiplied(12, 12, 12, 180).into()
|
egui::Color32::from_rgba_unmultiplied(12, 12, 12, 180).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Controls wether or not the native window position and size will be
|
||||||
|
/// persisted (only if the "persistence" feature is enabled).
|
||||||
|
fn persist_native_window(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Controls wether or not the egui memory (window positions etc) will be
|
||||||
|
/// persisted (only if the "persistence" feature is enabled).
|
||||||
|
fn persist_egui_memory(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Options controlling the behavior of a native window
|
/// Options controlling the behavior of a native window
|
||||||
|
|
Loading…
Reference in a new issue