mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
101 lines
2.7 KiB
Rust
101 lines
2.7 KiB
Rust
use crate::*;
|
|
|
|
/// Root view for standalone `tek_sequencer`.
|
|
pub struct SequencerTui {
|
|
pub jack: Arc<RwLock<JackClient>>,
|
|
pub clock: ClockModel,
|
|
pub phrases: PhrasesModel,
|
|
pub player: PhrasePlayerModel,
|
|
pub editor: PhraseEditorModel,
|
|
pub size: Measure<Tui>,
|
|
pub cursor: (usize, usize),
|
|
pub split: u16,
|
|
pub entered: bool,
|
|
pub note_buf: Vec<u8>,
|
|
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
|
pub focus: FocusState<AppFocus<SequencerFocus>>,
|
|
pub perf: PerfModel,
|
|
}
|
|
|
|
impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
|
|
type Error = Box<dyn std::error::Error>;
|
|
fn try_from (jack: &Arc<RwLock<JackClient>>) -> Usually<Self> {
|
|
let clock = ClockModel::from(&Arc::new(jack.read().unwrap().transport()));
|
|
Ok(Self {
|
|
jack: jack.clone(),
|
|
phrases: PhrasesModel::default(),
|
|
player: PhrasePlayerModel::from(&clock),
|
|
editor: PhraseEditorModel::default(),
|
|
size: Measure::new(),
|
|
cursor: (0, 0),
|
|
entered: false,
|
|
split: 20,
|
|
midi_buf: vec![vec![];65536],
|
|
note_buf: vec![],
|
|
clock,
|
|
focus: FocusState::Entered(AppFocus::Content(SequencerFocus::Transport(TransportFocus::Bpm))),
|
|
perf: PerfModel::default(),
|
|
})
|
|
}
|
|
}
|
|
|
|
/// Sections in the sequencer app that may be focused
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
pub enum SequencerFocus {
|
|
/// The transport (toolbar) is focused
|
|
Transport(TransportFocus),
|
|
/// The phrase list (pool) is focused
|
|
Phrases,
|
|
/// The phrase editor (sequencer) is focused
|
|
PhraseEditor,
|
|
}
|
|
|
|
impl_focus!(SequencerTui SequencerFocus [
|
|
//&[
|
|
//Menu,
|
|
//Menu,
|
|
//Menu,
|
|
//Menu,
|
|
//Menu,
|
|
//],
|
|
&[
|
|
Content(Transport(TransportFocus::PlayPause)),
|
|
Content(Transport(TransportFocus::Bpm)),
|
|
Content(Transport(TransportFocus::Sync)),
|
|
Content(Transport(TransportFocus::Clock)),
|
|
Content(Transport(TransportFocus::Quant))
|
|
],
|
|
&[
|
|
Content(Phrases),
|
|
Content(Phrases),
|
|
Content(PhraseEditor),
|
|
Content(PhraseEditor),
|
|
Content(PhraseEditor),
|
|
],
|
|
]);
|
|
|
|
/// Status bar for sequencer app
|
|
#[derive(Copy, Clone)]
|
|
pub enum SequencerStatusBar {
|
|
Transport,
|
|
PhrasePool,
|
|
PhraseEditor,
|
|
}
|
|
|
|
impl StatusBar for SequencerStatusBar {
|
|
type State = ();
|
|
fn hotkey_fg () -> Color {
|
|
TuiTheme::hotkey_fg()
|
|
}
|
|
fn update (&mut self, state: &()) {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
impl Content for SequencerStatusBar {
|
|
type Engine = Tui;
|
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
|
todo!();
|
|
""
|
|
}
|
|
}
|