Feat: introduce follow up actions
This commit is contained in:
@@ -3,7 +3,7 @@ use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
|
||||
use super::{InputContext, InputResult};
|
||||
use crate::commands::AppCommand;
|
||||
use crate::engine::SeqCommand;
|
||||
use crate::model::PatternSpeed;
|
||||
use crate::model::{FollowUp, PatternSpeed};
|
||||
use crate::state::{
|
||||
ConfirmAction, EditorTarget, EuclideanField, Modal, PatternField,
|
||||
PatternPropsField, RenameTarget,
|
||||
@@ -377,21 +377,45 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
speed,
|
||||
quantization,
|
||||
sync_mode,
|
||||
follow_up,
|
||||
} => {
|
||||
let (bank, pattern) = (*bank, *pattern);
|
||||
let is_chain = matches!(follow_up, FollowUp::Chain { .. });
|
||||
match key.code {
|
||||
KeyCode::Up => *field = field.prev(),
|
||||
KeyCode::Down | KeyCode::Tab => *field = field.next(),
|
||||
KeyCode::Up => *field = field.prev(is_chain),
|
||||
KeyCode::Down | KeyCode::Tab => *field = field.next(is_chain),
|
||||
KeyCode::Left => match field {
|
||||
PatternPropsField::Speed => *speed = speed.prev(),
|
||||
PatternPropsField::Quantization => *quantization = quantization.prev(),
|
||||
PatternPropsField::SyncMode => *sync_mode = sync_mode.toggle(),
|
||||
PatternPropsField::FollowUp => *follow_up = follow_up.prev_mode(),
|
||||
PatternPropsField::ChainBank => {
|
||||
if let FollowUp::Chain { bank: b, .. } = follow_up {
|
||||
*b = b.saturating_sub(1);
|
||||
}
|
||||
}
|
||||
PatternPropsField::ChainPattern => {
|
||||
if let FollowUp::Chain { pattern: p, .. } = follow_up {
|
||||
*p = p.saturating_sub(1);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
KeyCode::Right => match field {
|
||||
PatternPropsField::Speed => *speed = speed.next(),
|
||||
PatternPropsField::Quantization => *quantization = quantization.next(),
|
||||
PatternPropsField::SyncMode => *sync_mode = sync_mode.toggle(),
|
||||
PatternPropsField::FollowUp => *follow_up = follow_up.next_mode(),
|
||||
PatternPropsField::ChainBank => {
|
||||
if let FollowUp::Chain { bank: b, .. } = follow_up {
|
||||
*b = (*b + 1).min(31);
|
||||
}
|
||||
}
|
||||
PatternPropsField::ChainPattern => {
|
||||
if let FollowUp::Chain { pattern: p, .. } = follow_up {
|
||||
*p = (*p + 1).min(31);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
KeyCode::Char(c) => match field {
|
||||
@@ -418,6 +442,7 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
let speed_val = *speed;
|
||||
let quant_val = *quantization;
|
||||
let sync_val = *sync_mode;
|
||||
let follow_up_val = *follow_up;
|
||||
ctx.dispatch(AppCommand::StagePatternProps {
|
||||
bank,
|
||||
pattern,
|
||||
@@ -426,6 +451,7 @@ pub(super) fn handle_modal_input(ctx: &mut InputContext, key: KeyEvent) -> Input
|
||||
speed: speed_val,
|
||||
quantization: quant_val,
|
||||
sync_mode: sync_val,
|
||||
follow_up: follow_up_val,
|
||||
});
|
||||
ctx.dispatch(AppCommand::CloseModal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user