From b95e76eff44c630ac1480efdef3dc76a59cd246b Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 5 May 2025 10:37:51 -0500 Subject: [PATCH] updating text_svg to perhaps contain the handle --- src/ui/presenter.rs | 50 ++++++++++++++++++++++----------------------- src/ui/text_svg.rs | 3 +++ todo.org | 1 + 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 34268dd..12a7c13 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -543,37 +543,37 @@ pub(crate) fn slide_view( responsive(move |size| { let width = size.height * 16.0 / 9.0; let font_size = scale_font(slide.font_size() as f32, width); - let font = SvgFont::from(font).size(font_size.floor() as u8); let slide_text = slide.text(); // SVG based - 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 2a4dac5..47dcbae 100644 --- a/src/ui/text_svg.rs +++ b/src/ui/text_svg.rs @@ -24,6 +24,7 @@ pub struct TextSvg { stroke: Option, fill: Color, alignment: TextAlignment, + handle: Option, } impl Hash for TextSvg { @@ -173,6 +174,8 @@ impl TextSvg { } } + pub fn build(self) + pub fn fill(mut self, color: impl Into) -> Self { self.fill = color.into(); self diff --git a/todo.org b/todo.org index 2c42ef7..0a8457a 100644 --- a/todo.org +++ b/todo.org @@ -1,6 +1,7 @@ #+TITLE: The Task list for Lumina +* TODO Check into =mupdf-rs= for loading PDF's. * TODO [#A] Text could be built by using SVG instead of the text element. Maybe I could construct my own text element even This does almost work. There is a clear amount of lag or rather hang up since switching to the =text_svg= element. I think I may only keep it till I can figure out how to do strokes and shadows in iced's normal text element.