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],
|
midi_buf: vec![vec![];65536],
|
||||||
note_buf: vec![],
|
note_buf: vec![],
|
||||||
compact: false,
|
compact: false,
|
||||||
editing: true,
|
editing: true.into(),
|
||||||
color,
|
color,
|
||||||
perf,
|
perf,
|
||||||
size,
|
size,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ pub type ClipPool = Vec<Arc<RwLock<MidiClip>>>;
|
||||||
pub trait HasClips {
|
pub trait HasClips {
|
||||||
fn clips <'a> (&'a self) -> std::sync::RwLockReadGuard<'a, ClipPool>;
|
fn clips <'a> (&'a self) -> std::sync::RwLockReadGuard<'a, ClipPool>;
|
||||||
fn clips_mut <'a> (&'a self) -> std::sync::RwLockWriteGuard<'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 {
|
#[macro_export] macro_rules! has_clips {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct Arranger {
|
||||||
pub note_buf: Vec<u8>,
|
pub note_buf: Vec<u8>,
|
||||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||||
pub editor: MidiEditor,
|
pub editor: MidiEditor,
|
||||||
pub editing: bool,
|
pub editing: AtomicBool,
|
||||||
pub perf: PerfModel,
|
pub perf: PerfModel,
|
||||||
pub compact: bool,
|
pub compact: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -347,45 +347,35 @@ impl Arranger {
|
||||||
let selected_track = self.selected.track();
|
let selected_track = self.selected.track();
|
||||||
let selected_scene = self.selected.scene();
|
let selected_scene = self.selected.scene();
|
||||||
(move||Fill::y(Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
|
(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 color: ItemPalette = track.color().dark.into();
|
||||||
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
|
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 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 color = scene.color();
|
||||||
let name = if let Some(c) = &scene.clips[t] {
|
let (name, fg, bg) = if let Some(c) = &scene.clips[t] {
|
||||||
c.read().unwrap().name.to_string()
|
let c = c.read().unwrap();
|
||||||
|
(c.name.to_string(), c.color.lightest.rgb, c.color.base.rgb)
|
||||||
} else {
|
} else {
|
||||||
"⏹ ".to_string()
|
("⏹ ".to_string(), TuiTheme::g(64), TuiTheme::g(32))
|
||||||
};
|
};
|
||||||
let last = last_color.read().unwrap().clone();
|
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 active = editing && selected_scene == Some(s) && selected_track == Some(t);
|
||||||
let editor = Thunk::new(||&self.editor);
|
let editor = Thunk::new(||&self.editor);
|
||||||
let cell = Thunk::new(move||phat_sel_3(
|
let cell = Thunk::new(move||phat_sel_3(
|
||||||
selected_track == Some(t) && selected_scene == Some(s),
|
selected_track == Some(t) && selected_scene == Some(s),
|
||||||
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(TuiTheme::g(64), 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) {
|
if selected_track == Some(t) && selected_scene.map(|s|s+1) == Some(s) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(TuiTheme::g(32).into())
|
Some(bg.into())
|
||||||
},
|
},
|
||||||
TuiTheme::g(32).into(),
|
bg.into(),
|
||||||
TuiTheme::g(32).into(),
|
bg.into(),
|
||||||
));
|
));
|
||||||
let cell = Either(active, editor, cell);
|
let cell = Either(active, editor, cell);
|
||||||
|
*last_color.write().unwrap() = bg.into();
|
||||||
map_south(
|
map_south(
|
||||||
y1 as u16,
|
y1 as u16,
|
||||||
h + 1,
|
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() {
|
kpat!(Enter) => if state.scenes[s].clips[t].is_none() {
|
||||||
// FIXME: get this clip from the pool (autoregister via intmut)
|
// 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)))
|
Cmd::Clip(Clip::Put(t, s, Some(clip)))
|
||||||
} else {
|
} else {
|
||||||
return None
|
return None
|
||||||
|
|
@ -987,3 +977,15 @@ command!(|self: ArrangerClipCommand, state: Arranger|match self {
|
||||||
//Fill::xy(ArrangerVClips::new(self, 1)),
|
//Fill::xy(ArrangerVClips::new(self, 1)),
|
||||||
//Fill::x(ArrangerVOuts::from(self)))))
|
//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