closer to using these text_svgs
Some checks failed
/ test (push) Has been cancelled

This commit is contained in:
Chris Cochrun 2025-08-29 16:41:24 -05:00
parent 1446e35c58
commit 4ccb186189
6 changed files with 112 additions and 75 deletions

View file

@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::cmp::Ordering;
use std::ops::Deref;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
use crisp::types::{Keyword, Symbol, Value};
@ -24,7 +24,7 @@ pub struct ServiceItem {
pub title: String,
pub database_id: i32,
pub kind: ServiceItemKind,
pub slides: Arc<[Slide]>,
pub slides: Vec<Slide>,
// pub item: Box<dyn ServiceTrait>,
}
@ -122,7 +122,7 @@ impl Default for ServiceItem {
title: String::default(),
database_id: 0,
kind: ServiceItemKind::Content(Slide::default()),
slides: Arc::new([]),
slides: vec![],
// item: Box::new(Image::default()),
}
}
@ -172,7 +172,7 @@ impl From<&Value> for ServiceItem {
kind: ServiceItemKind::Content(
slide.clone(),
),
slides: Arc::new([slide]),
slides: vec![slide],
}
} else if let Some(background) =
list.get(background_pos)

View file

@ -30,7 +30,7 @@ pub struct Slide {
video_start_time: f32,
video_end_time: f32,
#[serde(skip)]
pub text_svg: TextSvg,
pub text_svg: Option<TextSvg>,
}
#[derive(
@ -261,6 +261,11 @@ impl Slide {
self
}
pub fn with_text_svg(mut self, text_svg: TextSvg) -> Self {
self.text_svg = Some(text_svg);
self
}
pub fn set_font(mut self, font: impl AsRef<str>) -> Self {
self.font = font.as_ref().into();
self
@ -284,6 +289,10 @@ impl Slide {
self.text.clone()
}
pub fn text_alignment(&self) -> TextAlignment {
self.text_alignment.clone()
}
pub fn font_size(&self) -> i32 {
self.font_size
}
@ -623,45 +632,19 @@ impl SlideBuilder {
let Some(video_end_time) = self.video_end_time else {
return Err(miette!("No video_end_time"));
};
if let Some(text_svg) = self.text_svg {
Ok(Slide {
background,
text,
font,
font_size,
text_alignment,
audio: self.audio,
video_loop,
video_start_time,
video_end_time,
text_svg,
..Default::default()
})
} else {
let text_svg = TextSvg::new(text.clone())
.alignment(text_alignment)
.fill("#fff")
.shadow(text_svg::shadow(2, 2, 5, "#000000"))
.stroke(text_svg::stroke(3, "#000"))
.font(
text_svg::Font::from(font.clone())
.size(font_size.try_into().unwrap()),
)
.build();
Ok(Slide {
background,
text,
font,
font_size,
text_alignment,
audio: self.audio,
video_loop,
video_start_time,
video_end_time,
text_svg,
..Default::default()
})
}
Ok(Slide {
background,
text,
font,
font_size,
text_alignment,
audio: self.audio,
video_loop,
video_start_time,
video_end_time,
text_svg: self.text_svg,
..Default::default()
})
}
}