mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: refactor pt.8, 512 errors lol
This commit is contained in:
parent
a1818a8504
commit
a784f7a6f2
19 changed files with 238 additions and 183 deletions
|
|
@ -1,38 +1,28 @@
|
|||
use crate::*;
|
||||
|
||||
/// Root level object for standalone `tek_arranger`
|
||||
pub struct ArrangerApp<E: Engine> {
|
||||
/// JACK client handle (needs to not be dropped for standalone mode to work).
|
||||
pub jack: Arc<RwLock<JackClient>>,
|
||||
/// Which view is focused
|
||||
pub focus_cursor: (usize, usize),
|
||||
/// Whether the focused view is entered
|
||||
pub entered: bool,
|
||||
/// Controls the JACK transport.
|
||||
pub transport: Option<Arc<RwLock<TransportToolbar<E>>>>,
|
||||
/// Global timebase
|
||||
pub clock: Arc<TransportTime>,
|
||||
pub struct ArrangerView<E: Engine> {
|
||||
/// Sequencer component
|
||||
pub sequencer: SequencerView<E>,
|
||||
/// Contains all the sequencers.
|
||||
pub arrangement: ArrangementEditor<E>,
|
||||
/// Pool of all phrases in the arrangement
|
||||
pub phrases: Arc<RwLock<PhrasePool<E>>>,
|
||||
/// Phrase editor view
|
||||
pub editor: PhraseEditor<E>,
|
||||
pub arrangement: ArrangementEditor<E>,
|
||||
/// Status bar
|
||||
pub status: ArrangerStatusBar,
|
||||
pub status: ArrangerStatusBar,
|
||||
/// Height of arrangement
|
||||
pub arrangement_split: u16,
|
||||
/// Width of phrase pool
|
||||
pub phrases_split: u16,
|
||||
pub split: u16,
|
||||
/// Width and height of app at last render
|
||||
pub size: Measure<E>,
|
||||
pub size: Measure<E>,
|
||||
/// Menu bar
|
||||
pub menu: MenuBar<E, Self, ArrangerAppCommand>,
|
||||
pub menu: MenuBar<E, Self, ArrangerViewCommand>,
|
||||
/// Command history
|
||||
pub history: Vec<ArrangerAppCommand>,
|
||||
pub history: Vec<ArrangerViewCommand>,
|
||||
/// Which view is focused
|
||||
pub cursor: (usize, usize),
|
||||
/// Whether the focused view is entered
|
||||
pub entered: bool,
|
||||
}
|
||||
|
||||
impl<E: Engine> Audio for ArrangerApp<E> {
|
||||
impl<E: Engine> Audio for ArrangerView<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 +53,7 @@ impl<E: Engine> Audio for ArrangerApp<E> {
|
|||
}
|
||||
|
||||
/// Layout for standalone arranger app.
|
||||
impl Content for ArrangerApp<Tui> {
|
||||
impl Content for ArrangerView<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
let focused = self.arrangement.focused;
|
||||
|
|
@ -103,7 +93,7 @@ impl Content for ArrangerApp<Tui> {
|
|||
}
|
||||
|
||||
/// General methods for arranger
|
||||
impl<E: Engine> ArrangerApp<E> {
|
||||
impl<E: Engine> ArrangerView<E> {
|
||||
pub fn new (
|
||||
jack: &Arc<RwLock<JackClient>>,
|
||||
transport: Option<Arc<RwLock<TransportToolbar<E>>>>,
|
||||
|
|
@ -126,10 +116,10 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
clock: if let Some(ref transport) = transport {
|
||||
transport.read().unwrap().clock.clone()
|
||||
} else {
|
||||
Arc::new(TransportTime::default())
|
||||
Arc::new(Clock::default())
|
||||
},
|
||||
menu: {
|
||||
use ArrangerAppCommand::*;
|
||||
use ArrangerViewCommand::*;
|
||||
MenuBar::new()
|
||||
.add({
|
||||
use ArrangementCommand::*;
|
||||
|
|
@ -139,7 +129,7 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
.cmd("s", "Save project", Arrangement(Save))
|
||||
})
|
||||
.add({
|
||||
use TransportAppCommand::*;
|
||||
use TransportViewCommand::*;
|
||||
Menu::new("Transport")
|
||||
.cmd("p", "Play", Transport(Play))
|
||||
.cmd("s", "Play from start", Transport(PlayFromStart))
|
||||
|
|
@ -188,7 +178,7 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
|
||||
//pub fn new (
|
||||
//jack: &Arc<RwLock<JackClient>>,
|
||||
//clock: &Arc<TransportTime>,
|
||||
//clock: &Arc<Clock>,
|
||||
//name: &str,
|
||||
//phrases: &Arc<RwLock<PhrasePool<E>>>
|
||||
//) -> Self {
|
||||
|
|
@ -234,7 +224,7 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
self.arrangement.phrase_put();
|
||||
}
|
||||
self.show_phrase();
|
||||
self.focus(ArrangerAppFocus::PhraseEditor);
|
||||
self.focus(ArrangerViewFocus::PhraseEditor);
|
||||
self.editor.entered = true;
|
||||
}
|
||||
/// Rename the selected track, scene, or clip
|
||||
|
|
@ -247,7 +237,7 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
ArrangementEditorFocus::Clip(t, s) => if let Some(ref phrase) = scenes[s].clips[t] {
|
||||
let index = self.phrases.read().unwrap().index_of(&*phrase.read().unwrap());
|
||||
if let Some(index) = index {
|
||||
self.focus(ArrangerAppFocus::PhrasePool);
|
||||
self.focus(ArrangerViewFocus::PhrasePool);
|
||||
self.phrases.write().unwrap().phrase = index;
|
||||
self.phrases.write().unwrap().begin_rename();
|
||||
}
|
||||
|
|
@ -257,15 +247,15 @@ impl<E: Engine> ArrangerApp<E> {
|
|||
/// Update status bar
|
||||
pub fn update_status (&mut self) {
|
||||
self.status = match self.focused() {
|
||||
ArrangerAppFocus::Transport => ArrangerStatusBar::Transport,
|
||||
ArrangerAppFocus::Arrangement => match self.arrangement.selected {
|
||||
ArrangerViewFocus::Transport => ArrangerStatusBar::Transport,
|
||||
ArrangerViewFocus::Arrangement => match self.arrangement.selected {
|
||||
ArrangementEditorFocus::Mix => ArrangerStatusBar::ArrangementMix,
|
||||
ArrangementEditorFocus::Track(_) => ArrangerStatusBar::ArrangementTrack,
|
||||
ArrangementEditorFocus::Scene(_) => ArrangerStatusBar::ArrangementScene,
|
||||
ArrangementEditorFocus::Clip(_, _) => ArrangerStatusBar::ArrangementClip,
|
||||
},
|
||||
ArrangerAppFocus::PhrasePool => ArrangerStatusBar::PhrasePool,
|
||||
ArrangerAppFocus::PhraseEditor => match self.editor.entered {
|
||||
ArrangerViewFocus::PhrasePool => ArrangerStatusBar::PhrasePool,
|
||||
ArrangerViewFocus::PhraseEditor => match self.editor.entered {
|
||||
true => ArrangerStatusBar::PhraseEdit,
|
||||
false => ArrangerStatusBar::PhraseView,
|
||||
},
|
||||
|
|
@ -563,7 +553,7 @@ impl<E: Engine> Arrangement<E> {
|
|||
impl ArrangementTrack {
|
||||
pub fn new (
|
||||
jack: &Arc<RwLock<JackClient>>,
|
||||
clock: &Arc<TransportTime>,
|
||||
clock: &Arc<Clock>,
|
||||
name: &str,
|
||||
color: Option<ItemColor>
|
||||
) -> Usually<Self> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue