move phrase length/rename modes to tui/pool/

This commit is contained in:
🪞👃🪞 2024-12-25 06:02:26 +01:00
parent 4ab9463164
commit eb5f451423
4 changed files with 27 additions and 14 deletions

View file

@ -35,13 +35,16 @@ mod arranger_mode_v; pub(crate) use arranger_mode_v::*;
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
mod status_bar; pub(crate) use status_bar::*;
mod file_browser; pub(crate) use file_browser::*;
mod phrase_editor; pub(crate) use phrase_editor::*;
mod piano_horizontal; pub(crate) use piano_horizontal::*;
mod phrase_length; pub(crate) use phrase_length::*;
mod phrase_rename; pub(crate) use phrase_rename::*;
mod pool; pub(crate) use pool::*; mod pool; pub(crate) use pool::*;
mod phrase_editor; pub(crate) use phrase_editor::*;
mod status_bar; pub(crate) use status_bar::*;
mod file_browser; pub(crate) use file_browser::*;
mod piano_horizontal; pub(crate) use piano_horizontal::*;
mod port_select; mod port_select;
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////

View file

@ -1,10 +1,12 @@
use super::*; use super::*;
use crate::{ use crate::PhrasePoolCommand as Pool;
PhrasePoolCommand as Pool,
tui::phrase_rename::PhraseRenameCommand as Rename, mod phrase_length; pub(crate) use phrase_length::*;
tui::phrase_length::PhraseLengthCommand as Length, mod phrase_rename; pub(crate) use phrase_rename::*;
tui::file_browser::FileBrowserCommand as Browse,
}; use PhraseRenameCommand as Rename;
use PhraseLengthCommand as Length;
use FileBrowserCommand as Browse;
#[derive(Debug)] #[derive(Debug)]
pub struct PoolModel { pub struct PoolModel {

View file

@ -1,7 +1,8 @@
use crate::*; use crate::*;
use super::pool::{PoolModel, PoolMode}; use super::*;
use PhraseLengthFocus::*; use PhraseLengthFocus::*;
use PhraseLengthCommand::*; use PhraseLengthCommand::*;
/// Displays and edits phrase length. /// Displays and edits phrase length.
#[derive(Clone)] #[derive(Clone)]
pub struct PhraseLength { pub struct PhraseLength {
@ -14,6 +15,7 @@ pub struct PhraseLength {
/// Selected subdivision /// Selected subdivision
pub focus: Option<PhraseLengthFocus>, pub focus: Option<PhraseLengthFocus>,
} }
impl PhraseLength { impl PhraseLength {
pub fn new (pulses: usize, focus: Option<PhraseLengthFocus>) -> Self { pub fn new (pulses: usize, focus: Option<PhraseLengthFocus>) -> Self {
Self { ppq: PPQ, bpb: 4, pulses, focus } Self { ppq: PPQ, bpb: 4, pulses, focus }
@ -37,6 +39,7 @@ impl PhraseLength {
format!("{:>02}", self.ticks()) format!("{:>02}", self.ticks())
} }
} }
/// Focused field of `PhraseLength` /// Focused field of `PhraseLength`
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum PhraseLengthFocus { pub enum PhraseLengthFocus {
@ -47,6 +50,7 @@ pub enum PhraseLengthFocus {
/// Editing the number of ticks /// Editing the number of ticks
Tick, Tick,
} }
impl PhraseLengthFocus { impl PhraseLengthFocus {
pub fn next (&mut self) { pub fn next (&mut self) {
*self = match self { *self = match self {
@ -63,6 +67,7 @@ impl PhraseLengthFocus {
} }
} }
} }
render!(<Tui>|self: PhraseLength|{ render!(<Tui>|self: PhraseLength|{
let bars = ||self.bars_string(); let bars = ||self.bars_string();
let beats = ||self.beats_string(); let beats = ||self.beats_string();
@ -78,6 +83,7 @@ render!(<Tui>|self: PhraseLength|{
add(&row!([" ", bars(), ".", beats(), "[", ticks()])), add(&row!([" ", bars(), ".", beats(), "[", ticks()])),
}) })
}); });
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum PhraseLengthCommand { pub enum PhraseLengthCommand {
Begin, Begin,
@ -88,6 +94,7 @@ pub enum PhraseLengthCommand {
Inc, Inc,
Dec, Dec,
} }
command!(|self:PhraseLengthCommand,state:PoolModel|{ command!(|self:PhraseLengthCommand,state:PoolModel|{
match state.phrases_mode_mut().clone() { match state.phrases_mode_mut().clone() {
Some(PoolMode::Length(phrase, ref mut length, ref mut focus)) => match self { Some(PoolMode::Length(phrase, ref mut length, ref mut focus)) => match self {
@ -118,6 +125,7 @@ command!(|self:PhraseLengthCommand,state:PoolModel|{
}; };
None None
}); });
input_to_command!(PhraseLengthCommand:<Tui>|state:PoolModel,from|{ input_to_command!(PhraseLengthCommand:<Tui>|state:PoolModel,from|{
if let Some(PoolMode::Length(_, length, _)) = state.phrases_mode() { if let Some(PoolMode::Length(_, length, _)) = state.phrases_mode() {
match from.event() { match from.event() {

View file

@ -1,4 +1,5 @@
use crate::*; use crate::*;
use super::*;
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum PhraseRenameCommand { pub enum PhraseRenameCommand {
@ -57,4 +58,3 @@ impl InputToCommand<Tui, PoolModel> for PhraseRenameCommand {
} }
} }
} }