mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
implement deleting of tracks and scenes
This commit is contained in:
parent
0b71a57ead
commit
a0eef1f626
2 changed files with 47 additions and 50 deletions
|
|
@ -97,6 +97,26 @@ impl<E: Engine> Arranger<E> {
|
||||||
}
|
}
|
||||||
Ok(Some(true))
|
Ok(Some(true))
|
||||||
}
|
}
|
||||||
|
pub fn rename_selected (&mut self) {
|
||||||
|
let Arrangement { selected, ref name, ref tracks, ref scenes, .. } = self.arrangement;
|
||||||
|
todo!("rename selected");
|
||||||
|
//self.modal = match selected {
|
||||||
|
//ArrangementFocus::Mix => {
|
||||||
|
//Some(Box::new(ArrangerRenameModal::new(selected, &*name.read().unwrap())))
|
||||||
|
//},
|
||||||
|
//ArrangementFocus::Track(t) => {
|
||||||
|
//Some(Box::new(ArrangerRenameModal::new(selected, &*tracks[t].name.read().unwrap())))
|
||||||
|
//},
|
||||||
|
//ArrangementFocus::Scene(s) => {
|
||||||
|
//Some(Box::new(ArrangerRenameModal::new(selected, &*scenes[s].name.read().unwrap())))
|
||||||
|
//},
|
||||||
|
//ArrangementFocus::Clip(t, s) => if let Some(ref clip) = scenes[s].clips[t] {
|
||||||
|
//Some(Box::new(ArrangerRenameModal::new(selected, &clip.read().unwrap().name)))
|
||||||
|
//} else {
|
||||||
|
//None
|
||||||
|
//}
|
||||||
|
//};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// Focus layout of arranger app
|
/// Focus layout of arranger app
|
||||||
impl<E: Engine> FocusGrid<ArrangerFocus> for Arranger<E> {
|
impl<E: Engine> FocusGrid<ArrangerFocus> for Arranger<E> {
|
||||||
|
|
@ -260,7 +280,12 @@ impl<E: Engine> Arrangement<E> {
|
||||||
Ok(&mut self.tracks[index])
|
Ok(&mut self.tracks[index])
|
||||||
}
|
}
|
||||||
pub fn track_del (&mut self) {
|
pub fn track_del (&mut self) {
|
||||||
unimplemented!("Arranger::track_del");
|
if let Some(index) = self.selected.track() {
|
||||||
|
self.tracks.remove(index);
|
||||||
|
for scene in self.scenes.iter_mut() {
|
||||||
|
scene.clips.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn track_default_name (&self) -> String {
|
pub fn track_default_name (&self) -> String {
|
||||||
format!("Track {}", self.tracks.len() + 1)
|
format!("Track {}", self.tracks.len() + 1)
|
||||||
|
|
@ -299,7 +324,9 @@ impl<E: Engine> Arrangement<E> {
|
||||||
Ok(&mut self.scenes[index])
|
Ok(&mut self.scenes[index])
|
||||||
}
|
}
|
||||||
pub fn scene_del (&mut self) {
|
pub fn scene_del (&mut self) {
|
||||||
unimplemented!("Arranger::scene_del");
|
if let Some(index) = self.selected.scene() {
|
||||||
|
self.scenes.remove(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn scene_default_name (&self) -> String {
|
pub fn scene_default_name (&self) -> String {
|
||||||
format!("Scene {}", self.scenes.len() + 1)
|
format!("Scene {}", self.scenes.len() + 1)
|
||||||
|
|
|
||||||
|
|
@ -3,49 +3,21 @@ use crate::*;
|
||||||
impl Content for Arranger<Tui> {
|
impl Content for Arranger<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
Layers::new(move|add|{
|
Stack::down(move|add|{
|
||||||
add(&Stack::down(move|add|{
|
|
||||||
add(&self.transport)?;
|
add(&self.transport)?;
|
||||||
let arrangement = &self.arrangement as &dyn Widget<Engine = Tui>;
|
let arrangement = &self.arrangement as &dyn Widget<Engine = Tui>;
|
||||||
if let Some(direction) = self.show_sequencer {
|
if let Some(direction) = self.show_sequencer {
|
||||||
let editor = &self.editor as &dyn Widget<Engine = Tui>;
|
add(&arrangement.split(direction, 20,
|
||||||
add(&arrangement.split(direction, 20, self.phrases.clone()
|
self.phrases.clone().split(direction.ccw(), 20,
|
||||||
.split(direction.ccw(), 20, editor)
|
&self.editor as &dyn Widget<Engine = Tui>
|
||||||
.min_y(20)).fill_y())
|
).min_y(20)
|
||||||
|
).fill_y())
|
||||||
} else {
|
} else {
|
||||||
add(&self.arrangement)
|
add(&self.arrangement)
|
||||||
}
|
}
|
||||||
}))?;
|
|
||||||
//if let Some(ref modal) = self.modal {
|
|
||||||
//add(&Background(COLOR_BG1))?;
|
|
||||||
//add(&Foreground(COLOR_BG2))?;
|
|
||||||
////add(modal as &dyn Widget<Engine = Tui>)?;
|
|
||||||
//}
|
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Arranger<Tui> {
|
|
||||||
pub fn rename_selected (&mut self) {
|
|
||||||
let Arrangement { selected, ref name, ref tracks, ref scenes, .. } = self.arrangement;
|
|
||||||
//self.modal = match selected {
|
|
||||||
//ArrangementFocus::Mix => {
|
|
||||||
//Some(Box::new(ArrangerRenameModal::new(selected, &*name.read().unwrap())))
|
|
||||||
//},
|
|
||||||
//ArrangementFocus::Track(t) => {
|
|
||||||
//Some(Box::new(ArrangerRenameModal::new(selected, &*tracks[t].name.read().unwrap())))
|
|
||||||
//},
|
|
||||||
//ArrangementFocus::Scene(s) => {
|
|
||||||
//Some(Box::new(ArrangerRenameModal::new(selected, &*scenes[s].name.read().unwrap())))
|
|
||||||
//},
|
|
||||||
//ArrangementFocus::Clip(t, s) => if let Some(ref clip) = scenes[s].clips[t] {
|
|
||||||
//Some(Box::new(ArrangerRenameModal::new(selected, &clip.read().unwrap().name)))
|
|
||||||
//} else {
|
|
||||||
//None
|
|
||||||
//}
|
|
||||||
//};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Content for Arrangement<Tui> {
|
impl Content for Arrangement<Tui> {
|
||||||
type Engine = Tui;
|
type Engine = Tui;
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
|
|
@ -88,20 +60,17 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
||||||
let rows: &[(usize, usize)] = rows.as_ref();
|
let rows: &[(usize, usize)] = rows.as_ref();
|
||||||
let cols: &[(usize, usize)] = cols.as_ref();
|
let cols: &[(usize, usize)] = cols.as_ref();
|
||||||
|
|
||||||
|
// grid
|
||||||
add(&CustomWidget::new(|_|Ok(Some([0,0])), move|to: &mut TuiOutput|{
|
add(&CustomWidget::new(|_|Ok(Some([0,0])), move|to: &mut TuiOutput|{
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let style = Some(Style::default().fg(COLOR_SEPARATOR));
|
let style = Some(Style::default().fg(COLOR_SEPARATOR));
|
||||||
for (_, x) in cols.iter() {
|
for (_, x) in cols.iter() {
|
||||||
let x = offset + area.x() + *x as u16 - 1;
|
let x = offset + area.x() + *x as u16 - 1;
|
||||||
for y in area.y()..area.y2() {
|
for y in area.y()..area.y2() { to.blit(&"▎", x, y, style); }
|
||||||
to.blit(&"▎", x, y, style);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (_, y) in rows.iter() {
|
for (_, y) in rows.iter() {
|
||||||
let y = area.y() + (*y / PPQ) as u16 + 1;
|
let y = area.y() + (*y / PPQ) as u16 + 1;
|
||||||
if y >= to.buffer.area.height {
|
if y >= to.buffer.area.height { break }
|
||||||
break
|
|
||||||
}
|
|
||||||
for x in area.x()..area.x2().saturating_sub(2) {
|
for x in area.x()..area.x2().saturating_sub(2) {
|
||||||
if x < to.buffer.area.x && y < to.buffer.area.y {
|
if x < to.buffer.area.x && y < to.buffer.area.y {
|
||||||
let cell = to.buffer.get_mut(x, y);
|
let cell = to.buffer.get_mut(x, y);
|
||||||
|
|
@ -113,6 +82,7 @@ impl<'a> Content for VerticalArranger<'a, Tui> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}))?;
|
}))?;
|
||||||
|
|
||||||
|
// cursor
|
||||||
add(&CustomWidget::new(|_|Ok(Some([0,0])), move|to: &mut TuiOutput|{
|
add(&CustomWidget::new(|_|Ok(Some([0,0])), move|to: &mut TuiOutput|{
|
||||||
let area = to.area();
|
let area = to.area();
|
||||||
let focused = state.focused;
|
let focused = state.focused;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue