mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
make the tiny pianos a component
This commit is contained in:
parent
414b5e1580
commit
e2023bdf53
5 changed files with 44 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ mod midi_pool; pub use midi_pool::*;
|
|||
mod midi_range; pub use midi_range::*;
|
||||
mod midi_view; pub use midi_view::*;
|
||||
mod piano_h; pub use self::piano_h::*;
|
||||
mod piano_v; pub use self::piano_v::*;
|
||||
|
||||
pub(crate) use ::tek_time::*;
|
||||
pub(crate) use ::tek_jack::{*, jack::*};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ pub struct PianoHorizontal {
|
|||
impl PianoHorizontal {
|
||||
pub fn new (clip: Option<&Arc<RwLock<MidiClip>>>) -> Self {
|
||||
let size = Measure::new();
|
||||
let mut range = MidiRangeModel::from((24, true));
|
||||
let mut range = MidiRangeModel::from((12, true));
|
||||
range.time_axis = size.x.clone();
|
||||
range.note_axis = size.y.clone();
|
||||
let piano = Self {
|
||||
|
|
|
|||
34
midi/src/piano_v.rs
Normal file
34
midi/src/piano_v.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use crate::*;
|
||||
use Color::*;
|
||||
pub struct OctaveVertical {
|
||||
on: [bool; 12],
|
||||
colors: [Color; 3]
|
||||
}
|
||||
impl Default for OctaveVertical {
|
||||
fn default () -> Self {
|
||||
Self {
|
||||
on: [false; 12],
|
||||
colors: [Rgb(255,255,255), Rgb(0,0,0), Rgb(255,0,0)]
|
||||
}
|
||||
}
|
||||
}
|
||||
impl OctaveVertical {
|
||||
fn color (&self, pitch: usize) -> Color {
|
||||
let pitch = pitch % 12;
|
||||
self.colors[if self.on[pitch] { 2 } else {
|
||||
match pitch { 0 | 2 | 4 | 5 | 6 | 8 | 10 => 0, _ => 1 }
|
||||
}]
|
||||
}
|
||||
}
|
||||
impl Content<TuiOut> for OctaveVertical {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
row!(
|
||||
Tui::fg_bg(self.color(0), self.color(1), "▙"),
|
||||
Tui::fg_bg(self.color(2), self.color(3), "▙"),
|
||||
Tui::fg_bg(self.color(4), self.color(5), "▌"),
|
||||
Tui::fg_bg(self.color(6), self.color(7), "▟"),
|
||||
Tui::fg_bg(self.color(8), self.color(9), "▟"),
|
||||
Tui::fg_bg(self.color(10), self.color(11), "▟"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,9 @@ impl Tek {
|
|||
fn view_clips_into (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
self.row_top(self.w(), 2,
|
||||
Bsp::s(Align::e("Input:"), Align::e("Into:")),
|
||||
self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s("▙▙█▙▙▙█", " ----- ")))))
|
||||
self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s(
|
||||
OctaveVertical::default(),
|
||||
" ------ "
|
||||
)))))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@ impl Tek {
|
|||
}
|
||||
fn view_clips_from (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
let heading = Align::e("From:");
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s("▙▙█▙▙▙█", " ----- "))));
|
||||
let content = self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s(
|
||||
OctaveVertical::default(),
|
||||
" ------ "
|
||||
))));
|
||||
self.row_top(self.w(), 2, heading, content)
|
||||
}
|
||||
fn view_clips_next (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue