diff --git a/src/main.rs b/src/main.rs index 8d00e68..954935f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -955,11 +955,13 @@ impl cosmic::Application for App { let slide_index = self.current_item.1; let item_index = self.current_item.0; let mut tasks = vec![]; + debug!(slide_index, item_index); if let Some(item) = self.service.get(item_index) { if item.slides.len() > slide_index + 1 { let slide_index = slide_index + 1; + debug!(slide_index, item_index); let action = self.presenter.update( presenter::Message::ActivateSlide( item_index, @@ -976,7 +978,7 @@ impl cosmic::Application for App { })); } self.current_item = - (item_index, slide_index + 1); + (item_index, slide_index); Task::batch(tasks) } else { // debug!("Slides are not longer"); @@ -1030,7 +1032,7 @@ impl cosmic::Application for App { })); } self.current_item = - (item_index, slide_index - 1); + (item_index, slide_index); Task::batch(tasks) } else if slide_index == 0 && item_index == 0 diff --git a/src/ui/presenter.rs b/src/ui/presenter.rs index 30db73b..fa00c26 100644 --- a/src/ui/presenter.rs +++ b/src/ui/presenter.rs @@ -216,6 +216,7 @@ impl Presenter { // )); } Message::ActivateSlide(item_index, slide_index) => { + debug!(slide_index, item_index); if let Some(slide) = self .service .get(item_index) diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index 3cfbd99..86d8236 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -20,7 +20,11 @@ use tracing::{debug, error}; use crate::{ Background, BackgroundKind, - core::{service_items::ServiceTrait, slide::Slide, songs::Song}, + core::{ + service_items::ServiceTrait, + slide::Slide, + songs::{Song, Verse}, + }, ui::{ presenter::slide_view, slide_editor::SlideEditor, text_svg, }, @@ -416,10 +420,89 @@ order", ] .spacing(5); - column![title_input, author_input, verse_input, lyric_input,] - .spacing(25) - .width(Length::FillPortion(2)) - .into() + let verse_list = self.song.clone().map(|song| { + if let Some(verses) = song.verses.map(|verses| { + verses + .iter() + .map(|verse| match verse { + Verse::Verse { number, .. } => text({ + let mut string = "Verse ".to_string(); + string.push_str(&number.to_string()); + string + }), + Verse::PreChorus { number, lyric } => text({ + let mut string = + "Pre-Chorus ".to_string(); + string.push_str(&number.to_string()); + string + }), + Verse::Chorus { number, lyric } => text({ + let mut string = "Chorus ".to_string(); + string.push_str(&number.to_string()); + string + }), + Verse::PostChorus { number, lyric } => { + text({ + let mut string = + "Post-Chorus ".to_string(); + string.push_str(&number.to_string()); + string + }) + } + Verse::Bridge { number, lyric } => text({ + let mut string = "Bridge ".to_string(); + string.push_str(&number.to_string()); + string + }), + Verse::Intro { number, lyric } => text({ + let mut string = "Intro ".to_string(); + string.push_str(&number.to_string()); + string + }), + Verse::Outro { number, lyric } => text({ + let mut string = "Outro ".to_string(); + string.push_str(&number.to_string()); + string + }), + Verse::Instrumental { number, lyric } => { + text({ + let mut string = + "Instrumental ".to_string(); + string.push_str(&number.to_string()); + string + }) + } + Verse::Other { number, lyric } => text({ + let mut string = "Other ".to_string(); + string.push_str(&number.to_string()); + string + }), + }) + .collect() + }) { + verses + } else { + vec![] + } + }); + let verse_list = if let Some(verse_list) = verse_list { + Element::from(row(verse_list + .into_iter() + .map(|v| Element::from(v)))) + } else { + Element::from(horizontal_space()) + }; + + column![ + title_input, + author_input, + verse_input, + lyric_input, + verse_list + ] + .spacing(25) + .width(Length::FillPortion(2)) + .into() } fn toolbar(&self) -> Element { diff --git a/todo.org b/todo.org index 78aaa37..f153dc3 100644 --- a/todo.org +++ b/todo.org @@ -2,7 +2,7 @@ * TODO [#A] Need to fix tests now that the basic app is working -* TODO [#A] Allow for a way to split the presentation up but a right click menu for the presentation. +* TODO [#A] Allow for a way to split the presentation up with a right click menu for the presentation preview row. * 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.