Restructure Theme with new style objects

This commit is contained in:
Max Brunsfeld
2021-08-03 13:36:58 -07:00
parent ef0ffbe819
commit 81041d7841
10 changed files with 218 additions and 169 deletions
+23 -7
View File
@@ -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,
}
+3 -1
View File
@@ -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>,
+10
View File
@@ -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,