fix note enter; align titles

This commit is contained in:
🪞👃🪞 2025-01-21 00:32:58 +01:00
parent 93462e7501
commit 81a74d79dc
7 changed files with 39 additions and 45 deletions

View file

@ -15,7 +15,7 @@
(@minus time/zoom :time-zoom-next)
(@z time/lock)
(@enter add :false)
(@shift-enter add :true)
(@del del :false)
(@shift-del del :true)
(@enter note/put)
(@shift-enter note/append)
(@del note/del)
(@shift-del note/del)

View file

@ -183,8 +183,9 @@ impl MidiViewer for MidiEditor {
fn set_clip (&mut self, p: Option<&Arc<RwLock<MidiClip>>>) { self.mode.set_clip(p) }
}
atom_command!(MidiEditCommand: |state: MidiEditor| {
("note/put" [_a: bool] Self::PutNote)
("note/del" [_a: bool] Self::PutNote)
("note/append" [] Self::AppendNote)
("note/put" [] Self::PutNote)
("note/del" [] Self::DelNote)
("note/pos" [a: usize] Self::SetNoteCursor(a.expect("no note cursor")))
("note/len" [a: usize] Self::SetNoteLength(a.expect("no note length")))
("time/pos" [a: usize] Self::SetTimeCursor(a.expect("no time cursor")))
@ -196,6 +197,7 @@ atom_command!(MidiEditCommand: |state: MidiEditor| {
// TODO: 1-9 seek markers that by default start every 8th of the clip
AppendNote,
PutNote,
DelNote,
SetNoteCursor(usize),
SetNoteLength(usize),
SetNoteScroll(usize),
@ -218,6 +220,7 @@ impl Command<MidiEditor> for MidiEditCommand {
use MidiEditCommand::*;
match self {
Show(clip) => { state.set_clip(clip.as_ref()); },
DelNote => {},
PutNote => { state.put_note(false); },
AppendNote => { state.put_note(true); },
SetTimeZoom(x) => { state.time_zoom().set(x); state.redraw(); },

View file

@ -18,7 +18,7 @@
(@shift-space clock toggle 0)
(@ctrl-a scene add)
(@ctrl-t track add)
(@tab edit)
(@tab edit :clip)
(@c color)}
{def :keys-mix

View file

@ -4,5 +4,5 @@
(@shift-space clock toggle 0)
(@ctrl-a scene add)
(@ctrl-t track add)
(@tab edit)
(@tab edit :clip)
(@c color)

View file

@ -7,7 +7,7 @@
(@right select :track-next :scene)
(@d select :track-next :scene)
(@q enqueue :clip)
(@q enqueue :track :scene)
(@c clip color :track :scene)
(@g clip get)
(@p clip put)

View file

@ -191,11 +191,11 @@ view!(TuiOut: |self: Tek| self.size.of(View(self, self.view)); {
":sampler" => self.view_sampler(self.is_editing(), &self.editor).boxed(),
":status" => self.view_editor().boxed(),
":toolbar" => self.view_clock().boxed(),
":tracks" => self.view_row(self.w(), 3, self.track_header(), self.track_cells()).boxed(),
":inputs" => self.view_row(self.w(), 3, self.input_header(), self.input_cells()).boxed(),
":outputs" => self.view_row(self.w(), 3, self.output_header(), self.output_cells()).boxed(),
":tracks" => self.view_row(self.w(), 2, self.track_header(), self.track_cells()).boxed(),
":inputs" => self.view_row(self.w(), 2, self.input_header(), self.input_cells()).boxed(),
":outputs" => self.view_row(self.w(), 2, self.output_header(), self.output_cells()).boxed(),
":scenes" => Outer(false, Style::default().fg(Tui::g(0))).enclose_bg(self.view_row(
self.w(), self.size.h().saturating_sub(12) as u16,
self.w(), self.size.h().saturating_sub(8) as u16,
self.scene_header(), self.clip_columns()
)).boxed()
});
@ -550,7 +550,7 @@ impl Tek {
let top = if s == 0 {
Some(Reset)
} else if neighbor {
None
Some(last_color.read().unwrap().light.rgb)
} else {
Some(last_color.read().unwrap().base.rgb)
};
@ -569,25 +569,23 @@ impl Tek {
"edit".into()
};
let label = move||{
let stop = self.fmtd_stop.clone();
let clip = scene.clips[t].clone();
Tui::fg(fg, Push::x(1, Tui::bold(true, clip
.map(|c|c.read().unwrap().name.clone())
.unwrap_or(stop))))
let icon = "";
let name = clip.map(|c|c.read().unwrap().name.clone());
Align::nw(Tui::fg(fg, Bsp::e(icon, Bsp::e(Tui::bold(true, name), " "))))
};
map_south(y1 as u16, h, Push::y(1, Fixed::y(h, Either::new(active,
Thunk::new(move||Bsp::a(
Fill::xy(Align::nw(button(tab, Tui::fg_bg(fg, bg.base.rgb, name.clone())))),
Fill::xy(Align::nw(button(tab, label()))),
&self.editor)),
Thunk::new(move||Bsp::a(
When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
Fill::xy(phat_sel_3(
phat_sel_3(
selected,
label(),
label(),
Fill::xy(label()),
Fill::xy(label()),
top, mid, low
))
)
)),
))))
@ -623,7 +621,7 @@ impl Tek {
fn input_header <'a> (&'a self) -> ThunkBox<'a, TuiOut> {
let fg = Tui::g(224);
let bg = Tui::g(64);
(move||Bsp::s(Fill::x(Align::w(self.button(" I ", format!(" midi ins ({})", self.midi_ins().len())))), self.midi_ins().get(0).map(|inp|Bsp::s(
(move||Bsp::s(Fill::x(Align::w(self.button(" I ", format!(" midi ins ({})", self.midi_ins().len())))), self.midi_ins().get(0).map(|inp|Bsp::s(
Fill::x(Tui::bold(true, Tui::fg_bg(fg, bg, Align::w(inp.name.clone())))),
inp.connect.get(0).map(|connect|Fill::x(Align::w(Tui::bold(false,
Tui::fg_bg(fg, bg, connect.info()))))),
@ -632,7 +630,7 @@ impl Tek {
fn output_header <'a> (&'a self) -> ThunkBox<'a, TuiOut> {
let fg = Tui::g(224);
let bg = Tui::g(64);
(move||Bsp::s(Fill::x(Align::w(self.button(" O ", format!(" midi outs ({}) ", self.midi_outs().len())))), self.midi_outs().get(0).map(|out|Bsp::s(
(move||Bsp::s(Fill::x(Align::w(self.button(" O ", format!(" midi outs ({}) ", self.midi_outs().len())))), self.midi_outs().get(0).map(|out|Bsp::s(
Fill::x(Tui::bold(true, Tui::fg_bg(fg, bg, Align::w(out.name.clone())))),
out.connect.get(0).map(|connect|Fill::x(Align::w(Tui::bold(false,
Tui::fg_bg(fg, bg, connect.info()))))),
@ -1003,27 +1001,24 @@ trait HasTracks: HasSelection + HasClock + HasJack + HasEditor + Send + Sync {
fn track_cells <'a> (&'a self) -> ThunkBox<'a, TuiOut> {
let iter = ||self.tracks_sizes(self.is_editing(), self.editor_w());
(move||Align::x(Map::new(iter, move|(_, track, x1, x2), i| {
let name = Push::x(1, &track.name);
let name = &track.name;
let color = track.color;
let fg = color.lightest.rgb;
let bg = color.base.rgb;
let active = self.selected().track() == Some(i + 1);
let bfg = if active { Rgb(255,255,255) } else { Rgb(0,0,0) };
let border = Style::default().fg(bfg).bg(bg);
Tui::bg(bg, map_east(x1 as u16, (x2 - x1) as u16,
Outer(false, border)
.enclose(Tui::fg_bg(fg, bg, Tui::bold(true, Fill::x(Align::x(name)))))
))
let content = Tui::fg_bg(fg, bg, Tui::bold(true, Fill::x(Align::nw(Bsp::e(" ", name)))));
Tui::bg(bg, map_east(x1 as u16, (x2 - x1) as u16, Outer(false, border).enclose(content)))
})).boxed()).into()
}
fn input_cells <'a> (&'a self) -> ThunkBox<'a, TuiOut> {
(move||Align::x(Map::new(||self.tracks_sizes(self.is_editing(), self.editor_w()), move|(_, track, x1, x2), i| {
let tracks = ||self.tracks_sizes(self.is_editing(), self.editor_w());
(move||Align::x(Map::new(tracks, move|(_, track, x1, x2), i| {
let w = (x2 - x1) as u16;
let color: ItemPalette = track.color;
map_east(x1 as u16, w, Fixed::x(w, Self::cell(color, Bsp::n(
Self::rec_mon(color.base.rgb, false, false),
phat_hi(color.base.rgb, color.dark.rgb)
))))
map_east(x1 as u16, w, Fixed::x(w, Self::cell(color,
Self::rec_mon(color.base.rgb, false, false))))
})).boxed()).into()
}
fn rec_mon (bg: Color, rec: bool, mon: bool) -> impl Content<TuiOut> {
@ -1036,13 +1031,11 @@ trait HasTracks: HasSelection + HasClock + HasJack + HasEditor + Send + Sync {
)
}
fn output_cells <'a> (&'a self) -> ThunkBox<'a, TuiOut> {
(move||Align::x(Map::new(||self.tracks_sizes(self.is_editing(), self.editor_w()), move|(_, track, x1, x2), i| {
let tracks = ||self.tracks_sizes(self.is_editing(), self.editor_w());
(move||Align::x(Map::new(tracks, move|(_, track, x1, x2), i| {
let w = (x2 - x1) as u16;
let color: ItemPalette = track.color;
map_east(x1 as u16, w, Fixed::x(w, Self::cell(color, Bsp::n(
Self::mute_solo(color.base.rgb, false, false),
phat_hi(color.dark.rgb, color.darker.rgb)
))))
map_east(x1 as u16, w, Fixed::x(w, Self::cell(color, Self::mute_solo(color.base.rgb, false, false))))
})).boxed()).into()
}
fn mute_solo (bg: Color, mute: bool, solo: bool) -> impl Content<TuiOut> {

View file

@ -1,5 +1,3 @@
(bsp/s (fixed/y 2 :toolbar)
(bsp/s (max/y 1 :toolbar)
(fill/x (align/c (bsp/w (fixed/x :pool-w :pool)
(bsp/n (fixed/y 3 :outputs)
(bsp/n (fixed/y 3 :inputs)
(bsp/n (fixed/y 3 :tracks) :scenes)))))))
(bsp/n :outputs (bsp/n :inputs (bsp/n :tracks :scenes)))))))