mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: refactor pt.7, 198 errors yay
This commit is contained in:
parent
869d92110d
commit
a1818a8504
6 changed files with 45 additions and 48 deletions
|
|
@ -86,7 +86,7 @@ pub trait FocusGrid {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum FocusCommand {
|
||||
Next,
|
||||
Prev,
|
||||
|
|
|
|||
|
|
@ -18,18 +18,24 @@ submod! {
|
|||
tui_arranger_foc
|
||||
tui_arranger_hor
|
||||
tui_arranger_ver
|
||||
tui_sequencer
|
||||
tui_sequencer_cmd
|
||||
tui_transport
|
||||
tui_transport_cmd
|
||||
tui_mixer
|
||||
tui_mixer_cmd
|
||||
tui_sampler
|
||||
tui_sampler_cmd
|
||||
tui_phrase
|
||||
tui_phrase_cmd
|
||||
tui_plugin
|
||||
tui_plugin_cmd
|
||||
tui_plugin_lv2
|
||||
tui_plugin_lv2_gui
|
||||
tui_plugin_vst2
|
||||
tui_plugin_vst3
|
||||
tui_pool
|
||||
tui_pool_cmd
|
||||
tui_sampler
|
||||
tui_sampler_cmd
|
||||
tui_sequencer
|
||||
tui_sequencer_bar
|
||||
tui_sequencer_cmd
|
||||
tui_sequencer_foc
|
||||
tui_transport
|
||||
tui_transport_cmd
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ pub struct ArrangerApp<E: Engine> {
|
|||
/// Width and height of app at last render
|
||||
pub size: Measure<E>,
|
||||
/// Menu bar
|
||||
pub menu: MenuBar<E, Self, ArrangerCommand>,
|
||||
pub menu: MenuBar<E, Self, ArrangerAppCommand>,
|
||||
/// Command history
|
||||
pub history: Vec<ArrangerCommand>,
|
||||
pub history: Vec<ArrangerAppCommand>,
|
||||
}
|
||||
|
||||
impl Audio for ArrangerApp {
|
||||
impl<E: Engine> Audio for ArrangerApp<E> {
|
||||
fn process (&mut self, client: &Client, scope: &ProcessScope) -> Control {
|
||||
if let Some(ref transport) = self.transport {
|
||||
transport.write().unwrap().process(client, scope);
|
||||
|
|
@ -63,7 +63,7 @@ impl Audio for ArrangerApp {
|
|||
}
|
||||
|
||||
/// Layout for standalone arranger app.
|
||||
impl Content for ArrangerApp {
|
||||
impl Content for ArrangerApp<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
let focused = self.arrangement.focused;
|
||||
|
|
@ -129,7 +129,7 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
Arc::new(TransportTime::default())
|
||||
},
|
||||
menu: {
|
||||
use ArrangerCommand::*;
|
||||
use ArrangerAppCommand::*;
|
||||
MenuBar::new()
|
||||
.add({
|
||||
use ArrangementCommand::*;
|
||||
|
|
@ -139,7 +139,7 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
.cmd("s", "Save project", Arrangement(Save))
|
||||
})
|
||||
.add({
|
||||
use TransportCommand::*;
|
||||
use TransportAppCommand::*;
|
||||
Menu::new("Transport")
|
||||
.cmd("p", "Play", Transport(Play))
|
||||
.cmd("s", "Play from start", Transport(PlayFromStart))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum ArrangerCommand {
|
||||
pub enum ArrangerAppCommand {
|
||||
Focus(FocusCommand),
|
||||
Transport(TransportCommand),
|
||||
Phrases(PhrasePoolCommand),
|
||||
|
|
@ -11,10 +11,10 @@ pub enum ArrangerCommand {
|
|||
}
|
||||
|
||||
/// Handle top-level events in standalone arranger.
|
||||
impl Handle<Tui> for Arranger<Tui> {
|
||||
impl Handle<Tui> for ArrangerApp<Tui> {
|
||||
fn handle (&mut self, i: &TuiInput) -> Perhaps<bool> {
|
||||
if let Some(entered) = self.entered() {
|
||||
use ArrangerFocus::*;
|
||||
use ArrangerAppFocus::*;
|
||||
if let Some(true) = match entered {
|
||||
Transport => self.transport.as_mut().map(|t|t.handle(i)).transpose()?.flatten(),
|
||||
Arrangement => self.arrangement.handle(i)?,
|
||||
|
|
@ -24,14 +24,14 @@ impl Handle<Tui> for Arranger<Tui> {
|
|||
return Ok(Some(true))
|
||||
}
|
||||
}
|
||||
ArrangerCommand::execute_with_state(self, i)
|
||||
ArrangerAppCommand::execute_with_state(self, i)
|
||||
}
|
||||
}
|
||||
|
||||
impl InputToCommand<Tui, Arranger<Tui>> for ArrangerCommand {
|
||||
fn input_to_command (state: &Arranger<Tui>, input: &TuiInput) -> Option<Self> {
|
||||
impl InputToCommand<Tui, ArrangerApp<Tui>> for ArrangerAppCommand {
|
||||
fn input_to_command (state: &ArrangerApp<Tui>, input: &TuiInput) -> Option<Self> {
|
||||
use FocusCommand::*;
|
||||
use ArrangerCommand::*;
|
||||
use ArrangerAppCommand::*;
|
||||
match input.event() {
|
||||
key!(KeyCode::Tab) => Some(Focus(Next)),
|
||||
key!(Shift-KeyCode::Tab) => Some(Focus(Prev)),
|
||||
|
|
@ -45,11 +45,11 @@ impl InputToCommand<Tui, Arranger<Tui>> for ArrangerCommand {
|
|||
key!(KeyCode::Esc) => Some(Focus(Exit)),
|
||||
key!(KeyCode::Char(' ')) => Some(Transport(TransportCommand::PlayToggle)),
|
||||
_ => match state.focused() {
|
||||
ArrangerFocus::Transport => state.transport.as_ref()
|
||||
ArrangerAppFocus::Transport => state.transport.as_ref()
|
||||
.map(|t|TransportCommand::input_to_command(&*t.read().unwrap(), input)
|
||||
.map(Transport))
|
||||
.flatten(),
|
||||
ArrangerFocus::PhrasePool => {
|
||||
ArrangerAppFocus::PhrasePool => {
|
||||
let phrases = state.phrases.read().unwrap();
|
||||
match input.event() {
|
||||
key!(KeyCode::Char('e')) => Some(EditPhrase(Some(phrases.phrase().clone()))),
|
||||
|
|
@ -57,10 +57,10 @@ impl InputToCommand<Tui, Arranger<Tui>> for ArrangerCommand {
|
|||
.map(Phrases)
|
||||
}
|
||||
},
|
||||
ArrangerFocus::PhraseEditor =>
|
||||
ArrangerAppFocus::PhraseEditor =>
|
||||
PhraseEditorCommand::input_to_command(&state.editor, input)
|
||||
.map(Editor),
|
||||
ArrangerFocus::Arrangement => match input.event() {
|
||||
ArrangerAppFocus::Arrangement => match input.event() {
|
||||
key!(KeyCode::Char('e')) => Some(EditPhrase(state.arrangement.phrase())),
|
||||
_ => ArrangementCommand::input_to_command(&state.arrangement, &input)
|
||||
.map(Arrangement)
|
||||
|
|
@ -108,14 +108,14 @@ impl InputToCommand<Tui, Arrangement<Tui>> for ArrangementCommand {
|
|||
}
|
||||
}
|
||||
|
||||
//impl Arranger<Tui> {
|
||||
//impl ArrangerApp<Tui> {
|
||||
///// Helper for event passthru to focused component
|
||||
//fn handle_focused (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
//match self.focused() {
|
||||
//ArrangerFocus::Transport => self.transport.handle(from),
|
||||
//ArrangerFocus::PhrasePool => self.handle_pool(from),
|
||||
//ArrangerFocus::PhraseEditor => self.editor.handle(from),
|
||||
//ArrangerFocus::Arrangement => self.handle_arrangement(from)
|
||||
//ArrangerAppFocus::Transport => self.transport.handle(from),
|
||||
//ArrangerAppFocus::PhrasePool => self.handle_pool(from),
|
||||
//ArrangerAppFocus::PhraseEditor => self.editor.handle(from),
|
||||
//ArrangerAppFocus::Arrangement => self.handle_arrangement(from)
|
||||
//.and_then(|result|{self.show_phrase();Ok(result)}),
|
||||
//}
|
||||
//}
|
||||
|
|
@ -160,15 +160,6 @@ impl InputToCommand<Tui, Arrangement<Tui>> for ArrangementCommand {
|
|||
//}
|
||||
//}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum ArrangerCommand {
|
||||
Focus(FocusCommand),
|
||||
Transport(TransportCommand),
|
||||
Phrases(PhrasePoolCommand),
|
||||
Editor(PhraseEditorCommand),
|
||||
Arrangement(ArrangementCommand),
|
||||
EditPhrase(Option<Arc<RwLock<Phrase>>>),
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub enum ArrangementCommand {
|
||||
New,
|
||||
|
|
@ -196,8 +187,8 @@ pub enum ArrangementCommand {
|
|||
Edit(Option<Arc<RwLock<Phrase>>>),
|
||||
}
|
||||
|
||||
impl<E: Engine> Command<Arranger<E>> for ArrangerCommand {
|
||||
fn execute (self, state: &mut Arranger<E>) -> Perhaps<Self> {
|
||||
impl<E: Engine> Command<ArrangerApp<E>> for ArrangerAppCommand {
|
||||
fn execute (self, state: &mut ArrangerApp<E>) -> Perhaps<Self> {
|
||||
let undo = match self {
|
||||
Self::Focus(cmd) => {
|
||||
delegate(cmd, Self::Focus, state)
|
||||
|
|
@ -218,7 +209,7 @@ impl<E: Engine> Command<Arranger<E>> for ArrangerCommand {
|
|||
},
|
||||
Self::EditPhrase(phrase) => {
|
||||
state.editor.phrase = phrase.clone();
|
||||
state.focus(ArrangerFocus::PhraseEditor);
|
||||
state.focus(ArrangerAppFocus::PhraseEditor);
|
||||
state.focus_enter();
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ impl<E: Engine> Command<SequencerApp<E>> for SequencerAppCommand {
|
|||
}
|
||||
}
|
||||
|
||||
impl InputToCommand<Tui, SequencerApp<Tui>> for SequencerCommand {
|
||||
impl InputToCommand<Tui, SequencerApp<Tui>> for SequencerAppCommand {
|
||||
fn input_to_command (state: &SequencerApp<Tui>, input: &TuiInput) -> Option<Self> {
|
||||
use SequencerCommand::*;
|
||||
use SequencerAppCommand::*;
|
||||
use FocusCommand::*;
|
||||
match input.event() {
|
||||
key!(KeyCode::Tab) => Some(Focus(Next)),
|
||||
|
|
@ -61,10 +61,10 @@ impl InputToCommand<Tui, SequencerApp<Tui>> for SequencerCommand {
|
|||
key!(KeyCode::Down) => Some(Focus(Down)),
|
||||
key!(KeyCode::Left) => Some(Focus(Left)),
|
||||
key!(KeyCode::Right) => Some(Focus(Right)),
|
||||
key!(KeyCode::Char(' ')) => Some(Transport(TransportCommand::PlayToggle)),
|
||||
key!(KeyCode::Char(' ')) => Some(Transport(TransportAppCommand::PlayToggle)),
|
||||
_ => match state.focused() {
|
||||
SequencerFocus::Transport => if let Some(t) = state.transport.as_ref() {
|
||||
TransportCommand::input_to_command(&*t.read().unwrap(), input).map(Transport)
|
||||
TransportAppCommand::input_to_command(&*t.read().unwrap(), input).map(Transport)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use crate::*;
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum TransportViewCommand {
|
||||
pub enum TransportAppCommand {
|
||||
Focus(FocusCommand),
|
||||
Transport(TransportCommand),
|
||||
}
|
||||
impl Handle<Tui> for TransportView<Tui> {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
TransportViewCommand::execute_with_state(self, from)
|
||||
TransportAppCommand::execute_with_state(self, from)
|
||||
}
|
||||
}
|
||||
impl InputToCommand<Tui, TransportView<Tui>> for TransportViewCommand {
|
||||
impl InputToCommand<Tui, TransportView<Tui>> for TransportAppCommand {
|
||||
fn input_to_command (_: &TransportView<Tui>, input: &TuiInput) -> Option<Self> {
|
||||
match input.event() {
|
||||
key!(KeyCode::Char(' ')) => Some(Self::FocusPrev),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue