use crate::*; macro_rules! impl_jack_api { ($Struct:ident $(:: $field:ident)*) => { impl JackApi for $Struct { fn jack (&self) -> &Arc> { &self$(.$field)* } } } } macro_rules! impl_clock_api { ($Struct:ident $(:: $field:ident)*) => { impl ClockApi for $Struct { fn quant (&self) -> &Arc { &self$(.$field)*.quant } fn sync (&self) -> &Arc { &self$(.$field)*.sync } fn current (&self) -> &Arc { &self$(.$field)*.current } fn transport_handle (&self) -> &Arc { &self$(.$field)*.transport } fn transport_state (&self) -> &Arc>> { &self$(.$field)*.playing } fn transport_offset (&self) -> &Arc>> { &self$(.$field)*.started } } } } macro_rules! impl_has_phrases { ($Struct:ident $(:: $field:ident)*) => { impl HasPhrases for $Struct { fn phrases (&self) -> &Vec>> { &self$(.$field)*.phrases } fn phrases_mut (&mut self) -> &mut Vec>> { &mut self$(.$field)*.phrases } } } } macro_rules! impl_midi_player { ($Struct:ident $(:: $field:ident)*) => { impl HasPhrase for $Struct { fn reset (&self) -> bool { self$(.$field)*.reset } fn reset_mut (&mut self) -> &mut bool { &mut self$(.$field)*.reset } fn phrase (&self) -> &Option<(Instant, Option>>)> { todo!("phrase") } fn phrase_mut (&self) -> &mut Option<(Instant, Option>>)> { todo!("phrase_mut") } fn next_phrase (&self) -> &Option<(Instant, Option>>)> { todo!("next_phrase") } fn next_phrase_mut (&mut self) -> &mut Option<(Instant, Option>>)> { todo!("next_phrase_mut") } } impl MidiInputApi for $Struct { fn midi_ins (&self) -> &Vec> { todo!("midi_ins") } fn midi_ins_mut (&self) -> &mut Vec> { todo!("midi_ins_mut") } fn recording (&self) -> bool { todo!("recording") } fn recording_mut (&mut self) -> &mut bool { todo!("recording_mut") } fn monitoring (&self) -> bool { todo!("monitoring") } fn monitoring_mut (&mut self) -> &mut bool { todo!("monitoring_mut") } fn overdub (&self) -> bool { todo!("overdub") } fn overdub_mut (&mut self) -> &mut bool { todo!("overdub_mut") } fn notes_in (&self) -> &Arc> { todo!("notes_in") } } impl MidiOutputApi for $Struct { fn midi_outs (&self) -> &Vec> { todo!("midi_outs") } fn midi_outs_mut (&mut self) -> &mut Vec> { todo!("midi_outs_mut") } fn midi_note (&mut self) -> &mut Vec { todo!("midi_note") } fn notes_out (&self) -> &Arc> { todo!("notes_out") } } impl MidiPlayerApi for $Struct {} } } macro_rules! impl_phrases_control { ($Struct:ident $(:: $field:ident)*) => { impl PhrasesControl for $Struct { fn phrase_index (&self) -> usize { self.phrases.phrase.load(Ordering::Relaxed) } fn set_phrase_index (&self, value: usize) { self.phrases.phrase.store(value, Ordering::Relaxed); } fn phrases_mode (&self) -> &Option { &self.phrases.mode } fn phrases_mode_mut (&mut self) -> &mut Option { &mut self.phrases.mode } } } } macro_rules! impl_phrase_editor_control { ($Struct:ident $(:: $field:ident)* [$Focus:expr]) => { impl PhraseEditorControl for $Struct { fn edit_phrase (&self, phrase: &Option>>) { //self.editor.show(self.selected_phrase().as_ref()); //state.editor.phrase = phrase.clone(); //state.focus(ArrangerFocus::PhraseEditor); //state.focus_enter(); todo!("edit_phrase") } fn editing_phrase (&self) -> &Option>> { todo!("editing_phrase") } fn phrase_editor_entered (&self) -> bool { self.entered && self.focused() == $Focus } fn time_axis (&self) -> &RwLock> { &self.editor.time_axis } fn note_axis (&self) -> &RwLock> { &self.editor.note_axis } fn note_len (&self) -> usize { self.editor.note_len } fn note_len_mut (&mut self) -> &mut usize { &mut self.editor.note_len } fn put_note (&mut self) { todo!("put_note") } } } } impl_jack_api!(TransportTui::jack); impl_jack_api!(SequencerTui::jack); impl_jack_api!(ArrangerTui::jack); impl_clock_api!(TransportTui::state::clock); impl_clock_api!(SequencerTui::transport::clock); impl_clock_api!(ArrangerTui::transport::clock); impl_clock_api!(PhrasePlayerModel::clock); impl_clock_api!(ArrangerTrack::player::clock); impl_has_phrases!(PhrasesModel); impl_has_phrases!(SequencerTui::phrases); impl_has_phrases!(ArrangerTui::phrases); impl_midi_player!(SequencerTui::player); impl_midi_player!(ArrangerTrack::player); impl_midi_player!(PhrasePlayerModel); impl_phrases_control!(SequencerTui); impl_phrases_control!(ArrangerTui); impl_phrase_editor_control!(SequencerTui [SequencerFocus::PhraseEditor]); impl_phrase_editor_control!(ArrangerTui [ArrangerFocus::PhraseEditor]);