This commit is contained in:
🪞👃🪞 2024-06-29 22:06:53 +03:00
parent 3886e34519
commit de2e2a2124
7 changed files with 119 additions and 65 deletions

View file

@ -52,15 +52,16 @@ impl Launcher {
let transport = client.transport();
let ppq = timebase.ppq() as u32;
DynamicDevice::new(render, handle, process, Self {
name: name.into(),
view: LauncherView::Tracks,
playing: transport.query_state()?,
monitoring: true,
recording: false,
overdub: true,
name: name.into(),
view: LauncherView::Tracks,
playing: transport.query_state()?,
transport,
cursor: (0, 0),
position: 0,
timebase: timebase.clone(),
monitoring: true,
recording: false,
overdub: true,
cursor: (0, 0),
position: 0,
scenes: scenes.unwrap_or_else(||vec![Scene::new(&"Scene 1", &[None])]),
tracks: if let Some(tracks) = tracks { tracks } else { vec![
Track::new("Track 1", &timebase, None, Some(vec![
@ -72,8 +73,7 @@ impl Launcher {
])))
]))?,
] },
timebase: timebase.clone(),
show_help: true
show_help: true,
}).activate(client)
}
fn cols (&self) -> usize {
@ -181,15 +181,13 @@ pub fn render (state: &Launcher, buf: &mut Buffer, mut area: Rect) -> Usually<Re
crate::device::sequencer::draw_dub(buf, x + 26, y, state.overdub);
draw_bpm(buf, x + 33, y, state.timebase.tempo());
draw_timer(buf, x + width - 1, y, &state.timebase, state.position);
//let separator = format!("├{}┤", "-".repeat((width - 2).into()));
//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: 8 }, state.view.is_tracks()
).draw()?.height;
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: 8 })?.height;
y = y + draw_section_chains(state, buf, Rect { x, y, width, height: 8 })?.height;
area.height = y;
if state.show_help {
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
let hide = "[Left Right] Track [Up Down] Scene [, .] Value [F1] Toggle help ";
@ -225,7 +223,8 @@ fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Us
let view = &state.view;
match view {
LauncherView::Sequencer => {
draw_box_styled(buf, area, style);
lozenge_left(buf, x, y, height, style);
lozenge_right(buf, x + width - 1, y, height, style);
},
_ => {},
};
@ -236,9 +235,13 @@ fn draw_section_sequencer (state: &Launcher, buf: &mut Buffer, area: Rect) -> Us
let state = track.sequencer.state();
let zoom = state.resolution;
let step = state.phrase().map(|_|tick / zoom);
let steps = if let Some(_phrase) = state.phrase() {
0
} else {
0
} / 4;
crate::device::sequencer::horizontal::timer(buf, x+5, y,
step.unwrap_or(0) / 4,
steps,
state.steps * zoom,
state.time_axis.0,
state.time_axis.1
@ -279,6 +282,14 @@ fn draw_highlight (buf: &mut Buffer, highlight: &Option<Rect>, style: Style) {
}
fn draw_section_chains (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let style = Some(Style::default().green().dim());
match state.view {
LauncherView::Chains => {
let Rect { x, y, width, height} = area;
lozenge_left(buf, x, y, height, style);
lozenge_right(buf, x + width - 1, y, height, style);
},
_ => {},
};
let chain = state.active_chain();
let plugins = if let Some(chain) = &chain {
let (_, plugins) = crate::device::chain::draw_as_row(
@ -294,17 +305,17 @@ fn draw_section_chains (state: &Launcher, buf: &mut Buffer, area: Rect) -> Usual
//},
//_ => {},
//};
draw_highlight(buf, &Some(area), match state.view {
LauncherView::Chains => Style::default().green().dim(),
_ => Style::default().dim()
});
if let Some(chain) = &chain {
if let Some(plugin) = plugins.get(chain.focus) {
draw_highlight(buf, &Some(*plugin), match state.view {
LauncherView::Chains => Style::default().green().not_dim(),
_ => Style::default().green().dim()
});
}
}
//draw_highlight(buf, &Some(area), match state.view {
//LauncherView::Chains => Style::default().green().dim(),
//_ => Style::default().dim()
//});
//if let Some(chain) = &chain {
//if let Some(plugin) = plugins.get(chain.focus) {
//draw_highlight(buf, &Some(*plugin), match state.view {
//LauncherView::Chains => Style::default().green().not_dim(),
//_ => Style::default().green().dim()
//});
//}
//}
Ok(area)
}