Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge pull request #1037 from vbasky/fix/1001-selection-persist

Brandon Thomas286a521598f5
diff --cc crates/engine/src/lib.rs
index 549633d9d,5e3edc545..44dd926f7
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@@ -200,12 -216,13 +216,16 @@@ pub struct EditorState
pub active_comp: Option<ItemId>,
/// Open compositions (viewer/timeline tabs), in tab order.
pub open_comps: Vec<ItemId>,
+ /// Compositions that were active before the current one, most recent first (Shift+Esc).
+ #[serde(default)]
+ pub recent_comps: Vec<ItemId>,
/// Current time per comp (the CTI).
pub times: std::collections::BTreeMap<ItemId, Tick>,
+ /// Layer selection of the active comp. Other comps' selections are in [`Self::comp_selections`].
pub selected_layers: Vec<LayerId>,
+ /// Selections of comps that are not active, keyed by comp id (#1001).
+ #[serde(default)]
+ pub comp_selections: std::collections::BTreeMap<ItemId, CompSelection>,
/// Selected properties / groups (by uid) of selected layers.
pub selected_props: Vec<(LayerId, Uid)>,
pub selected_keys: Vec<KeyRef>,
@@@ -881,20 -965,7 +968,15 @@@ impl Session
if !self.state.open_comps.contains(&id) {
self.state.open_comps.push(id);
}
+ if self.state.active_comp != Some(id) {
+ let previous = self.state.active_comp;
+ self.state.recent_comps.retain(|c| *c != id && Some(*c) != previous);
+ if let Some(previous) = previous {
+ self.state.recent_comps.insert(0, previous);
+ self.state.recent_comps.truncate(32);
+ }
- self.state.active_comp = Some(id);
- self.state.selected_layers.clear();
- self.state.selected_props.clear();
- self.state.selected_keys.clear();
- self.state.selected_vertices.clear();
- self.state.current_track = None;
+ }
+ self.activate_comp(id);
self.events.push(Event::OpenComp(id));
}