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
|
|
@ -1,7 +1,7 @@
|
|||
(@c color)
|
||||
(@q launch)
|
||||
(@t select :select-track-header)
|
||||
(@tab edit :clip)
|
||||
(@tab edit :clip-selected)
|
||||
(@shift-I input add)
|
||||
(@shift-O output add)
|
||||
(@shift-S scene add)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ pub struct App {
|
|||
pub size: Measure<TuiOut>,
|
||||
/// Performance counter
|
||||
pub perf: PerfModel,
|
||||
|
||||
// View and input definition
|
||||
pub config: Configuration,
|
||||
/// Contains all recently created clips.
|
||||
pub pool: Pool,
|
||||
/// Contains the currently edited musical arrangement
|
||||
pub project: Arrangement,
|
||||
/// Undo history
|
||||
|
|
@ -21,7 +22,6 @@ pub struct App {
|
|||
pub dialog: Option<Dialog>,
|
||||
/// Contains the currently edited MIDI clip
|
||||
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
|
||||
|
|
|
|||
|
|
@ -168,11 +168,11 @@ impl Arrangement {
|
|||
mins: &[PortConnect],
|
||||
mouts: &[PortConnect],
|
||||
) -> Usually<(usize, &mut Track)> {
|
||||
self.track_last += 1;
|
||||
let name: Arc<str> = name.map_or_else(
|
||||
||format!("Track{:02}", self.track_last).into(),
|
||||
||format!("t{:02}", self.track_last).into(),
|
||||
|x|x.to_string().into()
|
||||
);
|
||||
self.track_last += 1;
|
||||
let mut track = Track {
|
||||
width: (name.len() + 2).max(12),
|
||||
color: color.unwrap_or_else(ItemTheme::random),
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub trait HasScenes: Has<Vec<Scene>> + Send + Sync {
|
|||
}
|
||||
/// Generate the default name for a new scene
|
||||
fn scene_default_name (&self) -> Arc<str> {
|
||||
format!("Sc{:3>}", self.scenes().len() + 1).into()
|
||||
format!("s{:3>}", self.scenes().len() + 1).into()
|
||||
}
|
||||
fn scene_longest_name (&self) -> usize {
|
||||
self.scenes().iter().map(|s|s.name.len()).fold(0, usize::max)
|
||||
|
|
|
|||
|
|
@ -207,8 +207,12 @@ pub trait TracksView: HasSize<TuiOut> + HasTrackScroll + HasSelection + HasMidiI
|
|||
.tracks_with_sizes(&self.selection(), None)
|
||||
.skip(self.track_scroll())
|
||||
{
|
||||
(add)(&Fixed::x(track.width as u16,
|
||||
Tui::bg(track.color.base.rgb, Align::nw(Tui::fg(
|
||||
add(&Fixed::x(track.width as u16,
|
||||
Tui::bg(if self.selection().track() == Some(index) {
|
||||
track.color.light.rgb
|
||||
} else {
|
||||
track.color.base.rgb
|
||||
}, Align::nw(Tui::fg(
|
||||
Rgb(255, 255, 255), Tui::bold(true,
|
||||
format!("{}", track.name)))))));
|
||||
}
|
||||
|
|
@ -424,18 +428,23 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync {
|
|||
(None, ItemTheme::G[32])
|
||||
};
|
||||
let fg = theme.lightest.rgb;
|
||||
let mut outline = theme.base.rgb;
|
||||
let bg = if self.selection().track() == Some(track_index)
|
||||
&& self.selection().scene() == Some(scene_index)
|
||||
{
|
||||
outline = theme.lightest.rgb;
|
||||
theme.light.rgb
|
||||
} else if self.selection().track() == Some(track_index)
|
||||
|| self.selection().scene() == Some(scene_index)
|
||||
{
|
||||
outline = theme.darkest.rgb;
|
||||
theme.base.rgb
|
||||
} else {
|
||||
theme.dark.rgb
|
||||
};
|
||||
cell(&Fixed::xy(track.width as u16, 2, Tui::fg_bg(fg, bg, Align::nw(name.unwrap_or(" ---- ".into())))));
|
||||
cell(&Fixed::xy(track.width as u16, 2, Bsp::b(
|
||||
Fill::xy(Outer(true, Style::default().fg(outline))),
|
||||
Fill::xy(Align::nw(Tui::fg_bg(fg, bg, Align::nw(name.unwrap_or(" ---- ".into()))))))));
|
||||
//let (name, theme) = if let Some(clip) = &scene.clips.get(track_index).flatten() {
|
||||
//let clip = clip.read().unwrap();
|
||||
//(Some(clip.name.clone()), clip.color)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue