Restructure Theme with new style objects
This commit is contained in:
@@ -16,12 +16,18 @@ use crate::{
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct ContainerStyle {
|
||||
margin: Margin,
|
||||
padding: Padding,
|
||||
background_color: Option<Color>,
|
||||
border: Border,
|
||||
corner_radius: f32,
|
||||
shadow: Option<Shadow>,
|
||||
#[serde(default)]
|
||||
pub margin: Margin,
|
||||
#[serde(default)]
|
||||
pub padding: Padding,
|
||||
#[serde(rename = "background")]
|
||||
pub background_color: Option<Color>,
|
||||
#[serde(default)]
|
||||
pub border: Border,
|
||||
#[serde(default)]
|
||||
pub corner_radius: f32,
|
||||
#[serde(default)]
|
||||
pub shadow: Option<Shadow>,
|
||||
}
|
||||
|
||||
pub struct Container {
|
||||
@@ -247,9 +253,13 @@ impl ToJson for ContainerStyle {
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct Margin {
|
||||
#[serde(default)]
|
||||
top: f32,
|
||||
#[serde(default)]
|
||||
left: f32,
|
||||
#[serde(default)]
|
||||
bottom: f32,
|
||||
#[serde(default)]
|
||||
right: f32,
|
||||
}
|
||||
|
||||
@@ -274,9 +284,13 @@ impl ToJson for Margin {
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct Padding {
|
||||
#[serde(default)]
|
||||
top: f32,
|
||||
#[serde(default)]
|
||||
left: f32,
|
||||
#[serde(default)]
|
||||
bottom: f32,
|
||||
#[serde(default)]
|
||||
right: f32,
|
||||
}
|
||||
|
||||
@@ -301,9 +315,11 @@ impl ToJson for Padding {
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct Shadow {
|
||||
#[serde(deserialize_with = "deserialize_vec2f")]
|
||||
#[serde(default, deserialize_with = "deserialize_vec2f")]
|
||||
offset: Vector2F,
|
||||
#[serde(default)]
|
||||
blur: f32,
|
||||
#[serde(default)]
|
||||
color: Color,
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,11 @@ pub struct Label {
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct LabelStyle {
|
||||
#[serde(default = "Color::black")]
|
||||
pub color: Color,
|
||||
#[serde(default)]
|
||||
pub highlight_color: Option<Color>,
|
||||
#[serde(deserialize_with = "deserialize_font_properties")]
|
||||
#[serde(default, deserialize_with = "deserialize_font_properties")]
|
||||
pub font_properties: Properties,
|
||||
#[serde(default, deserialize_with = "deserialize_option_font_properties")]
|
||||
pub highlight_font_properties: Option<Properties>,
|
||||
|
||||
@@ -59,14 +59,24 @@ pub struct Icon {
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, Deserialize)]
|
||||
pub struct Border {
|
||||
#[serde(default = "default_border_width")]
|
||||
pub width: f32,
|
||||
#[serde(default)]
|
||||
pub color: Option<Color>,
|
||||
#[serde(default)]
|
||||
pub top: bool,
|
||||
#[serde(default)]
|
||||
pub right: bool,
|
||||
#[serde(default)]
|
||||
pub bottom: bool,
|
||||
#[serde(default)]
|
||||
pub left: bool,
|
||||
}
|
||||
|
||||
fn default_border_width() -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Path {
|
||||
pub bounds: RectF,
|
||||
|
||||
Reference in New Issue
Block a user