Merge remote-tracking branch 'origin/main' into save-conversations
This commit is contained in:
commit
6f0efec146
112 changed files with 4161 additions and 1653 deletions
|
@ -6,15 +6,16 @@ use std::{
|
|||
|
||||
use crate::json::ToJson;
|
||||
use pathfinder_color::{ColorF, ColorU};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{
|
||||
de::{self, Unexpected},
|
||||
Deserialize, Deserializer,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord, JsonSchema)]
|
||||
#[repr(transparent)]
|
||||
pub struct Color(ColorU);
|
||||
pub struct Color(#[schemars(with = "String")] ColorU);
|
||||
|
||||
impl Color {
|
||||
pub fn transparent_black() -> Self {
|
||||
|
|
|
@ -12,10 +12,11 @@ use crate::{
|
|||
scene::{self, Border, CursorRegion, Quad},
|
||||
AnyElement, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
|
||||
pub struct ContainerStyle {
|
||||
#[serde(default)]
|
||||
pub margin: Margin,
|
||||
|
@ -332,7 +333,7 @@ impl ToJson for ContainerStyle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[derive(Clone, Copy, Debug, Default, JsonSchema)]
|
||||
pub struct Margin {
|
||||
pub top: f32,
|
||||
pub left: f32,
|
||||
|
@ -359,7 +360,7 @@ impl ToJson for Margin {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[derive(Clone, Copy, Debug, Default, JsonSchema)]
|
||||
pub struct Padding {
|
||||
pub top: f32,
|
||||
pub left: f32,
|
||||
|
@ -486,9 +487,10 @@ impl ToJson for Padding {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
|
||||
pub struct Shadow {
|
||||
#[serde(default, deserialize_with = "deserialize_vec2f")]
|
||||
#[schemars(with = "Vec::<f32>")]
|
||||
offset: Vector2F,
|
||||
#[serde(default)]
|
||||
blur: f32,
|
||||
|
|
|
@ -8,6 +8,7 @@ use crate::{
|
|||
scene, Border, Element, ImageData, LayoutContext, SceneBuilder, SizeConstraint, View,
|
||||
ViewContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
|
||||
|
@ -21,7 +22,7 @@ pub struct Image {
|
|||
style: ImageStyle,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, Deserialize)]
|
||||
#[derive(Copy, Clone, Default, Deserialize, JsonSchema)]
|
||||
pub struct ImageStyle {
|
||||
#[serde(default)]
|
||||
pub border: Border,
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::{
|
|||
text_layout::{Line, RunStyle},
|
||||
Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
@ -20,7 +21,7 @@ pub struct Label {
|
|||
highlight_indices: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, Debug, Deserialize, Default, JsonSchema)]
|
||||
pub struct LabelStyle {
|
||||
pub text: TextStyle,
|
||||
pub highlight_text: Option<TextStyle>,
|
||||
|
|
|
@ -8,6 +8,7 @@ use crate::{
|
|||
},
|
||||
scene, Element, LayoutContext, SceneBuilder, SizeConstraint, View, ViewContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde_derive::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::{borrow::Cow, ops::Range};
|
||||
|
@ -115,14 +116,14 @@ impl<V: View> Element<V> for Svg {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
#[derive(Clone, Deserialize, Default, JsonSchema)]
|
||||
pub struct SvgStyle {
|
||||
pub color: Color,
|
||||
pub asset: String,
|
||||
pub dimensions: Dimensions,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
#[derive(Clone, Deserialize, Default, JsonSchema)]
|
||||
pub struct Dimensions {
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
Action, Axis, ElementStateHandle, LayoutContext, SceneBuilder, SizeConstraint, Task, View,
|
||||
ViewContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
cell::{Cell, RefCell},
|
||||
|
@ -33,7 +34,7 @@ struct TooltipState {
|
|||
debounce: RefCell<Option<Task<()>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
#[derive(Clone, Deserialize, Default, JsonSchema)]
|
||||
pub struct TooltipStyle {
|
||||
#[serde(flatten)]
|
||||
pub container: ContainerStyle,
|
||||
|
@ -42,7 +43,7 @@ pub struct TooltipStyle {
|
|||
pub max_text_width: Option<f32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
#[derive(Clone, Deserialize, Default, JsonSchema)]
|
||||
pub struct KeystrokeStyle {
|
||||
#[serde(flatten)]
|
||||
container: ContainerStyle,
|
||||
|
|
|
@ -7,13 +7,14 @@ use crate::{
|
|||
use anyhow::{anyhow, Result};
|
||||
use ordered_float::OrderedFloat;
|
||||
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
||||
use schemars::JsonSchema;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)]
|
||||
pub struct FamilyId(usize);
|
||||
|
||||
struct Family {
|
||||
|
|
|
@ -16,7 +16,7 @@ use serde::{de, Deserialize, Serialize};
|
|||
use serde_json::Value;
|
||||
use std::{cell::RefCell, sync::Arc};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, JsonSchema)]
|
||||
pub struct FontId(pub usize);
|
||||
|
||||
pub type GlyphId = u32;
|
||||
|
@ -59,20 +59,44 @@ pub struct Features {
|
|||
pub zero: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, JsonSchema)]
|
||||
pub struct TextStyle {
|
||||
pub color: Color,
|
||||
pub font_family_name: Arc<str>,
|
||||
pub font_family_id: FamilyId,
|
||||
pub font_id: FontId,
|
||||
pub font_size: f32,
|
||||
#[schemars(with = "PropertiesDef")]
|
||||
pub font_properties: Properties,
|
||||
pub underline: Underline,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||
#[derive(JsonSchema)]
|
||||
#[serde(remote = "Properties")]
|
||||
pub struct PropertiesDef {
|
||||
/// The font style, as defined in CSS.
|
||||
pub style: StyleDef,
|
||||
/// The font weight, as defined in CSS.
|
||||
pub weight: f32,
|
||||
/// The font stretchiness, as defined in CSS.
|
||||
pub stretch: f32,
|
||||
}
|
||||
|
||||
#[derive(JsonSchema)]
|
||||
#[schemars(remote = "Style")]
|
||||
pub enum StyleDef {
|
||||
/// A face that is neither italic not obliqued.
|
||||
Normal,
|
||||
/// A form that is generally cursive in nature.
|
||||
Italic,
|
||||
/// A typically-sloped version of the regular face.
|
||||
Oblique,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, JsonSchema)]
|
||||
pub struct HighlightStyle {
|
||||
pub color: Option<Color>,
|
||||
#[schemars(with = "Option::<f32>")]
|
||||
pub weight: Option<Weight>,
|
||||
pub italic: Option<bool>,
|
||||
pub underline: Option<Underline>,
|
||||
|
@ -81,9 +105,10 @@ pub struct HighlightStyle {
|
|||
|
||||
impl Eq for HighlightStyle {}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, JsonSchema)]
|
||||
pub struct Underline {
|
||||
pub color: Option<Color>,
|
||||
#[schemars(with = "f32")]
|
||||
pub thickness: OrderedFloat<f32>,
|
||||
pub squiggly: bool,
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ use anyhow::{anyhow, bail, Result};
|
|||
use async_task::Runnable;
|
||||
pub use event::*;
|
||||
use postage::oneshot;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use sqlez::{
|
||||
bindable::{Bind, Column, StaticColumnCount},
|
||||
|
@ -282,7 +283,7 @@ pub enum PromptLevel {
|
|||
Critical,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, Deserialize, JsonSchema)]
|
||||
pub enum CursorStyle {
|
||||
Arrow,
|
||||
ResizeLeftRight,
|
||||
|
|
|
@ -3,6 +3,7 @@ mod mouse_region;
|
|||
|
||||
#[cfg(debug_assertions)]
|
||||
use collections::HashSet;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
|
@ -99,7 +100,7 @@ pub struct Icon {
|
|||
pub color: Color,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug)]
|
||||
#[derive(Clone, Copy, Default, Debug, JsonSchema)]
|
||||
pub struct Border {
|
||||
pub width: f32,
|
||||
pub color: Color,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue