add Arranger model

This commit is contained in:
🪞👃🪞 2024-07-13 00:56:58 +03:00
parent c85fa3cd06
commit 20e30cb472
14 changed files with 310 additions and 241 deletions

View file

@ -14,12 +14,17 @@ pub struct ArrangerView<'a> {
impl<'a> ArrangerView<'a> {
pub fn new (app: &'a App, vertical: bool) -> Self {
Self {
vertical,
focused: app.section == AppFocus::Arranger,
entered: app.entered,
scenes: &app.scenes,
tracks: &app.tracks,
cursor: (app.track_cursor, app.scene_cursor),
vertical
scenes: &app.arranger.scenes,
tracks: &app.arranger.tracks,
cursor: match app.arranger.selected {
ArrangerFocus::Mix => (0, 0),
ArrangerFocus::Scene(s) => (0, s + 1),
ArrangerFocus::Track(t) => (t + 1, 0),
ArrangerFocus::Clip(t, s) => (t + 1, s + 1),
},
}
}
}
@ -100,8 +105,7 @@ impl<'a> ArrangerView<'a> {
let hi = (track_index + 1 == self.cursor.0) && (scene_index + 1 == self.cursor.1);
let style = Some(Nord::style_hi(self.focused, hi));
let y = 1 + y + 2 * scene_index as u16;
"".blit(buf, x, y, Some(Style::default().dim()))?;
"".blit(buf, x, y + 1, Some(Style::default().dim()))?;
"".blit(buf, x, y + 1, style)?;
label.blit(buf, x, y, style)?;
}
if track_index + 1 == self.cursor.0 {

View file

@ -19,10 +19,7 @@ impl<'a> ChainView<'a> {
direction,
entered: app.entered,
focused: app.section == AppFocus::Chain,
track: match app.track_cursor {
0 => None,
_ => app.tracks.get(app.track_cursor - 1)
},
track: app.arranger.track()
}
}
}

View file

@ -105,12 +105,9 @@ pub struct SequencerView<'a> {
impl<'a> SequencerView<'a> {
pub fn new (app: &'a App) -> Self {
let track = match app.track_cursor {
0 => None,
_ => app.tracks.get(app.track_cursor - 1)
};
let track = app.arranger.track();
Self {
phrase: app.phrase(),
phrase: app.arranger.phrase(),
focused: app.section == AppFocus::Sequencer,
entered: app.entered,
ppq: app.transport.ppq(),
@ -120,7 +117,7 @@ impl<'a> SequencerView<'a> {
time_zoom: app.seq_buf.time_zoom,
note_cursor: app.note_cursor,
note_start: app.note_start,
notes_in: if let Some(track) = track { &track.notes_in } else { &[false;128] },
notes_in: if let Some(track) = track { &track.notes_in } else { &[false;128] },
notes_out: if let Some(track) = track { &track.notes_out } else { &[false;128] },
}
}