diff --git a/neothesia/src/scene/menu_scene/iced_menu/mod.rs b/neothesia/src/scene/menu_scene/iced_menu/mod.rs index 5747b241..c9df5f03 100644 --- a/neothesia/src/scene/menu_scene/iced_menu/mod.rs +++ b/neothesia/src/scene/menu_scene/iced_menu/mod.rs @@ -465,7 +465,7 @@ impl<'a> Step { PlayerConfig::Human => 2, }; - let color = if (track.has_drums && !track.has_other_than_drums) || !visible { + let color = if !visible { iced_core::Color::from_rgb8(102, 102, 102) } else { let color_id = track.track_color_id % target.config.color_schema.len(); @@ -500,14 +500,20 @@ impl<'a> Step { .active(active) .active_color(color) .build(); + let card = track_card::track_card() .title(name) .subtitle(format!("{} Notes", track.notes.len())) .track_color(color) - .body(body) - .on_icon_press(Message::TrackVisibilityConfig(track.track_id, !visible)) - .build(); - tracks.push(card.into()); + .body(body); + + let card = if track.has_drums && !track.has_other_than_drums { + card + } else { + card.on_icon_press(Message::TrackVisibilityConfig(track.track_id, !visible)) + }; + + tracks.push(card.build().into()); } } diff --git a/neothesia/src/song.rs b/neothesia/src/song.rs index ed4f1892..f9a6b173 100644 --- a/neothesia/src/song.rs +++ b/neothesia/src/song.rs @@ -1,7 +1,8 @@ -#[derive(Debug, Default, Clone)] +use midi_file::MidiTrack; + +#[derive(Debug, Clone)] pub enum PlayerConfig { Mute, - #[default] Auto, Human, } @@ -13,24 +14,24 @@ pub struct TrackConfig { pub visible: bool, } -impl TrackConfig { - fn new(track_id: usize) -> Self { - Self { - track_id, - player: PlayerConfig::default(), - visible: true, - } - } -} - #[derive(Debug, Clone)] pub struct SongConfig { pub tracks: Box<[TrackConfig]>, } impl SongConfig { - fn new(tracks_count: usize) -> Self { - let tracks: Vec<_> = (0..tracks_count).map(TrackConfig::new).collect(); + fn new(tracks: &[MidiTrack]) -> Self { + let tracks: Vec<_> = tracks + .iter() + .map(|t| { + let is_drums = t.has_drums && !t.has_other_than_drums; + TrackConfig { + track_id: t.track_id, + player: PlayerConfig::Auto, + visible: !is_drums, + } + }) + .collect(); Self { tracks: tracks.into(), } @@ -45,7 +46,7 @@ pub struct Song { impl Song { pub fn new(file: midi_file::MidiFile) -> Self { - let config = SongConfig::new(file.tracks.len()); + let config = SongConfig::new(&file.tracks); Self { file, config } } }