mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
add clips with enter
This commit is contained in:
parent
156504b5ba
commit
efa35834de
3 changed files with 33 additions and 26 deletions
|
|
@ -185,7 +185,7 @@ pub fn main () -> Usually<()> {
|
|||
midi_buf: vec![vec![];65536],
|
||||
note_buf: vec![],
|
||||
compact: false,
|
||||
editing: true,
|
||||
editing: true.into(),
|
||||
color,
|
||||
perf,
|
||||
size,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ pub type ClipPool = Vec<Arc<RwLock<MidiClip>>>;
|
|||
pub trait HasClips {
|
||||
fn clips <'a> (&'a self) -> std::sync::RwLockReadGuard<'a, ClipPool>;
|
||||
fn clips_mut <'a> (&'a self) -> std::sync::RwLockWriteGuard<'a, ClipPool>;
|
||||
fn add_clip (&self) -> (usize, Arc<RwLock<MidiClip>>) {
|
||||
let clip = Arc::new(RwLock::new(MidiClip::new("Clip", true, 384, None, None)));
|
||||
self.clips_mut().push(clip.clone());
|
||||
(self.clips().len() - 1, clip)
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! has_clips {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -353,39 +353,29 @@ impl Arranger {
|
|||
let cells = Map::new(scenes, move|(_, scene, y1, y2), s| {
|
||||
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 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