diff --git a/src/core/slide.rs b/src/core/slide.rs index 048bcb3..a864f3d 100644 --- a/src/core/slide.rs +++ b/src/core/slide.rs @@ -12,7 +12,7 @@ use std::{ }; use tracing::error; -use crate::ui::text_svg::TextSvg; +use crate::ui::text_svg::{Shadow, Stroke, TextSvg}; use super::songs::Song; @@ -25,18 +25,17 @@ pub struct Slide { text: String, font: String, font_size: i32, - stroke_size: i32, - stroke_color: Option, + stroke: Option, + shadow: Option, text_alignment: TextAlignment, audio: Option, video_loop: bool, video_start_time: f32, video_end_time: f32, pdf_index: u32, + pub text_svg: Option, #[serde(skip)] pdf_page: Option, - #[serde(skip)] - pub text_svg: Option, } #[derive( diff --git a/src/ui/text_svg.rs b/src/ui/text_svg.rs index e8f7a4f..4697d61 100644 --- a/src/ui/text_svg.rs +++ b/src/ui/text_svg.rs @@ -6,7 +6,7 @@ use std::{ }; use cosmic::{ - cosmic_theme::palette::Srgb, + cosmic_theme::palette::{IntoColor, Srgb, rgb::Rgba}, iced::{ ContentFit, Length, Size, font::{Style, Weight}, @@ -25,7 +25,7 @@ use tracing::error; use crate::TextAlignment; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct TextSvg { text: String, font: Font, @@ -33,7 +33,9 @@ pub struct TextSvg { stroke: Option, fill: Color, alignment: TextAlignment, + #[serde(skip)] pub handle: Option, + #[serde(skip)] fontdb: Arc, } @@ -60,7 +62,9 @@ impl Hash for TextSvg { } } -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +#[derive( + Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize, +)] pub struct Font { name: String, weight: Weight, @@ -188,6 +192,19 @@ impl Color { } } +impl From for Color { + fn from(value: Rgba) -> Self { + let rgba: Srgb = value.into_color(); + Self(rgba) + } +} + +impl From for Color { + fn from(value: Srgb) -> Self { + Self(value) + } +} + impl From<&str> for Color { fn from(value: &str) -> Self { Self::from_hex_str(value)