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