diff options
Diffstat (limited to 'rust/crates/commands/src/timeline/tracks_snapshot.rs')
| -rw-r--r-- | rust/crates/commands/src/timeline/tracks_snapshot.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/rust/crates/commands/src/timeline/tracks_snapshot.rs b/rust/crates/commands/src/timeline/tracks_snapshot.rs new file mode 100644 index 00000000..5108e123 --- /dev/null +++ b/rust/crates/commands/src/timeline/tracks_snapshot.rs @@ -0,0 +1,33 @@ +use scene::{Project, SceneTracks}; + +use crate::command::{Command, CommandError, CommandResult}; +use crate::project_ext::active_scene_mut; + +pub struct TracksSnapshotCommand { + before: SceneTracks, + after: SceneTracks, +} + +impl TracksSnapshotCommand { + pub fn new(before: SceneTracks, after: SceneTracks) -> Self { + Self { before, after } + } +} + +impl Command for TracksSnapshotCommand { + fn execute( + &mut self, + project: &mut Project, + ) -> Result<Option<CommandResult>, CommandError> { + if let Some(scene) = active_scene_mut(project) { + scene.tracks = self.after.clone(); + } + Ok(None) + } + + fn undo(&mut self, project: &mut Project) { + if let Some(scene) = active_scene_mut(project) { + scene.tracks = self.before.clone(); + } + } +} |
