|
@@ -16,9 +16,39 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
public AnimationsViewModel(ViewModelMain owner) : base(owner)
|
|
public AnimationsViewModel(ViewModelMain owner) : base(owner)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
-
|
|
|
|
- [Command.Basic("PixiEditor.Animation.CreateRasterKeyFrame", "Create Raster Key Frame", "Create a raster key frame", Parameter = false, AnalyticsTrack = true)]
|
|
|
|
- [Command.Basic("PixiEditor.Animation.DuplicateRasterKeyFrame", "Duplicate Raster Key Frame", "Duplicate a raster key frame", Parameter = true, AnalyticsTrack = true)]
|
|
|
|
|
|
+
|
|
|
|
+ [Command.Basic("PixiEditor.Animation.NudgeActiveFrameNext", "CHANGE_ACTIVE_FRAME_NEXT",
|
|
|
|
+ "CHANGE_ACTIVE_FRAME_NEXT",
|
|
|
|
+ Parameter = 1, Key = Key.Right)]
|
|
|
|
+ [Command.Basic("PixiEditor.Animation.NudgeActiveFramePrevious", "CHANGE_ACTIVE_FRAME_PREVIOUS",
|
|
|
|
+ "CHANGE_ACTIVE_FRAME_PREVIOUS",
|
|
|
|
+ Parameter = -1, Key = Key.Left)]
|
|
|
|
+ public void ChangeActiveFrame(int nudgeBy)
|
|
|
|
+ {
|
|
|
|
+ var activeDocument = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
|
|
+ if (activeDocument is null || activeDocument.TransformViewModel.TransformActive)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ int newFrame = activeDocument.AnimationDataViewModel.ActiveFrameBindable + nudgeBy;
|
|
|
|
+ newFrame = Math.Max(1, newFrame);
|
|
|
|
+ activeDocument.Operations.SetActiveFrame(newFrame);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [Command.Basic("PixiEditor.Animation.TogglePlayAnimation", "TOGGLE_ANIMATION", "TOGGLE_ANIMATION",
|
|
|
|
+ Key = Key.Space, Modifiers = KeyModifiers.Shift)]
|
|
|
|
+ public void ToggleAnimation()
|
|
|
|
+ {
|
|
|
|
+ var activeDocument = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
|
|
+ if (activeDocument is null)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ activeDocument.AnimationDataViewModel.IsPlayingBindable = !activeDocument.AnimationDataViewModel.IsPlayingBindable;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [Command.Basic("PixiEditor.Animation.CreateRasterKeyFrame", "Create Raster Key Frame", "Create a raster key frame",
|
|
|
|
+ Parameter = false, AnalyticsTrack = true)]
|
|
|
|
+ [Command.Basic("PixiEditor.Animation.DuplicateRasterKeyFrame", "Duplicate Raster Key Frame",
|
|
|
|
+ "Duplicate a raster key frame", Parameter = true, AnalyticsTrack = true)]
|
|
public void CreateRasterKeyFrame(bool duplicate)
|
|
public void CreateRasterKeyFrame(bool duplicate)
|
|
{
|
|
{
|
|
var activeDocument = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
var activeDocument = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
@@ -28,16 +58,16 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
}
|
|
}
|
|
|
|
|
|
int newFrame = GetActiveFrame(activeDocument, activeDocument.SelectedStructureMember.Id);
|
|
int newFrame = GetActiveFrame(activeDocument, activeDocument.SelectedStructureMember.Id);
|
|
-
|
|
|
|
|
|
+
|
|
Guid toCloneFrom = duplicate ? activeDocument.SelectedStructureMember.Id : Guid.Empty;
|
|
Guid toCloneFrom = duplicate ? activeDocument.SelectedStructureMember.Id : Guid.Empty;
|
|
int frameToCopyFrom = duplicate ? activeDocument.AnimationDataViewModel.ActiveFrameBindable : -1;
|
|
int frameToCopyFrom = duplicate ? activeDocument.AnimationDataViewModel.ActiveFrameBindable : -1;
|
|
|
|
|
|
activeDocument.AnimationDataViewModel.CreateRasterKeyFrame(
|
|
activeDocument.AnimationDataViewModel.CreateRasterKeyFrame(
|
|
activeDocument.SelectedStructureMember.Id,
|
|
activeDocument.SelectedStructureMember.Id,
|
|
newFrame,
|
|
newFrame,
|
|
- toCloneFrom,
|
|
|
|
|
|
+ toCloneFrom,
|
|
frameToCopyFrom);
|
|
frameToCopyFrom);
|
|
-
|
|
|
|
|
|
+
|
|
activeDocument.Operations.SetActiveFrame(newFrame);
|
|
activeDocument.Operations.SetActiveFrame(newFrame);
|
|
|
|
|
|
Analytics.SendCreateKeyframe(
|
|
Analytics.SendCreateKeyframe(
|
|
@@ -55,10 +85,10 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
{
|
|
{
|
|
if (Owner.DocumentManagerSubViewModel.ActiveDocument is null)
|
|
if (Owner.DocumentManagerSubViewModel.ActiveDocument is null)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+
|
|
Owner.DocumentManagerSubViewModel.ActiveDocument?.AnimationDataViewModel.ToggleOnionSkinning(value);
|
|
Owner.DocumentManagerSubViewModel.ActiveDocument?.AnimationDataViewModel.ToggleOnionSkinning(value);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
[Command.Basic("PixiEditor.Animation.DeleteKeyFrames", "DELETE_KEY_FRAMES", "DELETE_KEY_FRAMES_DESCRIPTIVE",
|
|
[Command.Basic("PixiEditor.Animation.DeleteKeyFrames", "DELETE_KEY_FRAMES", "DELETE_KEY_FRAMES_DESCRIPTIVE",
|
|
ShortcutContext = typeof(TimelineDockViewModel), Key = Key.Delete, AnalyticsTrack = true)]
|
|
ShortcutContext = typeof(TimelineDockViewModel), Key = Key.Delete, AnalyticsTrack = true)]
|
|
public void DeleteKeyFrames()
|
|
public void DeleteKeyFrames()
|
|
@@ -68,18 +98,18 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
|
|
|
|
if (activeDocument is null || selected.Length == 0)
|
|
if (activeDocument is null || selected.Length == 0)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+
|
|
List<Guid> keyFrameIds = selected.Select(x => x.Id).ToList();
|
|
List<Guid> keyFrameIds = selected.Select(x => x.Id).ToList();
|
|
-
|
|
|
|
- for(int i = 0; i < keyFrameIds.Count; i++)
|
|
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < keyFrameIds.Count; i++)
|
|
{
|
|
{
|
|
- if(!activeDocument.AnimationDataViewModel.TryFindKeyFrame<KeyFrameViewModel>(keyFrameIds[i], out _))
|
|
|
|
|
|
+ if (!activeDocument.AnimationDataViewModel.TryFindKeyFrame<KeyFrameViewModel>(keyFrameIds[i], out _))
|
|
{
|
|
{
|
|
keyFrameIds.RemoveAt(i);
|
|
keyFrameIds.RemoveAt(i);
|
|
- i--;
|
|
|
|
|
|
+ i--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
activeDocument.AnimationDataViewModel.DeleteKeyFrames(keyFrameIds);
|
|
activeDocument.AnimationDataViewModel.DeleteKeyFrames(keyFrameIds);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -100,19 +130,20 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
activeDocument.AnimationDataViewModel.EndKeyFramesStartPos();
|
|
activeDocument.AnimationDataViewModel.EndKeyFramesStartPos();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
private static int GetActiveFrame(DocumentViewModel activeDocument, Guid targetLayer)
|
|
private static int GetActiveFrame(DocumentViewModel activeDocument, Guid targetLayer)
|
|
{
|
|
{
|
|
int active = activeDocument.AnimationDataViewModel.ActiveFrameBindable;
|
|
int active = activeDocument.AnimationDataViewModel.ActiveFrameBindable;
|
|
- if (activeDocument.AnimationDataViewModel.TryFindKeyFrame<KeyFrameGroupViewModel>(targetLayer, out KeyFrameGroupViewModel groupViewModel))
|
|
|
|
|
|
+ if (activeDocument.AnimationDataViewModel.TryFindKeyFrame<KeyFrameGroupViewModel>(targetLayer,
|
|
|
|
+ out KeyFrameGroupViewModel groupViewModel))
|
|
{
|
|
{
|
|
- if(active == groupViewModel.StartFrameBindable + groupViewModel.DurationBindable - 1)
|
|
|
|
|
|
+ if (active == groupViewModel.StartFrameBindable + groupViewModel.DurationBindable - 1)
|
|
{
|
|
{
|
|
return groupViewModel.StartFrameBindable + groupViewModel.DurationBindable;
|
|
return groupViewModel.StartFrameBindable + groupViewModel.DurationBindable;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return active;
|
|
return active;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -124,13 +155,13 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
// TODO: same as below
|
|
// TODO: same as below
|
|
//Owner.DocumentManagerSubViewModel.ActiveDocument.EventInlet.StartChangeActiveFrame();
|
|
//Owner.DocumentManagerSubViewModel.ActiveDocument.EventInlet.StartChangeActiveFrame();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
[Command.Internal("PixiEditor.Document.ChangeActiveFrame", CanExecute = "PixiEditor.HasDocument")]
|
|
[Command.Internal("PixiEditor.Document.ChangeActiveFrame", CanExecute = "PixiEditor.HasDocument")]
|
|
public void ChangeActiveFrame(double newActiveFrame)
|
|
public void ChangeActiveFrame(double newActiveFrame)
|
|
{
|
|
{
|
|
if (Owner.DocumentManagerSubViewModel.ActiveDocument is null)
|
|
if (Owner.DocumentManagerSubViewModel.ActiveDocument is null)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+
|
|
int intNewActiveFrame = (int)newActiveFrame;
|
|
int intNewActiveFrame = (int)newActiveFrame;
|
|
// TODO: Check if this should be implemented
|
|
// TODO: Check if this should be implemented
|
|
//Owner.DocumentManagerSubViewModel.ActiveDocument.EventInlet.ChangeActiveFrame(intNewActiveFrame);
|
|
//Owner.DocumentManagerSubViewModel.ActiveDocument.EventInlet.ChangeActiveFrame(intNewActiveFrame);
|
|
@@ -141,15 +172,15 @@ internal class AnimationsViewModel : SubViewModel<ViewModelMain>
|
|
{
|
|
{
|
|
if (Owner.DocumentManagerSubViewModel.ActiveDocument is null)
|
|
if (Owner.DocumentManagerSubViewModel.ActiveDocument is null)
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+
|
|
//Owner.DocumentManagerSubViewModel.ActiveDocument.EventInlet.EndChangeActiveFrame();
|
|
//Owner.DocumentManagerSubViewModel.ActiveDocument.EventInlet.EndChangeActiveFrame();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
[Command.Internal("PixiEditor.Animation.ActiveFrameSet")]
|
|
[Command.Internal("PixiEditor.Animation.ActiveFrameSet")]
|
|
public void ActiveFrameSet(double value)
|
|
public void ActiveFrameSet(double value)
|
|
{
|
|
{
|
|
var document = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
var document = Owner.DocumentManagerSubViewModel.ActiveDocument;
|
|
-
|
|
|
|
|
|
+
|
|
if (document is null)
|
|
if (document is null)
|
|
return;
|
|
return;
|
|
|
|
|