From 0543e2e892c3c0f8fc903ef0cf3a78008e5b3f4d Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 6 Jan 2026 14:53:17 -0600 Subject: [PATCH] moving stringfying of the verse to it's own function --- src/core/songs.rs | 66 +++++++++++++++++++++++++++++++++++++++++++ src/ui/song_editor.rs | 63 ++++++----------------------------------- 2 files changed, 74 insertions(+), 55 deletions(-) diff --git a/src/core/songs.rs b/src/core/songs.rs index d97ba25..bebf3fc 100644 --- a/src/core/songs.rs +++ b/src/core/songs.rs @@ -51,6 +51,72 @@ pub enum Verse { Other { number: usize, lyric: String }, } +impl Verse { + pub fn get_name(&self) -> String { + match self { + Verse::Verse { number, .. } => { + let mut string = "Verse ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::PreChorus { number, .. } => { + let mut string = "Pre-Chorus ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::Chorus { number, .. } => { + let mut string = "Chorus ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::PostChorus { number, .. } => { + let mut string = "Post-Chorus ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::Bridge { number, .. } => { + let mut string = "Bridge ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::Intro { number, .. } => { + let mut string = "Intro ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::Outro { number, .. } => { + let mut string = "Outro ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::Instrumental { number, .. } => { + let mut string = "Instrumental ".to_string(); + string.push_str(&number.to_string()); + string + } + Verse::Other { number, .. } => { + let mut string = "Other ".to_string(); + string.push_str(&number.to_string()); + string + } + } + } + + pub fn get_lyric(&self) -> String { + match self { + Verse::Verse { lyric, .. } => lyric.clone(), + Verse::PreChorus { lyric, .. } => lyric.clone(), + Verse::Chorus { lyric, .. } => lyric.clone(), + Verse::PostChorus { lyric, .. } => lyric.clone(), + Verse::Bridge { lyric, .. } => lyric.clone(), + Verse::Intro { lyric, .. } => lyric.clone(), + Verse::Outro { lyric, .. } => lyric.clone(), + Verse::Instrumental { lyric, .. } => lyric.clone(), + Verse::Other { lyric, .. } => lyric.clone(), + } + } +} + impl Default for Verse { fn default() -> Self { Self::Verse { diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index 86d8236..25a1630 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -411,7 +411,7 @@ order", .label("Verse Order") .on_input(Message::ChangeVerseOrder); - let lyric_title = text("Lyrics"); + let lyric_title = text::heading("Lyrics"); let lyric_input = column![ lyric_title, text_editor(&self.lyrics) @@ -424,60 +424,7 @@ order", 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 - }), - }) + .map(|verse| text(verse.get_name())) .collect() }) { verses @@ -722,6 +669,12 @@ order", } } +fn verses_editor<'a>(verse: Verse) -> Element<'a, Message> { + let verse_title = text(verse.get_name()); + let lyric = text(verse.get_lyric()); + todo!() +} + impl Default for SongEditor { fn default() -> Self { let mut fontdb = fontdb::Database::new();