mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
reenable inc/dec phrase
This commit is contained in:
parent
c3040cef1c
commit
2c8f4857dd
11 changed files with 217 additions and 585 deletions
|
|
@ -48,19 +48,19 @@
|
||||||
(:14 (44 100)))
|
(:14 (44 100)))
|
||||||
|
|
||||||
(phrase { :name "Trapping" :beats 8 :steps 96 }
|
(phrase { :name "Trapping" :beats 8 :steps 96 }
|
||||||
(:00 (42 100) (36 100) (34 120))
|
(:00 (42 100) (36 100) (34 120) (49 100))
|
||||||
(:01 (42 100))
|
(:01 (42 100))
|
||||||
(:02 (42 100))
|
(:02 (42 100))
|
||||||
(:06 (42 100) (36 100))
|
(:06 (42 100) (35 80) (36 80) (49 100))
|
||||||
(:06 (42 100) (36 100) (34 100))
|
|
||||||
(:07 (42 100))
|
(:07 (42 100))
|
||||||
(:08 (42 100))
|
(:08 (42 100))
|
||||||
(:12 (42 100))
|
(:12 (42 100))
|
||||||
|
(:15 (39 100) (34 100))
|
||||||
(:18 (42 100))
|
(:18 (42 100))
|
||||||
(:24 (42 100) (38 50) (40 50))
|
(:24 (42 100) (38 50) (40 50))
|
||||||
(:27 (42 100) (36 50))
|
(:27 (42 100) (36 50))
|
||||||
(:30 (42 100) (34 100))
|
(:30 (42 100))
|
||||||
(:33 (42 100) (36 50))
|
(:33 (42 100) (36 50) (34 100))
|
||||||
(:36 (42 90))
|
(:36 (42 90))
|
||||||
(:39 (42 80))
|
(:39 (42 80))
|
||||||
(:42 (42 70))
|
(:42 (42 70))
|
||||||
|
|
@ -68,11 +68,12 @@
|
||||||
|
|
||||||
(:48 (42 100) (36 100) (34 100))
|
(:48 (42 100) (36 100) (34 100))
|
||||||
(:50 (42 100))
|
(:50 (42 100))
|
||||||
(:52 (42 100))
|
(:52 (42 110))
|
||||||
(:54 (42 100))
|
(:54 (46 50) (42 120))
|
||||||
(:56 (42 100))
|
(:56 (42 90))
|
||||||
(:58 (42 100))
|
(:58 (42 100))
|
||||||
(:60 (42 100) (35 100))
|
(:60 (42 100) (35 100))
|
||||||
|
(:64 (39 100))
|
||||||
(:66 (42 100) (34 100))
|
(:66 (42 100) (34 100))
|
||||||
|
|
||||||
(:70 (42 100))
|
(:70 (42 100))
|
||||||
|
|
@ -81,7 +82,7 @@
|
||||||
(:75 (42 100) (36 50) (34 80))
|
(:75 (42 100) (36 50) (34 80))
|
||||||
(:78 (42 100))
|
(:78 (42 100))
|
||||||
(:81 (42 100) (36 50))
|
(:81 (42 100) (36 50))
|
||||||
(:84 (42 90) (38 40) (40 50) (34 90))
|
(:84 (38 40) (40 50) (34 90))
|
||||||
(:87 (42 90) (35 40))
|
(:87 (42 90) (35 40))
|
||||||
(:90 (42 70)))
|
(:90 (42 70)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ render!(SetupModal |self, buf, area| {
|
||||||
let width = lines[0].0.len() as u16;
|
let width = lines[0].0.len() as u16;
|
||||||
let x = area.x + (area.width - width) / 2;
|
let x = area.x + (area.width - width) / 2;
|
||||||
for (i, (line, style)) in lines.iter().enumerate() {
|
for (i, (line, style)) in lines.iter().enumerate() {
|
||||||
line.blit(buf, x, area.y + area.height / 2 - (lines.len() / 2) as u16 + i as u16, Some(*style));
|
line.blit(buf, x, area.y + area.height / 2 - (lines.len() / 2) as u16 + i as u16, Some(*style))?;
|
||||||
}
|
}
|
||||||
Ok(area)
|
Ok(area)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::{core::*, model::App};
|
||||||
|
|
||||||
pub const KEYMAP_ARRANGER: &'static [KeyBinding<App>] = keymap!(App {
|
pub const KEYMAP_ARRANGER: &'static [KeyBinding<App>] = keymap!(App {
|
||||||
[Char('`'), NONE, "arranger_mode_switch", "switch the display mode", |app: &mut App| {
|
[Char('`'), NONE, "arranger_mode_switch", "switch the display mode", |app: &mut App| {
|
||||||
app.arranger_mode = !app.seq_mode;
|
app.arranger_mode = !app.arranger_mode;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
[Up, NONE, "arranger_cursor_up", "move cursor up", |app: &mut App| Ok(
|
[Up, NONE, "arranger_cursor_up", "move cursor up", |app: &mut App| Ok(
|
||||||
|
|
|
||||||
|
|
@ -5,59 +5,50 @@ pub fn handle (state: &mut Plugin, event: &AppEvent) -> Usually<bool> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const KEYMAP: &'static [KeyBinding<Plugin>] = keymap!(Plugin {
|
pub const KEYMAP: &'static [KeyBinding<Plugin>] = keymap!(Plugin {
|
||||||
[Up, NONE, "cursor_up", "move cursor up", cursor_up],
|
[Up, NONE, "cursor_up", "move cursor up", |s: &mut Plugin|{
|
||||||
[Down, NONE, "cursor_down", "move cursor down", cursor_down],
|
s.selected = s.selected.saturating_sub(1);
|
||||||
[Char(','), NONE, "decrement", "decrement value", decrement],
|
Ok(true)
|
||||||
[Char('.'), NONE, "increment", "increment value", increment],
|
}],
|
||||||
});
|
[Down, NONE, "cursor_down", "move cursor down", |s: &mut Plugin|{
|
||||||
|
s.selected = (s.selected + 1).min(match &s.plugin {
|
||||||
fn cursor_up (s: &mut Plugin) -> Usually<bool> {
|
|
||||||
if s.selected > 0 {
|
|
||||||
s.selected = s.selected - 1
|
|
||||||
} else {
|
|
||||||
s.selected = match &s.plugin {
|
|
||||||
Some(PluginKind::LV2(LV2Plugin { port_list, .. })) => port_list.len() - 1,
|
Some(PluginKind::LV2(LV2Plugin { port_list, .. })) => port_list.len() - 1,
|
||||||
_ => 0
|
_ => unimplemented!()
|
||||||
|
});
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[PageUp, NONE, "cursor_up", "move cursor up", |s: &mut Plugin|{
|
||||||
|
s.selected = s.selected.saturating_sub(8);
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[PageDown, NONE, "cursor_down", "move cursor down", |s: &mut Plugin|{
|
||||||
|
s.selected = (s.selected + 10).min(match &s.plugin {
|
||||||
|
Some(PluginKind::LV2(LV2Plugin { port_list, .. })) => port_list.len() - 1,
|
||||||
|
_ => unimplemented!()
|
||||||
|
});
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[Char(','), NONE, "decrement", "decrement value", |s: &mut Plugin|{
|
||||||
|
match s.plugin.as_mut() {
|
||||||
|
Some(PluginKind::LV2(LV2Plugin { port_list, ref mut instance, .. })) => {
|
||||||
|
let index = port_list[s.selected].index;
|
||||||
|
if let Some(value) = instance.control_input(index) {
|
||||||
|
instance.set_control_input(index, value - 0.01);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
Ok(true)
|
||||||
Ok(true)
|
}],
|
||||||
}
|
[Char('.'), NONE, "increment", "increment value", |s: &mut Plugin|{
|
||||||
|
match s.plugin.as_mut() {
|
||||||
fn cursor_down (s: &mut Plugin) -> Usually<bool> {
|
Some(PluginKind::LV2(LV2Plugin { port_list, ref mut instance, .. })) => {
|
||||||
s.selected = s.selected + 1;
|
let index = port_list[s.selected].index;
|
||||||
match &s.plugin {
|
if let Some(value) = instance.control_input(index) {
|
||||||
Some(PluginKind::LV2(LV2Plugin { port_list, .. })) => {
|
instance.set_control_input(index, value + 0.01);
|
||||||
if s.selected >= port_list.len() {
|
}
|
||||||
s.selected = 0;
|
},
|
||||||
}
|
_ => {}
|
||||||
},
|
}
|
||||||
_ => {}
|
Ok(true)
|
||||||
}
|
}],
|
||||||
Ok(true)
|
});
|
||||||
}
|
|
||||||
|
|
||||||
fn decrement (s: &mut Plugin) -> Usually<bool> {
|
|
||||||
match s.plugin.as_mut() {
|
|
||||||
Some(PluginKind::LV2(LV2Plugin { port_list, ref mut instance, .. })) => {
|
|
||||||
let index = port_list[s.selected].index;
|
|
||||||
if let Some(value) = instance.control_input(index) {
|
|
||||||
instance.set_control_input(index, value - 0.01);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
Ok(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn increment (s: &mut Plugin) -> Usually<bool> {
|
|
||||||
match s.plugin.as_mut() {
|
|
||||||
Some(PluginKind::LV2(LV2Plugin { port_list, ref mut instance, .. })) => {
|
|
||||||
let index = port_list[s.selected].index;
|
|
||||||
if let Some(value) = instance.control_input(index) {
|
|
||||||
instance.set_control_input(index, value + 0.01);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
Ok(true)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ pub struct JackDevice {
|
||||||
/// The "real" readable/writable `Port`s are owned by the `state`.
|
/// The "real" readable/writable `Port`s are owned by the `state`.
|
||||||
pub ports: UnownedJackPorts,
|
pub ports: UnownedJackPorts,
|
||||||
}
|
}
|
||||||
|
render!(JackDevice |self, buf, area| {
|
||||||
|
self.state.read().unwrap().render(buf, area)
|
||||||
|
});
|
||||||
ports!(JackDevice {
|
ports!(JackDevice {
|
||||||
audio: {
|
audio: {
|
||||||
ins: |s|Ok(s.ports.audio_ins.values().collect()),
|
ins: |s|Ok(s.ports.audio_ins.values().collect()),
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ impl Track {
|
||||||
Ok(match self.devices.get(self.devices.len().saturating_sub(1)) {
|
Ok(match self.devices.get(self.devices.len().saturating_sub(1)) {
|
||||||
Some(device) => {
|
Some(device) => {
|
||||||
app.audio_out(0).map(|left|device.connect_audio_out(0, &left)).transpose()?;
|
app.audio_out(0).map(|left|device.connect_audio_out(0, &left)).transpose()?;
|
||||||
app.audio_out(1).map(|right|device.connect_audio_out(0, &right)).transpose()?;
|
app.audio_out(1).map(|right|device.connect_audio_out(1, &right)).transpose()?;
|
||||||
()
|
()
|
||||||
},
|
},
|
||||||
None => ()
|
None => ()
|
||||||
|
|
|
||||||
28
src/view.rs
28
src/view.rs
|
|
@ -1,6 +1,5 @@
|
||||||
pub mod chain;
|
pub mod chain;
|
||||||
pub mod arranger;
|
pub mod arranger;
|
||||||
pub mod layout;
|
|
||||||
pub mod sampler;
|
pub mod sampler;
|
||||||
pub mod sequencer;
|
pub mod sequencer;
|
||||||
pub mod transport;
|
pub mod transport;
|
||||||
|
|
@ -8,7 +7,6 @@ pub mod plugin;
|
||||||
pub mod border;
|
pub mod border;
|
||||||
|
|
||||||
pub use self::border::*;
|
pub use self::border::*;
|
||||||
pub use self::layout::*;
|
|
||||||
pub use self::transport::TransportView;
|
pub use self::transport::TransportView;
|
||||||
pub use self::arranger::*;
|
pub use self::arranger::*;
|
||||||
pub use self::chain::ChainView;
|
pub use self::chain::ChainView;
|
||||||
|
|
@ -22,7 +20,7 @@ render!(App |self, buf, area| {
|
||||||
&ArrangerView::new(&self, !self.arranger_mode),
|
&ArrangerView::new(&self, !self.arranger_mode),
|
||||||
&If(self.track_cursor > 0, &Split::right([
|
&If(self.track_cursor > 0, &Split::right([
|
||||||
&ChainView::vertical(&self),
|
&ChainView::vertical(&self),
|
||||||
&self.seq_buf,
|
&SequencerView::new(&self),
|
||||||
]))
|
]))
|
||||||
]).render(buf, area)?;
|
]).render(buf, area)?;
|
||||||
if let Some(ref modal) = self.modal {
|
if let Some(ref modal) = self.modal {
|
||||||
|
|
@ -43,12 +41,28 @@ impl<'a> Render for If<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Direction {
|
pub trait Modal<T>: Device {
|
||||||
Down,
|
fn handle_with_state (&self, state: &mut T, event: &AppEvent) -> Usually<bool>;
|
||||||
Right,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Split<'a, const N: usize>(pub Direction, pub [&'a (dyn Render + Sync);N]);
|
#[derive(Copy, Clone)]
|
||||||
|
pub enum Direction { Down, Right }
|
||||||
|
|
||||||
|
impl Direction {
|
||||||
|
pub fn split <'a, const N: usize> (&self, items: [&'a (dyn Render + Sync);N]) -> Split<'a, N> {
|
||||||
|
Split(*self, items)
|
||||||
|
}
|
||||||
|
pub fn is_down (&self) -> bool {
|
||||||
|
match self { Self::Down => true, _ => false }
|
||||||
|
}
|
||||||
|
pub fn is_right (&self) -> bool {
|
||||||
|
match self { Self::Right => true, _ => false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Split<'a, const N: usize>(
|
||||||
|
pub Direction, pub [&'a (dyn Render + Sync);N]
|
||||||
|
);
|
||||||
|
|
||||||
impl<'a, const N: usize> Split<'a, N> {
|
impl<'a, const N: usize> Split<'a, N> {
|
||||||
pub fn down (items: [&'a (dyn Render + Sync);N]) -> Self {
|
pub fn down (items: [&'a (dyn Render + Sync);N]) -> Self {
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ use crate::model::*;
|
||||||
use crate::view::*;
|
use crate::view::*;
|
||||||
|
|
||||||
pub struct ArrangerView<'a> {
|
pub struct ArrangerView<'a> {
|
||||||
pub scenes: &'a[Scene],
|
scenes: &'a[Scene],
|
||||||
pub tracks: &'a[Track],
|
tracks: &'a[Track],
|
||||||
pub cursor: (usize, usize),
|
cursor: (usize, usize),
|
||||||
pub focused: bool,
|
focused: bool,
|
||||||
pub entered: bool,
|
entered: bool,
|
||||||
pub vertical: bool,
|
vertical: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ArrangerView<'a> {
|
impl<'a> ArrangerView<'a> {
|
||||||
|
|
@ -101,9 +101,9 @@ impl<'a> ArrangerView<'a> {
|
||||||
bg_color
|
bg_color
|
||||||
);
|
);
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
self.vertical_scenes(buf, x2+1, y2+2, area.height);
|
self.vertical_scenes(buf, x2+1, y2+2, area.height)?;
|
||||||
} else if i < columns.len() {
|
} else if i < columns.len() {
|
||||||
self.vertical_clips(buf, x2+1, y2+2, area.height, i - 1);
|
self.vertical_clips(buf, x2+1, y2+2, area.height, i - 1)?;
|
||||||
};
|
};
|
||||||
let style = Some(highlight(self.focused, focus_column).bold());
|
let style = Some(highlight(self.focused, focus_column).bold());
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
@ -113,9 +113,9 @@ impl<'a> ArrangerView<'a> {
|
||||||
Style::default().green()
|
Style::default().green()
|
||||||
} else {
|
} else {
|
||||||
Style::default().black()
|
Style::default().black()
|
||||||
}));
|
}))?;
|
||||||
}
|
}
|
||||||
title.blit(buf, x2+2, y2, style);
|
title.blit(buf, x2+2, y2, style)?;
|
||||||
x2 = x2 + w + 3;
|
x2 = x2 + w + 3;
|
||||||
}
|
}
|
||||||
fill_bg(
|
fill_bg(
|
||||||
|
|
@ -128,12 +128,12 @@ impl<'a> ArrangerView<'a> {
|
||||||
bg_color
|
bg_color
|
||||||
);
|
);
|
||||||
if self.focused {
|
if self.focused {
|
||||||
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()));
|
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()))?;
|
||||||
}
|
}
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vertical_scenes (&self, buf: &mut Buffer, x: u16, y: u16, height: u16) -> u16 {
|
fn vertical_scenes (&self, buf: &mut Buffer, x: u16, y: u16, height: u16) -> Usually<u16> {
|
||||||
let mut index = 0usize;
|
let mut index = 0usize;
|
||||||
loop {
|
loop {
|
||||||
if index >= self.scenes.len() {
|
if index >= self.scenes.len() {
|
||||||
|
|
@ -142,24 +142,25 @@ impl<'a> ArrangerView<'a> {
|
||||||
if y + index as u16 >= height {
|
if y + index as u16 >= height {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
self.vertical_scene(buf, x, y + index as u16, index);
|
self.vertical_scene(buf, x, y + index as u16, index)?;
|
||||||
index = index + 1;
|
index = index + 1;
|
||||||
}
|
}
|
||||||
longest_scene_name(&self.scenes)
|
Ok(longest_scene_name(&self.scenes))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vertical_scene (&self, buf: &mut Buffer, x: u16, y: u16, index: usize) {
|
fn vertical_scene (&self, buf: &mut Buffer, x: u16, y: u16, index: usize) -> Usually<()> {
|
||||||
if let Some(scene) = self.scenes.get(index) {
|
if let Some(scene) = self.scenes.get(index) {
|
||||||
let style = Some(highlight(
|
let style = Some(highlight(
|
||||||
self.focused,
|
self.focused,
|
||||||
(0 == self.cursor.0) && (index + 1 == self.cursor.1)
|
(0 == self.cursor.0) && (index + 1 == self.cursor.1)
|
||||||
).bold());
|
).bold());
|
||||||
"⯈".blit(buf, x, y, style);
|
"⯈".blit(buf, x, y, style)?;
|
||||||
scene.name.blit(buf, x + 2, y, style);
|
scene.name.blit(buf, x + 2, y, style)?;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vertical_clips (&self, buf: &mut Buffer, x: u16, y: u16, height: u16, track: usize) -> u16 {
|
fn vertical_clips (&self, buf: &mut Buffer, x: u16, y: u16, height: u16, track: usize) -> Usually<u16> {
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
let mut width = 10;
|
let mut width = 10;
|
||||||
loop {
|
loop {
|
||||||
|
|
@ -169,14 +170,14 @@ impl<'a> ArrangerView<'a> {
|
||||||
if y + index as u16 >= height {
|
if y + index as u16 >= height {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
width = 10.max(self.vertical_clip(buf, x, y, track, index));
|
width = 10.max(self.vertical_clip(buf, x, y, track, index)?);
|
||||||
index = index + 1;
|
index = index + 1;
|
||||||
}
|
}
|
||||||
width
|
Ok(width)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vertical_clip (&self, buf: &mut Buffer, x: u16, y: u16, track: usize, index: usize) -> u16 {
|
fn vertical_clip (&self, buf: &mut Buffer, x: u16, y: u16, track: usize, index: usize) -> Usually<u16> {
|
||||||
if let Some(scene) = self.scenes.get(index) {
|
Ok(if let Some(scene) = self.scenes.get(index) {
|
||||||
let hi = (track + 1 == self.cursor.0) &&
|
let hi = (track + 1 == self.cursor.0) &&
|
||||||
(index + 1 == self.cursor.1);
|
(index + 1 == self.cursor.1);
|
||||||
let style = Some(highlight(self.focused, hi));
|
let style = Some(highlight(self.focused, hi));
|
||||||
|
|
@ -195,11 +196,11 @@ impl<'a> ArrangerView<'a> {
|
||||||
} else {
|
} else {
|
||||||
format!(" ·········")
|
format!(" ·········")
|
||||||
};
|
};
|
||||||
label.blit(buf, x, y + index, style);
|
label.blit(buf, x, y + index, style)?;
|
||||||
label.len() as u16
|
label.len() as u16
|
||||||
} else {
|
} else {
|
||||||
0u16
|
0u16
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,16 +218,16 @@ impl<'a> ArrangerView<'a> {
|
||||||
});
|
});
|
||||||
if self.focused && self.entered {
|
if self.focused && self.entered {
|
||||||
//RailV::draw(buf, Rect { x, y, width, height });
|
//RailV::draw(buf, Rect { x, y, width, height });
|
||||||
QuarterV(Style::default().green().dim()).draw(buf, Rect { x, y, width, height });
|
QuarterV(Style::default().green().dim()).draw(buf, Rect { x, y, width, height })?;
|
||||||
//lozenge_left(buf, x, y, height, style);
|
//lozenge_left(buf, x, y, height, style);
|
||||||
//lozenge_right(buf, x + width - 1, y, height, style);
|
//lozenge_right(buf, x + width - 1, y, height, style);
|
||||||
}
|
}
|
||||||
let mut x2 = 0;
|
let mut x2 = 0;
|
||||||
self.horizontal_tracks(buf, area, &mut x2);
|
self.horizontal_tracks(buf, area, &mut x2)?;
|
||||||
x2 = x2 + 1;
|
x2 = x2 + 1;
|
||||||
self.horizontal_scenes(buf, area, &mut x2);
|
self.horizontal_scenes(buf, area, &mut x2)?;
|
||||||
if self.focused {
|
if self.focused {
|
||||||
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()));
|
HELP.blit(buf, x + 2, y + height - 1, Some(Style::default().dim()))?;
|
||||||
}
|
}
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
|
|
@ -235,51 +236,58 @@ impl<'a> ArrangerView<'a> {
|
||||||
let h = (2 + self.tracks.len()) as u16;
|
let h = (2 + self.tracks.len()) as u16;
|
||||||
(w, h)
|
(w, h)
|
||||||
}
|
}
|
||||||
fn horizontal_tracks (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) {
|
fn horizontal_tracks (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) -> Usually<()> {
|
||||||
let style = Some(Style::default().bold().not_dim().white());
|
let style = Some(Style::default().bold().not_dim().white());
|
||||||
let Rect { x, y, height, .. } = area;
|
let Rect { x, y, height, .. } = area;
|
||||||
"Mix".blit(buf, x + 1, y, style);
|
"Mix".blit(buf, x + 1, y, style)?;
|
||||||
let style = Some(Style::default().bold());
|
let style = Some(Style::default().bold());
|
||||||
for (i, track) in self.tracks.iter().enumerate() {
|
for (i, track) in self.tracks.iter().enumerate() {
|
||||||
let y2 = y + 1 + i as u16 * 2;
|
let y2 = y + 1 + i as u16 * 2;
|
||||||
|
if self.cursor.0 > 0 {
|
||||||
|
if i == self.cursor.0 - 1 {
|
||||||
|
">".blit(buf, x, y2, style)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
let label = format!(" {:8}", &track.name);
|
let label = format!(" {:8}", &track.name);
|
||||||
label.blit(buf, x + 1, y2, style);
|
label.blit(buf, x + 1, y2, style)?;
|
||||||
"RDM".blit(buf, x + 10, y2, Some(Style::default().dim()));
|
"RDM".blit(buf, x + 10, y2, Some(Style::default().dim()))?;
|
||||||
" 0.0dB".blit(buf, x + 15, y2, Some(Style::default().dim()));
|
" 0.0dB".blit(buf, x + 15, y2, Some(Style::default().dim()))?;
|
||||||
*x2 = (*x2).max(label.len() as u16 + 13);
|
*x2 = (*x2).max(label.len() as u16 + 13);
|
||||||
}
|
}
|
||||||
"╷".blit(buf, x + *x2, y, style);
|
"╷".blit(buf, x + *x2, y, style)?;
|
||||||
for y in y+1..y+height-1 {
|
for y in y+1..y+height-1 {
|
||||||
"│".blit(buf, x + *x2, y, style);
|
"│".blit(buf, x + *x2, y, style)?;
|
||||||
}
|
}
|
||||||
//"╵".blit(buf, x + x2, y+height-1, style);
|
//"╵".blit(buf, x + x2, y+height-1, style);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
fn horizontal_scenes (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) {
|
fn horizontal_scenes (&self, buf: &mut Buffer, area: Rect, x2: &mut u16) -> Usually<()> {
|
||||||
let Rect { x, y, height, .. } = area;
|
let Rect { x, y, height, .. } = area;
|
||||||
let bold = Some(Style::default().bold());
|
let bold = Some(Style::default().bold());
|
||||||
let sep = Some(Style::default().dim());
|
let sep = Some(Style::default().dim());
|
||||||
for scene in self.scenes.iter() {
|
for scene in self.scenes.iter() {
|
||||||
let mut x3 = scene.name.len() as u16;
|
let mut x3 = scene.name.len() as u16;
|
||||||
scene.name.blit(buf, x + *x2, y, bold);
|
scene.name.blit(buf, x + *x2, y, bold)?;
|
||||||
for (i, clip) in scene.clips.iter().enumerate() {
|
for (i, clip) in scene.clips.iter().enumerate() {
|
||||||
if let Some(clip) = clip {
|
if let Some(clip) = clip {
|
||||||
if let Some(phrase) = self.tracks[i].phrases.get(*clip) {
|
if let Some(phrase) = self.tracks[i].phrases.get(*clip) {
|
||||||
let y2 = y + 1 + i as u16 * 2;
|
let y2 = y + 1 + i as u16 * 2;
|
||||||
let label = format!("{}", &phrase.name);
|
let label = format!("{}", &phrase.name);
|
||||||
label.blit(buf, x + *x2, y2, None);
|
label.blit(buf, x + *x2, y2, None)?;
|
||||||
x3 = x3.max(label.len() as u16)
|
x3 = x3.max(label.len() as u16)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*x2 = *x2 + x3;
|
*x2 = *x2 + x3;
|
||||||
|
|
||||||
"╷".blit(buf, x + *x2, y, sep);
|
"╷".blit(buf, x + *x2, y, sep)?;
|
||||||
for y in y+1..y+height-1 {
|
for y in y+1..y+height-1 {
|
||||||
"┊".blit(buf, x + *x2, y, sep);
|
"┊".blit(buf, x + *x2, y, sep)?;
|
||||||
}
|
}
|
||||||
"╵".blit(buf, x + *x2, y+height-1, sep);
|
"╵".blit(buf, x + *x2, y+height-1, sep)?;
|
||||||
*x2 = *x2 + 1;
|
*x2 = *x2 + 1;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
use crate::core::*;
|
use crate::core::*;
|
||||||
use crate::view::*;
|
|
||||||
use crate::model::*;
|
use crate::model::*;
|
||||||
|
use crate::view::{*, Direction};
|
||||||
|
|
||||||
pub struct ChainView<'a> {
|
pub struct ChainView<'a> {
|
||||||
pub focused: bool,
|
pub track: Option<&'a Track>,
|
||||||
pub track: Option<&'a Track>,
|
pub direction: Direction,
|
||||||
pub vertical: bool,
|
pub focused: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ChainView<'a> {
|
impl<'a> ChainView<'a> {
|
||||||
pub fn horizontal (app: &'a App) -> Self {
|
pub fn horizontal (app: &'a App) -> Self {
|
||||||
Self::new(app, false)
|
Self::new(app, Direction::Right)
|
||||||
}
|
}
|
||||||
pub fn vertical (app: &'a App) -> Self {
|
pub fn vertical (app: &'a App) -> Self {
|
||||||
Self::new(app, true)
|
Self::new(app, Direction::Down)
|
||||||
}
|
}
|
||||||
pub fn new (app: &'a App, vertical: bool) -> Self {
|
pub fn new (app: &'a App, direction: Direction) -> Self {
|
||||||
Self {
|
Self {
|
||||||
vertical,
|
direction,
|
||||||
focused: app.section == AppSection::Chain,
|
focused: app.section == AppSection::Chain,
|
||||||
track: match app.track_cursor {
|
track: match app.track_cursor {
|
||||||
0 => None,
|
0 => None,
|
||||||
|
|
@ -28,220 +28,66 @@ impl<'a> ChainView<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Render for ChainView<'a> {
|
impl<'a> Render for ChainView<'a> {
|
||||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
fn render (&self, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
||||||
let style = Some(if self.focused {
|
if let Some(track) = self.track {
|
||||||
Style::default().green().dim()
|
match self.direction {
|
||||||
} else {
|
Direction::Down => area.width = area.width.min(40),
|
||||||
Style::default().dim()
|
Direction::Right => area.width = area.width.min(10),
|
||||||
});
|
|
||||||
let Rect { x, y, width, height } = area;
|
|
||||||
if self.track.is_none() {
|
|
||||||
let label = "No track selected";
|
|
||||||
label.blit(
|
|
||||||
buf,
|
|
||||||
x + (width - label.len() as u16) / 2,
|
|
||||||
y + height / 2,
|
|
||||||
Some(Style::default().dim().bold())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
fill_bg(buf, area, if self.focused {
|
|
||||||
Color::Rgb(20, 45, 5)
|
|
||||||
} else {
|
|
||||||
Color::Reset
|
|
||||||
});
|
|
||||||
//lozenge_left(buf, x, y, height, style);
|
|
||||||
let (area, _plugins) = if self.track.is_some() {
|
|
||||||
if self.vertical {
|
|
||||||
self.draw_as_column(buf, area, style)?
|
|
||||||
} else {
|
|
||||||
self.draw_as_row(buf, area, style)?
|
|
||||||
}
|
}
|
||||||
|
fill_bg(buf, area, if self.focused { Color::Rgb(20, 45, 5) } else { Color::Reset });
|
||||||
|
self.direction
|
||||||
|
.split_focus(0, track.devices.as_slice(), if self.focused {
|
||||||
|
Style::default().green().dim()
|
||||||
|
} else {
|
||||||
|
Style::default().dim()
|
||||||
|
})
|
||||||
|
.render(buf, area)
|
||||||
} else {
|
} else {
|
||||||
(area, vec![])
|
let Rect { x, y, width, height } = area;
|
||||||
};
|
let label = "No track selected";
|
||||||
//lozenge_right(buf, x + width - 1, y, height, style);
|
let x = x + (width - label.len() as u16) / 2;
|
||||||
|
let y = y + height / 2;
|
||||||
|
label.blit(buf, x, y, Some(Style::default().dim().bold()))?;
|
||||||
|
Ok(area)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Renderables<'a> = &'a [JackDevice];
|
||||||
|
|
||||||
|
impl<'a> Direction {
|
||||||
|
fn split_focus (&self, index: usize, items: Renderables<'a>, style: Style) -> SplitFocus<'a> {
|
||||||
|
SplitFocus(*self, index, items, style)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SplitFocus<'a>(pub Direction, pub usize, pub Renderables<'a>, pub Style);
|
||||||
|
|
||||||
|
impl<'a> Render for SplitFocus<'a> {
|
||||||
|
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||||
|
let Rect { mut x, mut y, mut width, mut height } = area;
|
||||||
|
let mut results = vec![];
|
||||||
|
for item in self.2.iter() {
|
||||||
|
if width == 0 || height == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
let result = item.render(buf, Rect { x, y, width, height })?;
|
||||||
|
results.push(result);
|
||||||
|
match self.0 {
|
||||||
|
Direction::Down => {
|
||||||
|
y = y + result.height;
|
||||||
|
height = height.saturating_sub(result.height);
|
||||||
|
},
|
||||||
|
Direction::Right => {
|
||||||
|
x = x + result.width;
|
||||||
|
width = width.saturating_sub(result.width);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results
|
||||||
|
.get(self.1)
|
||||||
|
.map(|focused|Lozenge(self.3).draw(buf, *focused))
|
||||||
|
.transpose()?;
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ChainView<'a> {
|
|
||||||
pub fn draw_as_row (
|
|
||||||
&self, buf: &mut Buffer, area: Rect, style: Option<Style>
|
|
||||||
) -> Usually<(Rect, Vec<Rect>)> {
|
|
||||||
let Rect { mut x, y, width, height } = area;
|
|
||||||
let mut h = 3u16;
|
|
||||||
let mut frames = vec![];
|
|
||||||
let track = self.track.as_ref().unwrap();
|
|
||||||
for (i, device) in track.devices.iter().enumerate() {
|
|
||||||
let x2 = 0u16;
|
|
||||||
let _y2 = 1u16;
|
|
||||||
//for port in device.midi_ins()?.iter() {
|
|
||||||
//port.blit(buf, x, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
//for port in device.audio_ins()?.iter() {
|
|
||||||
//port.blit(buf, x, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
let width = width.saturating_sub(x).saturating_sub(x2);
|
|
||||||
let frame = device.state.read().unwrap()
|
|
||||||
.render(buf, Rect { x: x + x2, y, width, height })?;
|
|
||||||
let style = if i == track.device {
|
|
||||||
Some(if self.focused {
|
|
||||||
Style::default().green().bold().not_dim()
|
|
||||||
} else {
|
|
||||||
Style::default().green().dim()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
style
|
|
||||||
};
|
|
||||||
LozengeV(style.unwrap_or(Style::default())).draw(buf, frame);
|
|
||||||
//let mut y2 = 1u16;
|
|
||||||
//for port in device.midi_outs()?.iter() {
|
|
||||||
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
//for port in device.audio_outs()?.iter() {
|
|
||||||
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
frames.push(frame);
|
|
||||||
h = h.max(frame.height);
|
|
||||||
x = x + frame.width;
|
|
||||||
}
|
|
||||||
let label = "[Add device…]";
|
|
||||||
label.blit(buf, x + 1, area.y + 1, Some(Style::default().dim()));
|
|
||||||
x = x + 1 + label.len() as u16 + 1;
|
|
||||||
Ok((Rect { x: area.x, y: area.y, width: x, height: h }, frames))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_as_column (
|
|
||||||
&self, buf: &mut Buffer, area: Rect, selected: Option<Style>
|
|
||||||
) -> Usually<(Rect, Vec<Rect>)> {
|
|
||||||
let Rect { x, mut y, width, height } = area;
|
|
||||||
let mut w = 0u16;
|
|
||||||
let mut frames = vec![];
|
|
||||||
let track = self.track.as_ref().unwrap();
|
|
||||||
for (_i, device) in track.devices.iter().enumerate() {
|
|
||||||
//let midi_ins = device.midi_ins()?;
|
|
||||||
//let midi_outs = device.midi_outs()?;
|
|
||||||
//let audio_ins = device.audio_ins()?;
|
|
||||||
//let audio_outs = device.audio_outs()?;
|
|
||||||
let device = device.state.read().unwrap();
|
|
||||||
//let style_midi = Style::default().black().bold().on_green();
|
|
||||||
//let style_audio = Style::default().black().bold().on_red();
|
|
||||||
//y = y + midi_ins.len() as u16;
|
|
||||||
let frame = device.render(buf, Rect {
|
|
||||||
x, y, width, height: height.saturating_sub(y)
|
|
||||||
})?;
|
|
||||||
frames.push(frame);
|
|
||||||
w = w.max(frame.width);
|
|
||||||
y = y + frame.height;
|
|
||||||
//y = y - midi_ins.len() as u16;
|
|
||||||
//for port in midi_ins.iter() {
|
|
||||||
//buf.set_string(x + frame.width - 10, y, &format!(" <i> MIDI {} ", port.name()?), style_midi);
|
|
||||||
//y = y + 1;
|
|
||||||
//}
|
|
||||||
//y = y - audio_ins.len() as u16;
|
|
||||||
//for port in audio_ins.iter() {
|
|
||||||
//buf.set_string(x + frame.width - 10, y, &format!(" <i> MIDI {} ", port.name()?), style_audio);
|
|
||||||
//y = y + 1;
|
|
||||||
//}
|
|
||||||
//y = y + frame.height - 1;
|
|
||||||
//y = y + midi_outs.len() as u16;
|
|
||||||
//for port in midi_outs.iter() {
|
|
||||||
//buf.set_string(x + 2, y, &format!(" <o> MIDI {} ", port.name()?), style_midi);
|
|
||||||
//y = y + 1;
|
|
||||||
//}
|
|
||||||
//y = y + audio_outs.len() as u16;
|
|
||||||
//for port in audio_outs.iter() {
|
|
||||||
//buf.set_string(x + 2, y, &format!(" <o> Audio {} ", port.name()?), style_audio);
|
|
||||||
//y = y + 1;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
if frames.len() > 0 {
|
|
||||||
Lozenge(selected.unwrap_or(Style::default()))
|
|
||||||
.draw(buf, frames[track.device]);
|
|
||||||
}
|
|
||||||
Ok((Rect { x, y: area.y, width: w, height: y - area.y }, frames))
|
|
||||||
|
|
||||||
//let area = Rect { x, y, width: 40, height: 30 };
|
|
||||||
//let mut y = area.y;
|
|
||||||
//buf.set_string(area.x, y, "│", Style::default().black());
|
|
||||||
//buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
|
||||||
//buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
|
|
||||||
//let mut x = 0u16;
|
|
||||||
//for (i, device) in state.items.iter().enumerate() {
|
|
||||||
//let result = device.render(buf, Rect {
|
|
||||||
//x: area.x,
|
|
||||||
//y,
|
|
||||||
//width: area.width,
|
|
||||||
//height: 21//area.height.saturating_sub(y)
|
|
||||||
//})?;
|
|
||||||
//if i == state.focus {
|
|
||||||
//if state.focused {
|
|
||||||
//draw_box_styled(buf, result, Some(Style::default().green().not_dim()))
|
|
||||||
//} else {
|
|
||||||
//draw_box_styled_dotted(buf, result, Some(Style::default().green().dim()))
|
|
||||||
//};
|
|
||||||
//};
|
|
||||||
////let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
|
|
||||||
//x = x.max(result.width);
|
|
||||||
//y = y + result.height;
|
|
||||||
////y = y + 1;
|
|
||||||
//buf.set_string(area.x, y, "│", Style::default().black());
|
|
||||||
//buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
|
||||||
//buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
|
||||||
//y = y + 1;
|
|
||||||
////buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red());
|
|
||||||
////buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
|
||||||
////buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
|
||||||
//}
|
|
||||||
//Ok(draw_box(buf, Rect {
|
|
||||||
//x: area.x,
|
|
||||||
//y: area.y,
|
|
||||||
//width: area.width,
|
|
||||||
//height: y - area.y,
|
|
||||||
//}))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|
||||||
//-> Usually<Rect>
|
|
||||||
//{
|
|
||||||
//let Rect { x, y, .. } = area;
|
|
||||||
//let selected = Some(if state.focused {
|
|
||||||
//Style::default().green().not_dim()
|
|
||||||
//} else {
|
|
||||||
//Style::default().green().dim()
|
|
||||||
//});
|
|
||||||
//let result = match state.view {
|
|
||||||
//ChainViewMode::Hidden => Rect { x, y, width: 0, height: 0 },
|
|
||||||
//ChainViewMode::Compact => {
|
|
||||||
//let area = Rect { x, y, width: (state.name.len() + 4) as u16, height: 3 };
|
|
||||||
//buf.set_string(area.x + 2, area.y + 1, &state.name, Style::default());
|
|
||||||
//draw_box_styled(buf, area, selected)
|
|
||||||
//},
|
|
||||||
//ChainViewMode::Row => {
|
|
||||||
//draw_box_styled(buf, area, selected);
|
|
||||||
//let (area, _) = Row::draw(buf, area, &state.items, 0)?;
|
|
||||||
//area
|
|
||||||
//},
|
|
||||||
//ChainViewMode::Column => {
|
|
||||||
//draw_as_column(state, buf, area, selected)?
|
|
||||||
//},
|
|
||||||
//};
|
|
||||||
//Ok(result)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//pub enum ChainViewMode {
|
|
||||||
//Hidden,
|
|
||||||
//Compact,
|
|
||||||
//Row,
|
|
||||||
//Column,
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
//#![feature(fn_traits)]
|
|
||||||
//#![feature(unboxed_closures)]
|
|
||||||
use crate::core::*;
|
|
||||||
|
|
||||||
pub trait Modal<T>: Device {
|
|
||||||
fn handle_with_state (&self, state: &mut T, event: &AppEvent) -> Usually<bool>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait MaxHeight: Device {
|
|
||||||
fn max_height (&self) -> u16 {
|
|
||||||
u16::MAX
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Device> MaxHeight for T {}
|
|
||||||
|
|
||||||
pub enum Collected<'a> {
|
|
||||||
Box(Box<dyn Render + Sync + 'a>),
|
|
||||||
Ref(&'a (dyn Render + Sync + 'a)),
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Render for Collected<'a> {
|
|
||||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
|
||||||
match self {
|
|
||||||
Self::Box(item) => (*item).render(buf, area),
|
|
||||||
Self::Ref(item) => (*item).render(buf, area),
|
|
||||||
Self::None => Ok(area),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Collector<'a>(pub Vec<Collected<'a>>);
|
|
||||||
|
|
||||||
//impl<'a, R: Render + 'a> FnOnce<(R,)> for Collector<'a> {
|
|
||||||
//type Output = ();
|
|
||||||
//extern "rust-call" fn call_once (self, (device, ): (R,)) -> Self::Output {
|
|
||||||
//self.add(widget.into_collected());
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
impl<'a> Collector<'a> {
|
|
||||||
pub fn collect (collect: impl Fn(&mut Collector<'a>)) -> Self {
|
|
||||||
let mut items = Self(vec![]);
|
|
||||||
collect(&mut items);
|
|
||||||
items
|
|
||||||
}
|
|
||||||
fn add (mut self, widget: Collected<'a>) -> Self {
|
|
||||||
self.0.push(widget);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Collection<'a, T, U> {
|
|
||||||
fn add (self, widget: impl Render + 'a) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//struct AppLayout {
|
|
||||||
//focus: usize,
|
|
||||||
//track_focus: usize,
|
|
||||||
//chain_focus: usize,
|
|
||||||
//device_focus: usize,
|
|
||||||
//enter: bool,
|
|
||||||
//track_enter: bool,
|
|
||||||
//chain_enter: bool,
|
|
||||||
//device_enter: bool,
|
|
||||||
//}
|
|
||||||
|
|
||||||
//impl AppLayout {
|
|
||||||
//fn grid (&self) -> &mut crate::model::sampler::Sampler {
|
|
||||||
//unimplemented!();
|
|
||||||
//}
|
|
||||||
//fn has_track (&self) -> bool {
|
|
||||||
//unimplemented!();
|
|
||||||
//}
|
|
||||||
//fn sequencer (&self) -> &mut crate::model::sampler::Sampler {
|
|
||||||
//unimplemented!();
|
|
||||||
//}
|
|
||||||
//fn chain (&self) -> &mut crate::model::sampler::Sampler {
|
|
||||||
//unimplemented!();
|
|
||||||
//}
|
|
||||||
//fn chains (&self) -> Vec<&mut crate::model::sampler::Sampler> {
|
|
||||||
//unimplemented!();
|
|
||||||
//}
|
|
||||||
//fn devices (&self) -> Vec<&mut crate::model::sampler::Sampler> {
|
|
||||||
//unimplemented!();
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//handle!(AppLayout |self, event| {
|
|
||||||
//let mut grid = self.grid();
|
|
||||||
//let mut sequencer = self.sequencer();
|
|
||||||
//let mut devices = self.devices();
|
|
||||||
//let mut chains = self.chains();
|
|
||||||
//});
|
|
||||||
|
|
||||||
//struct FocusConst<'a, const N: usize>(
|
|
||||||
//usize,
|
|
||||||
//bool,
|
|
||||||
//[&'a mut dyn Handle; N]
|
|
||||||
//);
|
|
||||||
|
|
||||||
//impl<'a, const N: usize> Handle for FocusConst<'a, N> {
|
|
||||||
//fn handle (&mut self, event: &AppEvent) -> Usually<bool> {
|
|
||||||
//Ok(true)
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//struct FocusDyn<'a, T: Handle>(
|
|
||||||
//usize,
|
|
||||||
//bool,
|
|
||||||
//&'a mut [&mut T]
|
|
||||||
//);
|
|
||||||
|
|
||||||
//impl<'a, T: Handle> Handle for FocusDyn<'a, T> {
|
|
||||||
//fn handle (&mut self, event: &AppEvent) -> Usually<bool> {
|
|
||||||
//Ok(true)
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//render!(AppLayout |self, buf, area| {
|
|
||||||
//Flex::col(&[
|
|
||||||
//self.transport,
|
|
||||||
//Flex::col(&[
|
|
||||||
//self.grid,
|
|
||||||
//if self.track {
|
|
||||||
//Flex::col(&[
|
|
||||||
//self.sequencer,
|
|
||||||
//self.chain
|
|
||||||
//])
|
|
||||||
//} else {
|
|
||||||
//Flex::row(&self.chains)
|
|
||||||
//}
|
|
||||||
//])
|
|
||||||
//]).render(buf, area)
|
|
||||||
//})
|
|
||||||
|
|
||||||
//struct Flex<'a>(
|
|
||||||
//FlexDir,
|
|
||||||
//&'a [&'a dyn Render]
|
|
||||||
//);
|
|
||||||
|
|
||||||
//impl<'a> Flex<'a> {
|
|
||||||
//pub fn row (items: &'a [impl Render]) -> Self {
|
|
||||||
//Self(FlexDir::Row, items)
|
|
||||||
//}
|
|
||||||
//pub fn col (items: &'a [impl Render]) -> Self {
|
|
||||||
//Self(FlexDir::Col, items)
|
|
||||||
//}
|
|
||||||
//pub fn row_rev (items: &'a [impl Render]) -> Self {
|
|
||||||
//Self(FlexDir::RowRev, items)
|
|
||||||
//}
|
|
||||||
//pub fn col_rev (items: &'a [impl Render]) -> Self {
|
|
||||||
//Self(FlexDir::ColRev, items)
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//enum FlexDir {
|
|
||||||
//Row,
|
|
||||||
//Col,
|
|
||||||
//RowRev,
|
|
||||||
//ColRev
|
|
||||||
//}
|
|
||||||
|
|
||||||
//impl<'a> Render for Flex<'a> {
|
|
||||||
//fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
|
||||||
//let Rect { x, y, width, height } = area;
|
|
||||||
//let (mut x2, mut y2) = (0, 0);
|
|
||||||
//for item in self.1.iter() {
|
|
||||||
//let Rect { width, height, .. } = item.render(buf, Rect {
|
|
||||||
//x: x + x2, y: y + y2, width, height
|
|
||||||
//})?;
|
|
||||||
//let Rect { width, height, .. } = item.render(buf, match self.0 {
|
|
||||||
//FlexDir::Row => Rect {
|
|
||||||
//x: x + x2,
|
|
||||||
//y: y + y2,
|
|
||||||
//width: width - x2,
|
|
||||||
//height: height - y2,
|
|
||||||
//},
|
|
||||||
//FlexDir::Col => Rect {
|
|
||||||
//x: x + x2,
|
|
||||||
//y: y + y2,
|
|
||||||
//width: width - x2,
|
|
||||||
//height: height - y2,
|
|
||||||
//},
|
|
||||||
//FlexDir::RowRev => Rect {
|
|
||||||
//x: x + width - 1 - x2,
|
|
||||||
//y: y + y2,
|
|
||||||
//width: width - x2,
|
|
||||||
//height: height - y2,
|
|
||||||
//},
|
|
||||||
//FlexDir::ColRev => Rect {
|
|
||||||
//x: x + x2,
|
|
||||||
//y: y + height - 1 - y2,
|
|
||||||
//width: width - x2,
|
|
||||||
//height: height - y2,
|
|
||||||
//}
|
|
||||||
//})?;
|
|
||||||
//match self.0 {
|
|
||||||
//FlexDir::Row => {
|
|
||||||
//x2 = x2 + width;
|
|
||||||
//},
|
|
||||||
//FlexDir::Col => {
|
|
||||||
//y2 = y2 + height;
|
|
||||||
//},
|
|
||||||
//FlexDir::RowRev => {
|
|
||||||
//x2 = x2 + width
|
|
||||||
//},
|
|
||||||
//FlexDir::ColRev => {
|
|
||||||
//y2 = y2 + height;
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//Ok(area)
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
@ -4,7 +4,6 @@ pub struct TransportView {
|
||||||
pub record: bool,
|
pub record: bool,
|
||||||
pub overdub: bool,
|
pub overdub: bool,
|
||||||
pub monitor: bool,
|
pub monitor: bool,
|
||||||
pub frame: usize,
|
|
||||||
pub quant: usize,
|
pub quant: usize,
|
||||||
pub ppq: usize,
|
pub ppq: usize,
|
||||||
pub bpm: usize,
|
pub bpm: usize,
|
||||||
|
|
@ -18,7 +17,6 @@ impl TransportView {
|
||||||
monitor: app.track().map(|t|t.1.monitoring).unwrap_or(false),
|
monitor: app.track().map(|t|t.1.monitoring).unwrap_or(false),
|
||||||
record: app.track().map(|t|t.1.recording).unwrap_or(false),
|
record: app.track().map(|t|t.1.recording).unwrap_or(false),
|
||||||
overdub: app.track().map(|t|t.1.overdub).unwrap_or(false),
|
overdub: app.track().map(|t|t.1.overdub).unwrap_or(false),
|
||||||
frame: app.playhead,
|
|
||||||
quant: app.quant,
|
quant: app.quant,
|
||||||
ppq: app.timebase.ppq() as usize,
|
ppq: app.timebase.ppq() as usize,
|
||||||
bpm: app.timebase.bpm() as usize,
|
bpm: app.timebase.bpm() as usize,
|
||||||
|
|
@ -28,14 +26,16 @@ impl TransportView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render!(TransportView |self, buf, area| {
|
render!(TransportView |self, buf, area| {
|
||||||
let Self { ppq, frame, bpm, quant, pulse, usecs, .. } = self;
|
let mut area = area;
|
||||||
let frame = *frame as f64;
|
area.height = if area.width > 100 { 1 } else { 2 };
|
||||||
let Rect { x, y, width, .. } = area;
|
let Self { ppq, bpm, quant, pulse, usecs, .. } = self;
|
||||||
fill_bg(buf, Rect {
|
fill_bg(buf, area, Color::Rgb(20, 45, 5));
|
||||||
x, y, width, height: if width > 100 { 1 } else { 2 }
|
let dim = Style::default().dim();
|
||||||
}, Color::Rgb(20, 45, 5));
|
let not_dim = Style::default().not_dim();
|
||||||
let style = Style::default().not_dim();
|
let red = not_dim.red();
|
||||||
let mut area = Split::right([
|
let green = not_dim.green();
|
||||||
|
let yellow = not_dim.yellow();
|
||||||
|
Split::right([
|
||||||
|
|
||||||
// Play/Pause button
|
// Play/Pause button
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
|
|
@ -55,49 +55,37 @@ render!(TransportView |self, buf, area| {
|
||||||
|
|
||||||
// Record button/indicator
|
// Record button/indicator
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
"⏺ REC".blit(buf, x, y, Some(if self.record {
|
"⏺ REC".blit(buf, x, y, Some(if self.record { red } else { dim }))
|
||||||
Style::default().bold().red()
|
|
||||||
} else {
|
|
||||||
Style::default().bold().dim()
|
|
||||||
}))
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Overdub button/indicator
|
// Overdub button/indicator
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
"⏺ DUB".blit(buf, x, y, Some(if self.overdub {
|
"⏺ DUB".blit(buf, x, y, Some(if self.overdub { yellow } else { dim }))
|
||||||
Style::default().bold().yellow()
|
|
||||||
} else {
|
|
||||||
Style::default().bold().dim()
|
|
||||||
}))
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Monitor button/indicator
|
// Monitor button/indicator
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
"⏺ MON".blit(buf, x, y, Some(if self.monitor {
|
"⏺ MON".blit(buf, x, y, Some(if self.monitor { green } else { dim }))
|
||||||
Style::default().bold().green()
|
|
||||||
} else {
|
|
||||||
Style::default().bold().dim()
|
|
||||||
}))
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Beats per minute
|
// Beats per minute
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
"BPM".blit(buf, x, y, Some(style))?;
|
"BPM".blit(buf, x, y, Some(not_dim))?;
|
||||||
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(style.bold()))?;
|
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(not_dim.bold()))?;
|
||||||
Ok(Rect { x, y, width: 13, height: 1 })
|
Ok(Rect { x, y, width: 13, height: 1 })
|
||||||
},
|
},
|
||||||
|
|
||||||
// Quantization
|
// Quantization
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
"QUANT".blit(buf, x, y, Some(style))?;
|
"QUANT".blit(buf, x, y, Some(not_dim))?;
|
||||||
ppq_to_name(*quant).blit(buf, x + 6, y, Some(style.bold()))?;
|
ppq_to_name(*quant).blit(buf, x + 6, y, Some(not_dim.bold()))?;
|
||||||
Ok(Rect { x, y, width: 12, height: 1 })
|
Ok(Rect { x, y, width: 12, height: 1 })
|
||||||
},
|
},
|
||||||
|
|
||||||
// Clip launch sync
|
// Clip launch sync
|
||||||
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
|
||||||
"SYNC".blit(buf, x, y, Some(style))?;
|
"SYNC".blit(buf, x, y, Some(not_dim))?;
|
||||||
"4/4".blit(buf, x + 5, y, Some(style.bold()))?;
|
"4/4".blit(buf, x + 5, y, Some(not_dim.bold()))?;
|
||||||
Ok(Rect { x, y, width: 12, height: 1 })
|
Ok(Rect { x, y, width: 12, height: 1 })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -111,7 +99,5 @@ render!(TransportView |self, buf, area| {
|
||||||
timer.blit(buf, x + width - timer.len() as u16 - 1, y, Some(Style::default().not_dim()))
|
timer.blit(buf, x + width - timer.len() as u16 - 1, y, Some(Style::default().not_dim()))
|
||||||
}
|
}
|
||||||
|
|
||||||
]).render(buf, area)?;
|
]).render(buf, area)
|
||||||
area.height = 1;
|
|
||||||
Ok(area)
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue