mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
autocolor: clip colors from track and scene
This commit is contained in:
parent
2a5af2c753
commit
3f2cf57ea8
1 changed files with 19 additions and 13 deletions
|
|
@ -167,10 +167,10 @@ has_editor!(|self: Tek|{
|
|||
is_editing = self.editing.load(Relaxed); });
|
||||
edn_provide!(# usize: |self: Tek| {
|
||||
":scene" => self.selected.scene().unwrap_or(0),
|
||||
":scene-next" => self.selected.scene().unwrap_or(0) + 1,
|
||||
":scene-next" => (self.selected.scene().unwrap_or(0) + 1).min(self.scenes.len()),
|
||||
":scene-prev" => self.selected.scene().unwrap_or(0).saturating_sub(1),
|
||||
":track" => self.selected.track().unwrap_or(0),
|
||||
":track-next" => self.selected.track().unwrap_or(0) + 1,
|
||||
":track-next" => (self.selected.track().unwrap_or(0) + 1).min(self.tracks.len()),
|
||||
":track-prev" => self.selected.track().unwrap_or(0).saturating_sub(1) });
|
||||
edn_view!(TuiOut: |self: Tek| self.size.of(EdnView::from_source(self, self.edn.as_ref())); {
|
||||
bool {};
|
||||
|
|
@ -686,7 +686,6 @@ command!(|self: TekCommand, app: Tek|match self {
|
|||
None
|
||||
},
|
||||
Self::Edit(value) => {
|
||||
// autocreate: create new clip when entering empty cell
|
||||
if let Some(value) = value {
|
||||
if app.is_editing() != value {
|
||||
app.editing.store(value, Relaxed);
|
||||
|
|
@ -694,18 +693,25 @@ command!(|self: TekCommand, app: Tek|match self {
|
|||
} else {
|
||||
app.editing.store(!app.is_editing(), Relaxed);
|
||||
};
|
||||
if app.is_editing() {
|
||||
if let Selection::Clip(t, s) = app.selected {
|
||||
if let Some(Some(c)) = app.scenes.get_mut(s).map(|s|s.clips.get_mut(t)) {
|
||||
if c.is_none() {
|
||||
if let Some(ref pool) = app.pool {
|
||||
let (index, clip) = pool.add_new_clip();
|
||||
if let Some(ref mut editor) = app.editor {
|
||||
editor.set_clip(Some(&clip));
|
||||
// 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);
|
||||
}
|
||||
*c = Some(clip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue