From 73baad8ae60782e3680391b2c6f41e8a76803252 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 23 Apr 2025 13:49:34 -0500 Subject: [PATCH] turns out svg's are terribly expensive in iced --- Cargo.lock | 1 - Cargo.toml | 2 +- src/ui/presenter.rs | 37 +++++++++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56582d0..827ff3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4099,7 +4099,6 @@ dependencies = [ "lazy_static", "palette 0.7.6", "rfd", - "ron 0.9.0", "serde", "slotmap", "taffy", diff --git a/Cargo.toml b/Cargo.toml index 7f97217..3736d89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ description = "A cli presentation system" [dependencies] clap = { version = "4.5.20", features = ["debug", "derive"] } -libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["debug", "winit", "tokio", "rfd", "dbus-config", "a11y", "wgpu", "multi-window", "single-instance" ] } +libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["debug", "winit", "winit_wgpu", "tokio", "rfd", "dbus-config", "a11y", "wgpu", "multi-window"] } lexpr = "0.2.7" miette = { version = "7.2.0", features = ["fancy"] } pretty_assertions = "1.4.1" diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 5eeb1cf..d8b1f6a 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -13,7 +13,7 @@ use cosmic::{ scrollable::{ scroll_to, AbsoluteOffset, Direction, Scrollbar, }, - span, stack, + span, stack, text, }, prelude::*, widget::{ @@ -546,16 +546,33 @@ pub(crate) fn slide_view<'a>( 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 font = SvgFont::from(font).size(font_size.floor() as u8); let slide_text = slide.text(); - let text = text_svg::TextSvg::new() - .text(slide_text) - .fill("#fff") - .shadow(shadow(2, 2, 5, "#000000")) - .stroke(stroke(1, "#000")) - .font(font) - .view() - .map(|m| Message::None); + // let text = text_svg::TextSvg::new() + // .text(&slide_text) + // .fill("#fff") + // .shadow(shadow(2, 2, 5, "#000000")) + // .stroke(stroke(1, "#000")) + // .font(font) + // .view() + // .map(|m| Message::None); + // let text = text!("{}", &slide_text); + let lines = slide_text.lines(); + let text: Vec> = lines + .map(|t| { + rich_text([span(format!("{}\n", t.to_string())) + .background( + Background::Color(Color::BLACK) + .scale_alpha(0.4), + ) + .padding(3)]) + .size(font_size) + .font(font) + .center() + .into() + }) + .collect(); + let text = Column::with_children(text).spacing(6); let text_container = Container::new(text) .center(Length::Fill) .align_x(Horizontal::Left);