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 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;
////////////////////////////////////////////////////////

View file

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

View file

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

View file

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