From 6fcabad45c22a88221e324907e71fe748725ff3c Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 17 Mar 2025 07:26:44 -0500 Subject: [PATCH] testing out svg as a text option instead of using the text element The text element has little options for heavily styling the text. I think I'll start to build a dedicated text element from SVGs instead. This will ensure that I can add strokes and drop-shadows. --- src/ui/song_editor.rs | 54 ++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index 86727c7..a2c5563 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -7,12 +7,13 @@ use cosmic::{ Font, Length, }, iced_wgpu::graphics::text::cosmic_text::fontdb, - iced_widget::row, + iced_widget::{row, stack}, theme, widget::{ button, column, combo_box, container, dropdown, - horizontal_space, icon, scrollable, text, text_editor, - text_input, + horizontal_space, icon, scrollable, + svg::{self, Handle}, + text, text_editor, text_input, Svg, }, Element, Task, }; @@ -305,25 +306,36 @@ impl SongEditor { .into_iter() .enumerate() .map(|(index, slide)| { - container( - slide_view( - slide, - if index == 0 { - &self.video - } else { - &None - }, - self.current_font, - false, - false, + let svg = Handle::from_memory(r#" + + + + + + + Hello World +"#.as_bytes()); + stack!( + container( + slide_view( + slide, + if index == 0 { + &self.video + } else { + &None + }, + self.current_font, + false, + false, + ) + .map(|_| Message::None), ) - .map(|_| Message::None), - ) - .height(250) - .center_x(Length::Fill) - .padding([0, 20]) - .clip(true) - .into() + .height(250) + .center_x(Length::Fill) + .padding([0, 20]) + .clip(true), + Svg::new(svg), + ).into() }) .collect(); scrollable(