refactor sampler, flatten arranger

This commit is contained in:
🪞👃🪞 2025-04-24 19:33:22 +03:00
parent a9d22bd26f
commit 9f70441627
28 changed files with 1816 additions and 1836 deletions

View file

@ -14,6 +14,7 @@ view!(TuiOut: |self: Tek| self.size.of(View(self, self.view)); {
.boxed(),
":sample" => ().boxed(),//self.view_sample(self.is_editing()).boxed(),
":sampler" => ().boxed(),//self.view_sampler(self.is_editing(), &self.editor).boxed(),
//":samples-grid" => SamplerView::new(self).boxed(),
":status" => self.view_status().boxed(),
":pool" => self.pool.as_ref()
.map(|pool|Fixed::x(self.w_sidebar(), PoolView(self.is_editing(), pool)))
@ -85,19 +86,6 @@ expose!([self: Tek] {
}
});
macro_rules! defcom {
(|$self:ident, $app:ident:$App:ty| $($Command:ident { $(
$Variant:ident $(($($param:ident: $Param:ty),+))? => $expr:expr
)* $(,)? })*) => {
$(#[derive(Clone, Debug)] pub enum $Command {
$($Variant $(($($Param),+))?),*
})*
$(command!(|$self: $Command, $app: $App|match $self {
$($Command::$Variant $(($($param),+))? => $expr),*
});)*
}
}
defcom! { |self, app: Tek|
TekCommand {
@ -201,30 +189,26 @@ defcom! { |self, app: Tek|
app.editing.store(!app.is_editing(), Relaxed);
};
// autocreate: create new clip from pool when entering empty cell
if let Some(ref pool) = app.pool {
if app.is_editing() {
if let Selection::Clip(t, s) = app.selected {
if let Some(scene) = app.scenes.get_mut(s) {
if let Some(slot) = scene.clips.get_mut(t) {
if slot.is_none() {
let (index, mut clip) = pool.add_new_clip();
// autocolor: new clip colors from scene and track color
clip.write().unwrap().color = ItemColor::random_near(
app.tracks[t].color.base.mix(
scene.color.base,
0.5
),
0.2
).into();
if let Some(ref mut editor) = app.editor {
editor.set_clip(Some(&clip));
}
*slot = Some(clip);
}
}
}
}
if let Some(ref pool) = app.pool
&& app.is_editing()
&& let Selection::Clip(t, s) = app.selected
&& let Some(scene) = app.scenes.get_mut(s)
&& let Some(slot) = scene.clips.get_mut(t)
&& slot.is_none()
{
let (index, mut clip) = pool.add_new_clip();
// autocolor: new clip colors from scene and track color
clip.write().unwrap().color = ItemColor::random_near(
app.tracks[t].color.base.mix(
scene.color.base,
0.5
),
0.2
).into();
if let Some(ref mut editor) = app.editor {
editor.set_clip(Some(&clip));
}
*slot = Some(clip);
}
None
}