constrain tracks from left side

This commit is contained in:
🪞👃🪞 2025-01-27 00:07:56 +01:00
parent e2023bdf53
commit 3502070613
5 changed files with 22 additions and 22 deletions

View file

@ -1,4 +1,5 @@
use crate::*;
use Color::*;
/// A clip, rendered as a horizontal piano roll.
pub struct PianoHorizontal {
pub clip: Option<Arc<RwLock<MidiClip>>>,
@ -82,7 +83,7 @@ impl PianoHorizontal {
}
/// Draw the piano roll background using full blocks on note on and half blocks on legato: █▄ █▄ █▄
fn draw_fg (buf: &mut BigBuffer, clip: &MidiClip, zoom: usize) {
let style = Style::default().fg(clip.color.base.rgb);//.bg(Color::Rgb(0, 0, 0));
let style = Style::default().fg(clip.color.base.rgb);//.bg(Rgb(0, 0, 0));
let mut notes_on = [false;128];
for (x, time_start) in (0..clip.length).step_by(zoom).enumerate() {
for (_y, note) in (0..=127).rev().enumerate() {
@ -182,9 +183,9 @@ impl PianoHorizontal {
let note_lo = state.note_lo().get();
let note_hi = state.note_hi();
let note_pos = state.note_pos();
let key_style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0)));
let off_style = Some(Style::default().fg(Tui::g(160)));
let on_style = Some(Style::default().fg(Tui::g(255)).bg(color.base.rgb).bold());
let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0)));
let off_style = Some(Style::default().fg(Tui::g(255)));
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.rgb).bold());
Fill::y(Fixed::x(self.keys_width, ThunkRender::new(move|to: &mut TuiOut|{
let [x, y0, _w, _h] = to.area().xywh();
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {

View file

@ -1,9 +1,10 @@
use crate::*;
impl Tek {
pub fn view_tracks (&self) -> impl Content<TuiOut> + use<'_> {
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
let data = (self.selected.track().unwrap_or(0), self.tracks().len());
self.fmtd.write().unwrap().trks.update(Some(data), rewrite!(buf, "({}/{})", data.0, data.1));
self.row(self.w(), 1, Align::w(Bsp::e(
self.fmtd.write().unwrap().trks.update(Some(data), rewrite!(buf, "{}/{}", data.0, data.1));
self.row(w, 1, Align::w(Bsp::e(
self.button3(" t", "track", self.fmtd.read().unwrap().trks.view.clone()),
self.button2(" T", "add track"),
)), self.per_track(|t, track|{
@ -17,8 +18,8 @@ impl Tek {
}))
}
pub fn view_scenes (&self) -> impl Content<TuiOut> + use<'_> {
let w = self.size.w() as u16;
let h = self.size.h() as u16;
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
let h = (self.size.h() as u16).saturating_sub(self.h_inputs() + self.h_outputs() + 1);
let editing = self.is_editing();
let selected_track = self.selected().track();
let selected_scene = self.selected().scene();

View file

@ -35,7 +35,8 @@ impl Tek {
)
}
fn view_clips_into (&self) -> impl Content<TuiOut> + use<'_> {
self.row_top(self.w(), 2,
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
self.row_top(w, 2,
Bsp::s(Align::e("Input:"), Align::e("Into:")),
self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s(
OctaveVertical::default(),

View file

@ -1,6 +1,7 @@
use crate::*;
impl Tek {
pub fn view_outputs (&self) -> impl Content<TuiOut> + use<'_> {
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
let fg = Tui::g(224);
Align::n(Bsp::s(
Bsp::s(
@ -8,7 +9,7 @@ impl Tek {
self.view_clips_from(),
),
Bsp::s(
self.row_top(self.w(), 1,
self.row_top(w, 1,
Fill::x(Align::w(Bsp::e(
self.button3(" o", "midi outs", format!("{}", self.midi_outs.len())),
self.button2(" O", "add midi out"),
@ -31,16 +32,12 @@ 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(
OctaveVertical::default(),
" ------ "
))));
self.row_top(self.w(), 2, heading, content)
}
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
self.row_top(w, 2, Align::e("From:"),
self.per_track_top(|_, _|Tui::bg(Reset,
Align::c(Bsp::s(" ------ ", OctaveVertical::default(),))))) }
fn view_clips_next (&self) -> impl Content<TuiOut> + use<'_> {
let heading = Align::e("Next:");
let content = self.per_track_top(|_, _|Tui::bg(Reset, " ----- "));
self.row_top(self.w(), 1, heading, content)
}
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
self.row_top(w, 1, Align::e("Next:"),
self.per_track_top(|_, _|Tui::bg(Reset, " ------ "))) }
}

View file

@ -1,5 +1,5 @@
(bsp/n
(fixed/y 1 :toolbar)
(fixed/y 2 :toolbar)
(fill/xy (align/c (bsp/a (fill/xy (align/e :pool))
(bsp/a
(fill/xy (align/n (bsp/s :tracks :inputs)))