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

View file

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

View file

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

View file

@ -7,7 +7,7 @@
(@right select :track-next :scene) (@right select :track-next :scene)
(@d select :track-next :scene) (@d select :track-next :scene)
(@q enqueue :clip) (@q enqueue :track :scene)
(@c clip color :track :scene) (@c clip color :track :scene)
(@g clip get) (@g clip get)
(@p clip put) (@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(), ":sampler" => self.view_sampler(self.is_editing(), &self.editor).boxed(),
":status" => self.view_editor().boxed(), ":status" => self.view_editor().boxed(),
":toolbar" => self.view_clock().boxed(), ":toolbar" => self.view_clock().boxed(),
":tracks" => self.view_row(self.w(), 3, self.track_header(), self.track_cells()).boxed(), ":tracks" => self.view_row(self.w(), 2, self.track_header(), self.track_cells()).boxed(),
":inputs" => self.view_row(self.w(), 3, self.input_header(), self.input_cells()).boxed(), ":inputs" => self.view_row(self.w(), 2, self.input_header(), self.input_cells()).boxed(),
":outputs" => self.view_row(self.w(), 3, self.output_header(), self.output_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( ":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() self.scene_header(), self.clip_columns()
)).boxed() )).boxed()
}); });
@ -550,7 +550,7 @@ impl Tek {
let top = if s == 0 { let top = if s == 0 {
Some(Reset) Some(Reset)
} else if neighbor { } else if neighbor {
None Some(last_color.read().unwrap().light.rgb)
} else { } else {
Some(last_color.read().unwrap().base.rgb) Some(last_color.read().unwrap().base.rgb)
}; };
@ -569,25 +569,23 @@ impl Tek {
"edit".into() "edit".into()
}; };
let label = move||{ let label = move||{
let stop = self.fmtd_stop.clone();
let clip = scene.clips[t].clone(); let clip = scene.clips[t].clone();
Tui::fg(fg, Push::x(1, Tui::bold(true, clip let icon = "";
.map(|c|c.read().unwrap().name.clone()) let name = clip.map(|c|c.read().unwrap().name.clone());
.unwrap_or(stop)))) 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, map_south(y1 as u16, h, Push::y(1, Fixed::y(h, Either::new(active,
Thunk::new(move||Bsp::a( 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)), &self.editor)),
Thunk::new(move||Bsp::a( Thunk::new(move||Bsp::a(
When::new(selected, Fill::y(Align::n(button(tab, "edit")))), When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
Fill::xy(phat_sel_3( phat_sel_3(
selected, selected,
label(), Fill::xy(label()),
label(), Fill::xy(label()),
top, mid, low top, mid, low
)) )
)), )),
)))) ))))
@ -1003,27 +1001,24 @@ trait HasTracks: HasSelection + HasClock + HasJack + HasEditor + Send + Sync {
fn track_cells <'a> (&'a self) -> ThunkBox<'a, TuiOut> { fn track_cells <'a> (&'a self) -> ThunkBox<'a, TuiOut> {
let iter = ||self.tracks_sizes(self.is_editing(), self.editor_w()); let iter = ||self.tracks_sizes(self.is_editing(), self.editor_w());
(move||Align::x(Map::new(iter, move|(_, track, x1, x2), i| { (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 color = track.color;
let fg = color.lightest.rgb; let fg = color.lightest.rgb;
let bg = color.base.rgb; let bg = color.base.rgb;
let active = self.selected().track() == Some(i + 1); let active = self.selected().track() == Some(i + 1);
let bfg = if active { Rgb(255,255,255) } else { Rgb(0,0,0) }; let bfg = if active { Rgb(255,255,255) } else { Rgb(0,0,0) };
let border = Style::default().fg(bfg).bg(bg); let border = Style::default().fg(bfg).bg(bg);
Tui::bg(bg, map_east(x1 as u16, (x2 - x1) as u16, let content = Tui::fg_bg(fg, bg, Tui::bold(true, Fill::x(Align::nw(Bsp::e(" ", name)))));
Outer(false, border) Tui::bg(bg, map_east(x1 as u16, (x2 - x1) as u16, Outer(false, border).enclose(content)))
.enclose(Tui::fg_bg(fg, bg, Tui::bold(true, Fill::x(Align::x(name)))))
))
})).boxed()).into() })).boxed()).into()
} }
fn input_cells <'a> (&'a self) -> ThunkBox<'a, TuiOut> { 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 w = (x2 - x1) as u16;
let color: ItemPalette = track.color; let color: ItemPalette = track.color;
map_east(x1 as u16, w, Fixed::x(w, Self::cell(color, Bsp::n( map_east(x1 as u16, w, Fixed::x(w, Self::cell(color,
Self::rec_mon(color.base.rgb, false, false), Self::rec_mon(color.base.rgb, false, false))))
phat_hi(color.base.rgb, color.dark.rgb)
))))
})).boxed()).into() })).boxed()).into()
} }
fn rec_mon (bg: Color, rec: bool, mon: bool) -> impl Content<TuiOut> { 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> { 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 w = (x2 - x1) as u16;
let color: ItemPalette = track.color; let color: ItemPalette = track.color;
map_east(x1 as u16, w, Fixed::x(w, Self::cell(color, Bsp::n( map_east(x1 as u16, w, Fixed::x(w, Self::cell(color, Self::mute_solo(color.base.rgb, false, false))))
Self::mute_solo(color.base.rgb, false, false),
phat_hi(color.dark.rgb, color.darker.rgb)
))))
})).boxed()).into() })).boxed()).into()
} }
fn mute_solo (bg: Color, mute: bool, solo: bool) -> impl Content<TuiOut> { 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) (fill/x (align/c (bsp/w (fixed/x :pool-w :pool)
(bsp/n (fixed/y 3 :outputs) (bsp/n :outputs (bsp/n :inputs (bsp/n :tracks :scenes)))))))
(bsp/n (fixed/y 3 :inputs)
(bsp/n (fixed/y 3 :tracks) :scenes)))))))