From 2408404ff408abaccedf93d17ceaea15a37c14b9 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 11 Nov 2024 12:02:42 -0600 Subject: [PATCH] adding ron to slide serializing... It's possible I could use this as a method of creating slides in text form. It's vastly easier to implement. --- Cargo.lock | 1 + Cargo.toml | 1 + src/core/lisp.rs | 3 ++- src/core/slide.rs | 51 ++++++++++++++++++++++++++++--------------- test_presentation.ron | 31 ++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 test_presentation.ron diff --git a/Cargo.lock b/Cargo.lock index 781b507..589b7a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3132,6 +3132,7 @@ dependencies = [ "libcosmic", "miette", "pretty_assertions", + "ron", "serde", "serde-lexpr", "strum", diff --git a/Cargo.toml b/Cargo.toml index bda8ef0..bbd806d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,4 @@ tracing-subscriber = { version = "0.3.18", features = ["fmt", "std", "chrono", " iced_video_player = { git = "https://github.com/jackpot51/iced_video_player", branch = "cosmic", features = ["wgpu"] } strum = "0.26.3" strum_macros = "0.26.4" +ron = "0.8.1" diff --git a/src/core/lisp.rs b/src/core/lisp.rs index c602558..efbb30f 100644 --- a/src/core/lisp.rs +++ b/src/core/lisp.rs @@ -27,9 +27,10 @@ pub(crate) enum Keyword { ImageFit(ImageFit), } -#[derive(Debug, Clone, PartialEq, Eq, EnumString)] +#[derive(Debug, Default, Clone, PartialEq, Eq, EnumString)] pub(crate) enum ImageFit { #[strum(ascii_case_insensitive)] + #[default] Cover, #[strum(ascii_case_insensitive)] Fill, diff --git a/src/core/slide.rs b/src/core/slide.rs index 4c25760..ae2ca4d 100644 --- a/src/core/slide.rs +++ b/src/core/slide.rs @@ -316,25 +316,25 @@ fn build_image_bg(atom: &Value, image_map: &mut HashMap, map_ind } } -fn build_slide(exp: Value) -> Result { - let mut slide_builder = SlideBuilder::new(); - let mut keyword = "idk"; - for value in exp.as_cons().unwrap().to_vec().0 { - let mut vecs = vec![vec![]]; - match value { - Value::Symbol(symbol) => {} - Value::Keyword(keyword) => {} - Value::String(string) => {} - Value::Number(num) => {} - Value::Cons(cons) => { - vecs.push(get_lists(&value)); - } - _ => {} - } - } +// fn build_slide(exp: Value) -> Result { +// let mut slide_builder = SlideBuilder::new(); +// let mut keyword = "idk"; +// for value in exp.as_cons().unwrap().to_vec().0 { +// let mut vecs = vec![vec![]]; +// match value { +// Value::Symbol(symbol) => {} +// Value::Keyword(keyword) => {} +// Value::String(string) => {} +// Value::Number(num) => {} +// Value::Cons(cons) => { +// vecs.push(get_lists(&value)); +// } +// _ => {} +// } +// } - todo!() -} +// todo!() +// } fn build_slides( cons: &lexpr::Cons, @@ -429,4 +429,19 @@ mod test { let test_slide = test_slide(); assert_eq!(slide, test_slide) } + + #[test] + fn test_ron_deserialize() { + let slide = read_to_string("./test_presentation.ron").expect("Problem getting file read"); + match ron::from_str::>(&slide) { + Ok(s) => { + dbg!(s); + assert!(true) + } + Err(e) => { + dbg!(e); + assert!(false) + } + } + } } diff --git a/test_presentation.ron b/test_presentation.ron new file mode 100644 index 0000000..bfe3218 --- /dev/null +++ b/test_presentation.ron @@ -0,0 +1,31 @@ +[ + ( + id: 0, + background: Background( + path: "~/pics/frodo.jpg", + kind: Image + ), + text: "This is Frodo", + font: "Quicksand", + font_size: 50, + text_alignment: MiddleCenter, + video_loop: false, + video_start_time: 0.0, + video_end_time: 0.0, + ), + + ( + id: 0, + background: Background( + path: "~/vids/test/chosensmol.mp4", + kind: Video + ), + text: "This is Frodo", + font: "Quicksand", + font_size: 50, + text_alignment: MiddleCenter, + video_loop: false, + video_start_time: 0.0, + video_end_time: 0.0, + ) +]