From 2c120d126be1cff6ed2e4da3dc9bd7b2f2c22c82 Mon Sep 17 00:00:00 2001 From: Yuto Terada Date: Wed, 23 Oct 2024 12:12:29 +0900 Subject: [PATCH] feat: Adjust keyframe positions for the latter elements after splitting --- src/Beutl/ViewModels/ElementViewModel.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Beutl/ViewModels/ElementViewModel.cs b/src/Beutl/ViewModels/ElementViewModel.cs index 601e8fe83..0b03ea0c9 100644 --- a/src/Beutl/ViewModels/ElementViewModel.cs +++ b/src/Beutl/ViewModels/ElementViewModel.cs @@ -3,6 +3,7 @@ using Avalonia; using Avalonia.Input; using Avalonia.Input.Platform; +using Beutl.Animation; using Beutl.Commands; using Beutl.Helpers; using Beutl.Models; @@ -360,6 +361,16 @@ private void OnSplit(TimeSpan timeSpan) IRecordableCommand command1 = Scene.MoveChild(Model.ZIndex, Model.Start, forwardLength, Model); backward.Start = absTime; backward.Length = backwardLength; + foreach (KeyFrameAnimation item in new ObjectSearcher(backward, + o => o is KeyFrameAnimation { UseGlobalClock: false }) + .SearchAll() + .OfType()) + { + foreach (IKeyFrame keyframe in item.KeyFrames) + { + keyframe.KeyTime -= forwardLength; + } + } backward.Save(RandomFileNameGenerator.Generate(Path.GetDirectoryName(Scene.FileName)!, Constants.ElementFileExtension));