mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
replace existing samples; dont crash on small screen
This commit is contained in:
parent
5e75f97e09
commit
61c84ac030
2 changed files with 14 additions and 5 deletions
|
|
@ -185,6 +185,9 @@ mod draw_vertical {
|
|||
move |buf: &mut Buffer, area: Rect| {
|
||||
for (_, y) in rows.iter() {
|
||||
let y = area.y + (*y / 96) as u16 + 1;
|
||||
if y >= buf.area.height {
|
||||
break
|
||||
}
|
||||
for x in area.x..area.width+area.y-2 {
|
||||
let cell = buf.get_mut(x, y);
|
||||
cell.modifier = Modifier::UNDERLINED;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ handle!(Sampler |self, event| handle_keymap(self, event, KEYMAP_SAMPLER));
|
|||
|
||||
/// Key bindings for sampler device.
|
||||
pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
||||
[Up, NONE, "cursor_up", "move cursor up", |state: &mut Sampler| {
|
||||
[Up, NONE, "cursor_up", "move cursor up", |state: &mut Sampler| {
|
||||
state.cursor.0 = if state.cursor.0 == 0 {
|
||||
state.mapped.len() + state.unmapped.len() - 1
|
||||
} else {
|
||||
|
|
@ -69,23 +69,29 @@ pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
|||
};
|
||||
Ok(true)
|
||||
}],
|
||||
[Down, NONE, "cursor_down", "move cursor down", |state: &mut Sampler| {
|
||||
[Down, NONE, "cursor_down", "move cursor down", |state: &mut Sampler| {
|
||||
state.cursor.0 = (state.cursor.0 + 1) % (state.mapped.len() + state.unmapped.len());
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('t'), NONE, "sample_play", "play current sample", |state: &mut Sampler| {
|
||||
[Char('t'), NONE, "sample_play", "play current sample", |state: &mut Sampler| {
|
||||
if let Some(sample) = state.sample() {
|
||||
state.voices.push(Sample::play(sample, 0, &100.into()))
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('a'), NONE, "sample_add", "add a new sample", |state: &mut Sampler| {
|
||||
[Char('a'), NONE, "sample_add", "add a new sample", |state: &mut Sampler| {
|
||||
let sample = Sample::new("", 0, 0, vec![]);
|
||||
*MODAL.lock().unwrap() = Some(Exit::boxed(AddSampleModal::new(&sample)?));
|
||||
state.unmapped.push(sample);
|
||||
Ok(true)
|
||||
}],
|
||||
[Enter, NONE, "sample_edit", "edit selected sample", |state: &mut Sampler| {
|
||||
[Char('r'), NONE, "sample_replace", "replace selected sample", |state: &mut Sampler| {
|
||||
if let Some(sample) = state.sample() {
|
||||
*MODAL.lock().unwrap() = Some(Exit::boxed(AddSampleModal::new(&sample)?));
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
[Enter, NONE, "sample_edit", "edit selected sample", |state: &mut Sampler| {
|
||||
if let Some(sample) = state.sample() {
|
||||
state.editing = Some(sample.clone());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue