mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
feat: run stub tek_chain
This commit is contained in:
parent
2a60808239
commit
c089e6cfa4
9 changed files with 60 additions and 38 deletions
|
|
@ -10,6 +10,15 @@ pub struct Chain {
|
|||
pub device: usize,
|
||||
}
|
||||
|
||||
handle!(Chain |self, event| handle_keymap(self, event, KEYMAP_CHAIN));
|
||||
|
||||
render!(Chain |self, buf, area| ChainView {
|
||||
chain: Some(&self),
|
||||
direction: tek_core::Direction::Right,
|
||||
focused: true,
|
||||
entered: true,
|
||||
}.render(buf, area));
|
||||
|
||||
impl Chain {
|
||||
pub fn new (name: &str) -> Usually<Self> {
|
||||
Ok(Self {
|
||||
|
|
@ -36,7 +45,7 @@ impl Chain {
|
|||
//}
|
||||
//Ok(())
|
||||
//}
|
||||
//pub fn connect_last_device (&self, app: &App) -> Usually<()> {
|
||||
//pub fn connect_last_device (&self, app: &Chain) -> Usually<()> {
|
||||
//Ok(match self.devices.get(self.devices.len().saturating_sub(1)) {
|
||||
//Some(device) => {
|
||||
//app.audio_out(0).map(|left|device.connect_audio_out(0, &left)).transpose()?;
|
||||
|
|
@ -48,3 +57,30 @@ impl Chain {
|
|||
//}
|
||||
}
|
||||
|
||||
/// Key bindings for chain section.
|
||||
pub const KEYMAP_CHAIN: &'static [KeyBinding<Chain>] = keymap!(Chain {
|
||||
[Up, NONE, "chain_cursor_up", "move cursor up", |_: &mut Chain| {
|
||||
Ok(true)
|
||||
}],
|
||||
[Down, NONE, "chain_cursor_down", "move cursor down", |_: &mut Chain| {
|
||||
Ok(true)
|
||||
}],
|
||||
[Left, NONE, "chain_cursor_left", "move cursor left", |app: &mut Chain| {
|
||||
//if let Some(track) = app.arranger.track_mut() {
|
||||
//track.device = track.device.saturating_sub(1);
|
||||
//return Ok(true)
|
||||
//}
|
||||
Ok(false)
|
||||
}],
|
||||
[Right, NONE, "chain_cursor_right", "move cursor right", |app: &mut Chain| {
|
||||
//if let Some(track) = app.arranger.track_mut() {
|
||||
//track.device = (track.device + 1).min(track.devices.len().saturating_sub(1));
|
||||
//return Ok(true)
|
||||
//}
|
||||
Ok(false)
|
||||
}],
|
||||
[Char('`'), NONE, "chain_mode_switch", "switch the display mode", |app: &mut Chain| {
|
||||
//app.chain_mode = !app.chain_mode;
|
||||
Ok(true)
|
||||
}],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl<'a> Render for ChainView<'a> {
|
|||
Style::default().dim()
|
||||
})
|
||||
.render_areas(buf, area)?;
|
||||
if self.focused && self.entered {
|
||||
if self.focused && self.entered && areas.len() > 0 {
|
||||
Corners(Style::default().green().not_dim()).draw(buf, areas[0])?;
|
||||
}
|
||||
Ok(area)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,4 @@ pub(crate) use tek_core::*;
|
|||
pub(crate) use tek_core::ratatui::prelude::*;
|
||||
pub(crate) use tek_jack::*;
|
||||
pub(crate) use std::sync::RwLockWriteGuard;
|
||||
submod! {
|
||||
chain
|
||||
chain_view
|
||||
}
|
||||
submod! { chain chain_view }
|
||||
|
|
|
|||
9
crates/tek_chain/src/main.rs
Normal file
9
crates/tek_chain/src/main.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
pub(crate) use tek_core::*;
|
||||
pub(crate) use tek_core::ratatui::prelude::*;
|
||||
pub(crate) use tek_jack::*;
|
||||
pub(crate) use std::sync::RwLockWriteGuard;
|
||||
submod! { chain chain_view }
|
||||
pub fn main () -> Usually<()> {
|
||||
tek_core::run(Arc::new(RwLock::new(crate::Chain::new("todo")?)))?;
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue