From 049e5bd7cc631b203b5da1e3641523f24d9cd4d0 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 3 Jul 2025 21:59:52 -0500 Subject: [PATCH] fixing text_svg --- src/ui/presenter.rs | 50 ++++++++++++++++++++++----------------------- src/ui/text_svg.rs | 4 ++-- todo.org | 4 +++- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 12a7c13..d3bd197 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -546,34 +546,34 @@ pub(crate) fn slide_view( let slide_text = slide.text(); // SVG based - // let font = SvgFont::from(font).size(font_size.floor() as u8); - // let text = text_svg::TextSvg::new() - // .text(&slide_text) - // .fill("#fff") - // .shadow(text_svg::shadow(2, 2, 5, "#000000")) - // .stroke(text_svg::stroke(1, "#000")) - // .font(font) - // .view() - // .map(|m| Message::None); + let font = SvgFont::from(font).size(font_size.floor() as u8); + let text = text_svg::TextSvg::new() + .text(&slide_text) + .fill("#fff") + .shadow(text_svg::shadow(2, 2, 5, "#000000")) + .stroke(text_svg::stroke(1, "#000")) + .font(font) + .view() + .map(|m| Message::None); // let text = text!("{}", &slide_text); // text widget based - let lines = slide_text.lines(); - let text: Vec> = lines - .map(|t| { - rich_text([span(format!("{}\n", t)) - .background( - Background::Color(Color::BLACK) - .scale_alpha(0.4), - ) - .padding(1)]) - .size(font_size) - .font(font) - .center() - .into() - }) - .collect(); - let text = Column::with_children(text).spacing(6); + // let lines = slide_text.lines(); + // let text: Vec> = lines + // .map(|t| { + // rich_text([span(format!("{}\n", t)) + // .background( + // Background::Color(Color::BLACK) + // .scale_alpha(0.4), + // ) + // .padding(1)]) + // .size(font_size) + // .font(font) + // .center() + // .into() + // }) + // .collect(); + // let text = Column::with_children(text).spacing(6); //Next let text_container = Container::new(text) diff --git a/src/ui/text_svg.rs b/src/ui/text_svg.rs index 4401004..69141e8 100644 --- a/src/ui/text_svg.rs +++ b/src/ui/text_svg.rs @@ -249,11 +249,11 @@ impl TextSvg { self.fill, stroke, text); // debug!(final_svg); - lazy(self.clone(), move |_s| Svg::new(Handle::from_memory( +Svg::new(Handle::from_memory( Box::leak(::clone(&final_svg).into_boxed_str()).as_bytes(), )) .width(Length::Fill) - .height(Length::Fill)) + .height(Length::Fill) .into() })).width(Length::Fill).height(Length::Fill).into() } diff --git a/todo.org b/todo.org index 0a8457a..4426e4c 100644 --- a/todo.org +++ b/todo.org @@ -7,9 +7,11 @@ This does almost work. There is a clear amount of lag or rather hang up since sw Actually, what if we just made the svg at load/creation time and stored it in the file system for later, then load the entire songs svg's into memory during the presentation to speed things up? Would that be faster than creating them at on the fly? Is it the creation of them that is slow or the rendering? -** SVG performs badly +** ~SVG performs badly~ JK lolZ!! Since SVG's apparently run poorly in iced, instead I'll need to see about either creating a new text element, or teaching Iced to render strokes and shadows on text. +Apparently svg was slow due to the lazy widget, which idk why I used in the first place. + * TODO [#C] Make the presenter more modular so things are easier to change. * TODO [#A] Need to fix tests now that the basic app is working