sequencer time indicator

This commit is contained in:
🪞👃🪞 2024-06-29 15:29:49 +03:00
parent 4ebecc2427
commit e13569df93
5 changed files with 68 additions and 40 deletions

View file

@ -183,10 +183,10 @@ pub fn render (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect>
//separator.blit(buf, x, y + 22, Some(Style::default().dim()));
//separator.blit(buf, x, y + 41, Some(Style::default().dim()));
let mut y = y + 1;
y = y + LauncherGridView
::new(state, buf, Rect { x, y, width, height: 22 }, state.view.is_tracks())
.draw()?.height + 1;
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: 28 })?.height + 1;
y = y + LauncherGridView::new(
state, buf, Rect { x, y, width, height: 22 }, state.view.is_tracks()
).draw()?.height;
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: 28 })?.height;
y = y + draw_section_chains(state, buf, Rect { x, y, width, height: 21 })?.height;
if state.show_help {
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
@ -221,34 +221,52 @@ fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Us
let Rect { x, y, width, height } = area;
let style = Some(Style::default().green().dim());
let view = &state.view;
match state.view {
match view {
LauncherView::Sequencer => {
draw_box_styled(buf, area, style);
},
_ => {},
};
if let Some(track) = state.tracks.get(state.col().saturating_sub(1)) {
let state = track.sequencer.state();
let frame = state.position;
let timebase = &state.timebase;
let tick = (frame as f64 / timebase.frames_per_tick()) as usize;
let state = track.sequencer.state();
let zoom = state.resolution;
let step = state.phrase().map(|_|tick / zoom);
crate::device::sequencer::horizontal::timer(buf, x+5, y,
step.unwrap_or(0) / 4,
state.steps * zoom,
state.time_axis.0,
state.time_axis.1
);
let keys_area = Rect { x, y: y + 1, width, height };
crate::device::sequencer::horizontal::keys(buf, keys_area, state.note_axis.1)?;
crate::device::sequencer::horizontal::keys(buf, keys_area,
state.note_axis.1
)?;
if let Some(phrase) = state.phrase() {
crate::device::sequencer::horizontal::lanes(buf, x, y + 1,
&phrase,
state.timebase.ppq() as u32,
state.resolution as u32,
state.resolution as u32,
state.time_axis.0 as u32,
state.time_axis.1 as u32,
state.note_axis.0 as u32,
state.note_axis.1 as u32,
);
}
let cursor_style = match view {
LauncherView::Sequencer => Style::default().green().not_dim(),
_ => Style::default().green().dim(),
};
crate::device::sequencer::horizontal::cursor(buf, x, y + 1, cursor_style,
state.time_cursor,
state.note_cursor);
state.note_cursor
);
}
Ok(area)
}