Skip to content

Commit

Permalink
Allow to toggle all track configs at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Dec 14, 2023
1 parent 1f5d209 commit d7b2a3c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion neothesia/src/scene/menu_scene/iced_menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum Message {

Play,

AllTracksPlayerConfig(PlayerConfig),
TrackPlayerConfig(usize, PlayerConfig),
TrackVisibilityConfig(usize, bool),

Expand Down Expand Up @@ -153,6 +154,13 @@ impl Program for AppUi {
target.config.set_input(Some(&input));
self.data.selected_input = Some(input);
}
Message::AllTracksPlayerConfig(config) => {
if let Some(song) = target.song.as_mut() {
for track in song.config.tracks.iter_mut() {
track.player = config.clone();
}
}
}
Message::TrackPlayerConfig(track, config) => {
if let Some(song) = target.song.as_mut() {
song.config.tracks[track].player = config;
Expand Down Expand Up @@ -505,13 +513,25 @@ impl<'a> Step {
}
}

let controls = {
let listen = button(centered_text("Listen Only"))
.on_press(Message::AllTracksPlayerConfig(PlayerConfig::Auto))
.style(theme::button());

let play_along = button(centered_text("Play Along"))
.on_press(Message::AllTracksPlayerConfig(PlayerConfig::Human))
.style(theme::button());

row![listen, play_along].spacing(14)
};

let column = super::wrap::Wrap::with_elements(tracks)
.spacing(14.0)
.line_spacing(14.0)
.padding(50.0)
.align_items(Alignment::Center);

let column = col![vertical_space(Length::Fixed(30.0)), column]
let column = col![vertical_space(Length::Fixed(30.0)), controls, column]
.align_items(Alignment::Center)
.width(Length::Fill);

Expand Down

0 comments on commit d7b2a3c

Please sign in to comment.