mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
117 lines
2.7 KiB
Rust
117 lines
2.7 KiB
Rust
pub(crate) use tek_core::crossterm::event::{KeyCode, KeyModifiers};
|
|
pub(crate) use tek_core::midly::{num::u7, live::LiveEvent, MidiMessage};
|
|
pub(crate) use tek_core::jack::*;
|
|
pub(crate) use tek_api::*;
|
|
pub(crate) use tek_snd::*;
|
|
|
|
pub(crate) use std::collections::BTreeMap;
|
|
pub(crate) use std::sync::{Arc, Mutex, RwLock};
|
|
pub(crate) use std::path::PathBuf;
|
|
pub(crate) use std::ffi::OsString;
|
|
pub(crate) use std::fs::read_dir;
|
|
|
|
use std::fmt::Debug;
|
|
|
|
submod! {
|
|
tui_arranger
|
|
//tui_mixer // TODO
|
|
tui_phrase
|
|
//tui_plugin // TODO
|
|
//tui_plugin_lv2
|
|
//tui_plugin_lv2_gui
|
|
//tui_plugin_vst2
|
|
//tui_plugin_vst3
|
|
tui_pool
|
|
tui_pool_length
|
|
tui_pool_rename
|
|
//tui_sampler // TODO
|
|
//tui_sampler_cmd
|
|
tui_sequencer
|
|
tui_status
|
|
tui_theme
|
|
tui_transport
|
|
}
|
|
|
|
pub struct AppView<E, A, C, S>
|
|
where
|
|
E: Engine,
|
|
A: Widget<Engine = E> + Audio,
|
|
C: Command<Self>,
|
|
S: StatusBar,
|
|
{
|
|
pub app: A,
|
|
pub cursor: (usize, usize),
|
|
pub entered: bool,
|
|
pub menu_bar: Option<MenuBar<E, Self, C>>,
|
|
pub status_bar: Option<S>,
|
|
pub history: Vec<C>,
|
|
pub size: Measure<E>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum AppViewCommand<T: Debug + Clone> {
|
|
Focus(FocusCommand),
|
|
Undo,
|
|
Redo,
|
|
App(T)
|
|
}
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
|
pub enum AppViewFocus<F: Debug + Copy + Clone + PartialEq> {
|
|
Menu,
|
|
Content(F),
|
|
}
|
|
|
|
impl<E, A, C, S> AppView<E, A, C, S>
|
|
where
|
|
E: Engine,
|
|
A: Widget<Engine = E> + Audio,
|
|
C: Command<Self>,
|
|
S: StatusBar
|
|
{
|
|
pub fn new (
|
|
app: A,
|
|
menu_bar: Option<MenuBar<E, Self, C>>,
|
|
status_bar: Option<S>,
|
|
) -> Self {
|
|
Self {
|
|
app,
|
|
cursor: (0, 0),
|
|
entered: false,
|
|
history: vec![],
|
|
size: Measure::new(),
|
|
menu_bar,
|
|
status_bar,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<A, C, S> Content for AppView<Tui, A, C, S>
|
|
where
|
|
A: Widget<Engine = Tui> + Audio,
|
|
C: Command<Self>,
|
|
S: StatusBar,
|
|
{
|
|
type Engine = Tui;
|
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
|
let menus = self.menu_bar.as_ref().map_or_else(
|
|
||&[] as &[Menu<_, _, _>],
|
|
|m|m.menus.as_slice()
|
|
);
|
|
Split::down(
|
|
if self.menu_bar.is_some() { 1 } else { 0 },
|
|
row!(menu in menus.iter() => {
|
|
row!(" ", menu.title.as_str(), " ")
|
|
}),
|
|
Either(
|
|
self.status_bar.is_some(),
|
|
Split::up(
|
|
1,
|
|
widget(self.status_bar.as_ref().unwrap()),
|
|
widget(&self.app)
|
|
),
|
|
widget(&self.app)
|
|
)
|
|
)
|
|
}
|
|
}
|