make TextSvg and Slide better designed

This commit is contained in:
Chris Cochrun 2026-02-09 15:04:07 -06:00
parent 87655baa76
commit e006068863
2 changed files with 24 additions and 8 deletions

View file

@ -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<Rgba>,
stroke: Option<Stroke>,
shadow: Option<Shadow>,
text_alignment: TextAlignment,
audio: Option<PathBuf>,
video_loop: bool,
video_start_time: f32,
video_end_time: f32,
pdf_index: u32,
pub text_svg: Option<TextSvg>,
#[serde(skip)]
pdf_page: Option<Handle>,
#[serde(skip)]
pub text_svg: Option<TextSvg>,
}
#[derive(

View file

@ -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<Stroke>,
fill: Color,
alignment: TextAlignment,
#[serde(skip)]
pub handle: Option<Handle>,
#[serde(skip)]
fontdb: Arc<resvg::usvg::fontdb::Database>,
}
@ -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<Rgba> for Color {
fn from(value: Rgba) -> Self {
let rgba: Srgb = value.into_color();
Self(rgba)
}
}
impl From<Srgb> for Color {
fn from(value: Srgb) -> Self {
Self(value)
}
}
impl From<&str> for Color {
fn from(value: &str) -> Self {
Self::from_hex_str(value)