mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
add clips with enter
This commit is contained in:
parent
156504b5ba
commit
efa35834de
3 changed files with 33 additions and 26 deletions
|
|
@ -21,7 +21,7 @@ pub struct Arranger {
|
|||
pub note_buf: Vec<u8>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub editor: MidiEditor,
|
||||
pub editing: bool,
|
||||
pub editing: AtomicBool,
|
||||
pub perf: PerfModel,
|
||||
pub compact: bool,
|
||||
}
|
||||
|
|
@ -347,45 +347,35 @@ impl Arranger {
|
|||
let selected_track = self.selected.track();
|
||||
let selected_scene = self.selected.scene();
|
||||
(move||Fill::y(Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
|
||||
let w = (x2 - x1) as u16;
|
||||
let w = (x2 - x1) as u16;
|
||||
let color: ItemPalette = track.color().dark.into();
|
||||
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
|
||||
let cells = Map::new(scenes, move|(_, scene, y1, y2), s| {
|
||||
let h = (y2 - y1) as u16;
|
||||
let h = (y2 - y1) as u16;
|
||||
let color = scene.color();
|
||||
let name = if let Some(c) = &scene.clips[t] {
|
||||
c.read().unwrap().name.to_string()
|
||||
let (name, fg, bg) = if let Some(c) = &scene.clips[t] {
|
||||
let c = c.read().unwrap();
|
||||
(c.name.to_string(), c.color.lightest.rgb, c.color.base.rgb)
|
||||
} else {
|
||||
"⏹ ".to_string()
|
||||
("⏹ ".to_string(), TuiTheme::g(64), TuiTheme::g(32))
|
||||
};
|
||||
let last = last_color.read().unwrap().clone();
|
||||
//let cell = phat_sel_3(
|
||||
//selected_track == Some(i) && selected_scene == Some(j),
|
||||
//Tui::fg(TuiTheme::g(64), Push::x(1, name)),
|
||||
//Tui::fg(TuiTheme::g(64), Push::x(1, name)),
|
||||
//if selected_track == Some(i) && selected_scene.map(|s|s+1) == Some(j) {
|
||||
//None
|
||||
//} else {
|
||||
//Some(TuiTheme::g(32).into())
|
||||
//},
|
||||
//TuiTheme::g(32).into(),
|
||||
//TuiTheme::g(32).into(),
|
||||
//);
|
||||
let last = last_color.read().unwrap().clone();
|
||||
let active = editing && selected_scene == Some(s) && selected_track == Some(t);
|
||||
let editor = Thunk::new(||&self.editor);
|
||||
let cell = Thunk::new(move||phat_sel_3(
|
||||
selected_track == Some(t) && selected_scene == Some(s),
|
||||
Tui::fg(TuiTheme::g(64), Push::x(1, Tui::bold(true, name.to_string()))),
|
||||
Tui::fg(TuiTheme::g(64), Push::x(1, Tui::bold(true, name.to_string()))),
|
||||
Tui::fg(fg, Push::x(1, Tui::bold(true, name.to_string()))),
|
||||
Tui::fg(fg, Push::x(1, Tui::bold(true, name.to_string()))),
|
||||
if selected_track == Some(t) && selected_scene.map(|s|s+1) == Some(s) {
|
||||
None
|
||||
} else {
|
||||
Some(TuiTheme::g(32).into())
|
||||
Some(bg.into())
|
||||
},
|
||||
TuiTheme::g(32).into(),
|
||||
TuiTheme::g(32).into(),
|
||||
bg.into(),
|
||||
bg.into(),
|
||||
));
|
||||
let cell = Either(active, editor, cell);
|
||||
*last_color.write().unwrap() = bg.into();
|
||||
map_south(
|
||||
y1 as u16,
|
||||
h + 1,
|
||||
|
|
@ -738,7 +728,7 @@ fn clip_keymap (state: &Arranger, input: &Event, t: usize, s: usize) -> Option<A
|
|||
|
||||
kpat!(Enter) => if state.scenes[s].clips[t].is_none() {
|
||||
// FIXME: get this clip from the pool (autoregister via intmut)
|
||||
let clip = Arc::new(RwLock::new(MidiClip::default()));
|
||||
let (_, clip) = state.add_clip();
|
||||
Cmd::Clip(Clip::Put(t, s, Some(clip)))
|
||||
} else {
|
||||
return None
|
||||
|
|
@ -987,3 +977,15 @@ command!(|self: ArrangerClipCommand, state: Arranger|match self {
|
|||
//Fill::xy(ArrangerVClips::new(self, 1)),
|
||||
//Fill::x(ArrangerVOuts::from(self)))))
|
||||
|
||||
//let cell = phat_sel_3(
|
||||
//selected_track == Some(i) && selected_scene == Some(j),
|
||||
//Tui::fg(TuiTheme::g(64), Push::x(1, name)),
|
||||
//Tui::fg(TuiTheme::g(64), Push::x(1, name)),
|
||||
//if selected_track == Some(i) && selected_scene.map(|s|s+1) == Some(j) {
|
||||
//None
|
||||
//} else {
|
||||
//Some(TuiTheme::g(32).into())
|
||||
//},
|
||||
//TuiTheme::g(32).into(),
|
||||
//TuiTheme::g(32).into(),
|
||||
//);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue