mirror of
https://github.com/danbulant/cushy
synced 2026-06-18 22:11:34 +00:00
serde feature
This commit is contained in:
parent
7e69846909
commit
8eaf0f414f
7 changed files with 53 additions and 18 deletions
|
|
@ -130,6 +130,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
`ModifiersState` type. Specifically, this trait adds an associated `PRIMARY`
|
||||
constant that resolves to the primary shortcut modifier on the target
|
||||
platform.
|
||||
- New feature flag `serde` enables serialization support for some types.
|
||||
|
||||
|
||||
[139]: https://github.com/khonsulabs/cushy/issues/139
|
||||
|
|
|
|||
22
Cargo.lock
generated
22
Cargo.lock
generated
|
|
@ -685,6 +685,7 @@ dependencies = [
|
|||
"png",
|
||||
"pollster",
|
||||
"rand",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
|
|
@ -766,9 +767,9 @@ checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
|
|||
|
||||
[[package]]
|
||||
name = "easing-function"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5699e572f2ece3d6ea49a528341097d26117751ea0a8ed3adab747bb6e96c480"
|
||||
checksum = "1ff18235504129e34c411871066cfa4ad108ed6a28d5fb2417057aff7f99bee4"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
|
|
@ -863,6 +864,7 @@ dependencies = [
|
|||
"bytemuck",
|
||||
"euclid",
|
||||
"intentional",
|
||||
"serde",
|
||||
"wgpu",
|
||||
"winit",
|
||||
]
|
||||
|
|
@ -2124,9 +2126,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
|||
|
||||
[[package]]
|
||||
name = "plotters"
|
||||
version = "0.3.6"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3"
|
||||
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"plotters-backend",
|
||||
|
|
@ -2596,18 +2598,18 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.209"
|
||||
version = "1.0.210"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
|
||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.209"
|
||||
version = "1.0.210"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
|
||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -2922,9 +2924,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.39.3"
|
||||
version = "1.40.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5"
|
||||
checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"pin-project-lite",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ roboto-flex = []
|
|||
plotters = ["dep:plotters", "kludgine/plotters"]
|
||||
tokio = ["dep:tokio"]
|
||||
tokio-multi-thread = ["tokio", "tokio/rt-multi-thread"]
|
||||
serde = ["dep:serde", "figures/serde"]
|
||||
|
||||
[dependencies]
|
||||
kludgine = { git = "https://github.com/khonsulabs/kludgine", features = [
|
||||
|
|
@ -31,7 +32,7 @@ interner = "0.2.1"
|
|||
kempt = "0.2.1"
|
||||
intentional = "0.1.0"
|
||||
tracing = "0.1.40"
|
||||
tokio = { version = "1.37.0", optional = true, features = ["rt"] }
|
||||
tokio = { version = "1.40.0", optional = true, features = ["rt"] }
|
||||
|
||||
tracing-subscriber = { version = "0.3", optional = true, features = [
|
||||
"env-filter",
|
||||
|
|
@ -45,10 +46,11 @@ unicode-segmentation = "1.10.1"
|
|||
pollster = "0.3.0"
|
||||
png = "0.17.10"
|
||||
image = { version = "0.25.0", features = ["png"] }
|
||||
plotters = { version = "0.3.5", default-features = false, optional = true }
|
||||
plotters = { version = "0.3.7", default-features = false, optional = true }
|
||||
nominals = "0.3.0"
|
||||
parking_lot = "0.12.1"
|
||||
easing-function = "0.1.0"
|
||||
easing-function = "0.1.1"
|
||||
serde = { version = "1.0.210", features = ["derive"], optional = true }
|
||||
|
||||
|
||||
# [patch.crates-io]
|
||||
|
|
|
|||
|
|
@ -1188,6 +1188,8 @@ fn color_lerp() {
|
|||
///
|
||||
/// Because of these restrictions, this type implements `Ord` and `Eq`.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||
pub struct ZeroToOne(f32);
|
||||
|
||||
impl ZeroToOne {
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ impl Styles {
|
|||
context: &WidgetContext<'_>,
|
||||
) -> Fallback::ComponentType
|
||||
where
|
||||
Fallback: ComponentDefinition + ?Sized,
|
||||
Fallback: ComponentDefinition,
|
||||
{
|
||||
self.0
|
||||
.components
|
||||
|
|
@ -166,7 +166,7 @@ impl Styles {
|
|||
context: &WidgetContext<'_>,
|
||||
) -> Option<Named::ComponentType>
|
||||
where
|
||||
Named: ComponentDefinition + ?Sized,
|
||||
Named: ComponentDefinition,
|
||||
{
|
||||
self.0
|
||||
.components
|
||||
|
|
@ -179,7 +179,7 @@ impl Styles {
|
|||
#[must_use]
|
||||
pub fn get<Named>(&self, component: &Named, context: &WidgetContext<'_>) -> Named::ComponentType
|
||||
where
|
||||
Named: ComponentDefinition + ?Sized,
|
||||
Named: ComponentDefinition,
|
||||
{
|
||||
self.try_get(component, context)
|
||||
.unwrap_or_else(|| component.default_value(context))
|
||||
|
|
@ -680,6 +680,7 @@ impl TryFrom<Component> for CornerRadii<Dimension> {
|
|||
|
||||
/// A 1-dimensional measurement that may be automatically calculated.
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum FlexibleDimension {
|
||||
/// Automatically calculate this dimension.
|
||||
Auto,
|
||||
|
|
@ -733,6 +734,7 @@ impl From<Lp> for FlexibleDimension {
|
|||
|
||||
/// A 1-dimensional measurement.
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum Dimension {
|
||||
/// Physical Pixels
|
||||
Px(Px),
|
||||
|
|
@ -863,6 +865,7 @@ impl Div<f32> for Dimension {
|
|||
|
||||
/// A range of [`Dimension`]s.
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct DimensionRange {
|
||||
/// The start bound of the range.
|
||||
pub start: Bound<Dimension>,
|
||||
|
|
@ -2078,6 +2081,7 @@ impl From<Hsl> for Color {
|
|||
|
||||
/// A 2d ordering configuration.
|
||||
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct VisualOrder {
|
||||
/// The ordering to apply horizontally.
|
||||
pub horizontal: HorizontalOrder,
|
||||
|
|
@ -2139,6 +2143,7 @@ impl RequireInvalidation for VisualOrder {
|
|||
|
||||
/// A horizontal direction.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum HorizontalOrder {
|
||||
/// Describes an order starting at the left and proceeding to the right.
|
||||
LeftToRight,
|
||||
|
|
@ -2166,6 +2171,7 @@ impl HorizontalOrder {
|
|||
|
||||
/// A vertical direction.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum VerticalOrder {
|
||||
/// Describes an order starting at the top and proceeding to the bottom.
|
||||
TopToBottom,
|
||||
|
|
@ -2201,6 +2207,7 @@ impl VerticalOrder {
|
|||
/// A configuration option to control which controls should be able to receive
|
||||
/// focus through keyboard focus handling or initial focus handling.
|
||||
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum FocusableWidgets {
|
||||
/// Allow all widgets that can respond to keyboard input to accept focus.
|
||||
#[default]
|
||||
|
|
@ -2249,6 +2256,7 @@ impl RequireInvalidation for FocusableWidgets {
|
|||
/// A description of the level of depth a
|
||||
/// [`Container`](crate::widgets::Container) is nested at.
|
||||
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ContainerLevel {
|
||||
/// The lowest container level.
|
||||
#[default]
|
||||
|
|
|
|||
|
|
@ -1524,6 +1524,26 @@ macro_rules! impl_cow_string {
|
|||
}
|
||||
|
||||
impl<T> InputValue<$type> for T where T: IntoDynamic<$type> {}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl serde::Serialize for $type {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
self.0.serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de> serde::Deserialize<'de> for $type {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
String::deserialize(deserializer).map(Self::from)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1018,8 +1018,8 @@ where
|
|||
/// - `WM_CLASS` on X11
|
||||
/// - application ID on wayland
|
||||
/// - class name on windows
|
||||
pub fn app_name(mut self, name: String) -> Self {
|
||||
self.attributes.app_name = Some(name);
|
||||
pub fn app_name(mut self, name: impl Into<String>) -> Self {
|
||||
self.attributes.app_name = Some(name.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue