wip: enabling standalone arranger

This commit is contained in:
🪞👃🪞 2024-08-10 14:23:51 +03:00
parent b6da43e93e
commit 7685072e4c
16 changed files with 445 additions and 370 deletions

View file

@ -4,6 +4,8 @@ use crate::*;
/// Represents the tracks and scenes of the composition.
pub struct Arranger {
/// Name of arranger
pub name: String,
/// Display mode of arranger
pub mode: ArrangerViewMode,
/// Currently selected element.
@ -16,28 +18,13 @@ pub struct Arranger {
pub entered: bool,
pub fixed_height: bool,
pub sequencer: Sequencer,
}
/// Display mode of arranger
pub enum ArrangerViewMode {
Vertical,
VerticalCompact,
Horizontal,
}
impl ArrangerViewMode {
fn to_next (&mut self) {
*self = match self {
Self::Vertical => Self::VerticalCompact,
Self::VerticalCompact => Self::Horizontal,
Self::Horizontal => Self::Vertical,
}
}
pub transport: Option<Arc<RwLock<TransportToolbar>>>,
}
impl Arranger {
pub fn new () -> Self {
pub fn new (name: &str) -> Self {
Self {
name: name.into(),
mode: ArrangerViewMode::Vertical,
selected: ArrangerFocus::Clip(0, 0),
scenes: vec![],
@ -46,6 +33,7 @@ impl Arranger {
focused: true,
fixed_height: false,
sequencer: Sequencer::new(),
transport: None
}
}
pub fn activate (&mut self) {
@ -63,7 +51,7 @@ impl Arranger {
_ => {}
}
}
fn show_phrase (&mut self) -> Usually<()> {
pub fn show_phrase (&mut self) -> Usually<()> {
unimplemented!()
//let phrase = self.phrase();
//self.sequencer.show(phrase)
@ -155,57 +143,3 @@ render!(Arranger |self, buf, area| match self.mode {
ArrangerViewMode::VerticalCompact =>
super::arranger_view_v::draw_compact(self, buf, area),
});
/// Key bindings for arranger section.
pub const KEYMAP_ARRANGER: &'static [KeyBinding<Arranger>] = keymap!(Arranger {
[Char('`'), NONE, "arranger_mode_switch", "switch the display mode", |app: &mut Arranger| {
app.mode.to_next();
Ok(true)
}],
[Up, NONE, "arranger_cursor_up", "move cursor up", |app: &mut Arranger| {
match app.mode {
ArrangerViewMode::Horizontal => app.track_prev(),
_ => app.scene_prev(),
};
app.show_phrase()?;
Ok(true)
}],
[Down, NONE, "arranger_cursor_down", "move cursor down", |app: &mut Arranger| {
match app.mode {
ArrangerViewMode::Horizontal => app.track_next(),
_ => app.scene_next(),
};
app.show_phrase()?;
Ok(true)
}],
[Left, NONE, "arranger_cursor_left", "move cursor left", |app: &mut Arranger| {
match app.mode {
ArrangerViewMode::Horizontal => app.scene_prev(),
_ => app.track_prev(),
};
app.show_phrase()?;
Ok(true)
}],
[Right, NONE, "arranger_cursor_right", "move cursor right", |app: &mut Arranger| {
match app.mode {
ArrangerViewMode::Horizontal => app.scene_next(),
_ => app.track_next(),
};
app.show_phrase()?;
Ok(true)
}],
[Char('.'), NONE, "arranger_increment", "set next clip at cursor", |app: &mut Arranger| {
app.phrase_next();
app.sequencer.phrase = app.phrase().map(Clone::clone);
Ok(true)
}],
[Char(','), NONE, "arranger_decrement", "set previous clip at cursor", |app: &mut Arranger| {
app.phrase_prev();
app.sequencer.phrase = app.phrase().map(Clone::clone);
Ok(true)
}],
[Enter, NONE, "arranger_activate", "activate item at cursor", |app: &mut Arranger| {
app.activate();
Ok(true)
}],
});