mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
arranger: spawning clips once again!1
This commit is contained in:
parent
b663c53b0a
commit
48603e4812
6 changed files with 41 additions and 18 deletions
|
|
@ -18,6 +18,20 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
|
|||
}));
|
||||
|
||||
#[tengri_proc::command(App)] impl AppCommand {
|
||||
fn edit (app: &mut App) -> Perhaps<Self> {
|
||||
let selection = app.selection().clone();
|
||||
Ok(match selection {
|
||||
Selection::TrackClip { track, scene } => {
|
||||
let clip = &mut app.scenes_mut()[scene].clips[track];
|
||||
if clip.is_none() {
|
||||
*clip = Some(Default::default());
|
||||
}
|
||||
app.editor = clip.as_ref().map(|c|c.into());
|
||||
None
|
||||
}
|
||||
_ => None
|
||||
})
|
||||
}
|
||||
fn dialog (app: &mut App, dialog: Option<Dialog>) -> Perhaps<Self> {
|
||||
app.toggle_dialog(dialog);
|
||||
Ok(None)
|
||||
|
|
|
|||
|
|
@ -3,25 +3,25 @@ use crate::*;
|
|||
#[derive(Default, Debug)]
|
||||
pub struct App {
|
||||
/// Must not be dropped for the duration of the process
|
||||
pub jack: Jack,
|
||||
pub jack: Jack,
|
||||
/// Port handles
|
||||
pub ports: std::collections::BTreeMap<u32, Port<Unowned>>,
|
||||
/// Display size
|
||||
pub size: Measure<TuiOut>,
|
||||
/// Performance counter
|
||||
pub perf: PerfModel,
|
||||
|
||||
// View and input definition
|
||||
pub config: Configuration,
|
||||
pub config: Configuration,
|
||||
/// Contains all recently created clips.
|
||||
pub pool: Pool,
|
||||
/// Contains the currently edited musical arrangement
|
||||
pub project: Arrangement,
|
||||
/// Undo history
|
||||
pub history: Vec<AppCommand>,
|
||||
// Dialog overlay
|
||||
pub dialog: Option<Dialog>,
|
||||
pub dialog: Option<Dialog>,
|
||||
/// Contains the currently edited MIDI clip
|
||||
pub editor: Option<MidiEditor>,
|
||||
|
||||
pub editor: Option<MidiEditor>,
|
||||
// Cache of formatted strings
|
||||
pub view_cache: Arc<RwLock<ViewCache>>,
|
||||
/// Base color.
|
||||
|
|
@ -29,6 +29,7 @@ pub struct App {
|
|||
}
|
||||
|
||||
has!(Jack: |self: App|self.jack);
|
||||
has!(Pool: |self: App|self.pool);
|
||||
has!(Clock: |self: App|self.project.clock);
|
||||
has!(Selection: |self: App|self.project.selection);
|
||||
has!(Vec<JackMidiIn>: |self: App|self.project.midi_ins);
|
||||
|
|
@ -39,16 +40,15 @@ has!(Measure<TuiOut>: |self: App|self.size);
|
|||
maybe_has!(Track: |self: App|
|
||||
{ MaybeHas::<Track>::get(&self.project) };
|
||||
{ MaybeHas::<Track>::get_mut(&mut self.project) });
|
||||
impl HasTrackScroll for App {
|
||||
fn track_scroll (&self) -> usize { self.project.track_scroll() }
|
||||
}
|
||||
maybe_has!(Scene: |self: App|
|
||||
{ MaybeHas::<Scene>::get(&self.project) };
|
||||
{ MaybeHas::<Scene>::get_mut(&mut self.project) });
|
||||
impl HasSceneScroll for App {
|
||||
fn scene_scroll (&self) -> usize { self.project.scene_scroll() }
|
||||
}
|
||||
impl HasTrackScroll for App {
|
||||
fn track_scroll (&self) -> usize { self.project.track_scroll() }
|
||||
}
|
||||
|
||||
has_clips!(|self: App|self.project.pool.clips);
|
||||
has_editor!(|self: App|{
|
||||
editor = self.editor;
|
||||
|
|
@ -312,7 +312,7 @@ impl App {
|
|||
fn select_track_prev (&self) -> Selection {
|
||||
self.selection().track_prev()
|
||||
}
|
||||
fn clip_selection (&self) -> Option<Arc<RwLock<MidiClip>>> {
|
||||
fn clip_selected (&self) -> Option<Arc<RwLock<MidiClip>>> {
|
||||
match self.selection() {
|
||||
Selection::TrackClip { track, scene } => self.scenes()[*scene].clips[*track].clone(),
|
||||
_ => None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue