Added undo/redo to profile editor

Added shape anchor point display and movement
This commit is contained in:
Robert committed 2020-01-14 17:19:53 +01:00
1 parent e9677f2070
commit c97b479779
25 files changed
+386 -68

No files matched your search

@@ -14,15 +14,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
private readonly IProfileEditorService _profileEditorService;
private int _pixelsPerSecond;
public PropertyTrackKeyframeViewModel(BaseKeyframe keyframe, IProfileEditorService profileEditorService)
public PropertyTrackKeyframeViewModel(PropertyTrackViewModel propertyTrackViewModel, BaseKeyframe keyframe, IProfileEditorService profileEditorService)
{
_profileEditorService = profileEditorService;
PropertyTrackViewModel = propertyTrackViewModel;
Keyframe = keyframe;
EasingViewModels = new BindableCollection<PropertyTrackEasingViewModel>();
CreateEasingViewModels();
}
public bool IsSelected { get; set; }
public PropertyTrackViewModel PropertyTrackViewModel { get; }
public BaseKeyframe Keyframe { get; }
public BindableCollection<PropertyTrackEasingViewModel> EasingViewModels { get; set; }
public double X { get; set; }
@@ -49,6 +52,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public void KeyframeMouseUp(object sender, MouseButtonEventArgs e)
{
((IInputElement) sender).ReleaseMouseCapture();
_profileEditorService.UpdateSelectedProfileElement();
}
public void KeyframeMouseMove(object sender, MouseEventArgs e)
@@ -72,7 +76,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
Keyframe.Position = newTime;
Update(_pixelsPerSecond);
_profileEditorService.UpdateSelectedProfileElement();
_profileEditorService.UpdateProfilePreview();
return;
}
@@ -85,12 +89,29 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
Keyframe.Position = newTime;
Update(_pixelsPerSecond);
_profileEditorService.UpdateSelectedProfileElement();
_profileEditorService.UpdateProfilePreview();
}
}
#endregion
#region Context menu actions
public void Copy()
{
var keyframe = PropertyTrackViewModel.LayerPropertyViewModel.LayerProperty.CreateNewKeyframe(Keyframe.Position, Keyframe.BaseValue);
keyframe.EasingFunction = Keyframe.EasingFunction;
_profileEditorService.UpdateSelectedProfileElement();
}
public void Delete()
{
PropertyTrackViewModel.LayerPropertyViewModel.LayerProperty.RemoveKeyframe(Keyframe);
_profileEditorService.UpdateSelectedProfileElement();
}
#endregion
#region Easing
private void CreateEasingViewModels()
@@ -39,7 +39,17 @@
MouseMove="{s:Action KeyframeMouseMove}">
<Ellipse.ContextMenu>
<ContextMenu>
<MenuItem Header="Copy" />
<MenuItem Header="Copy" Command="{s:Action Copy}">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="ContentCopy" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Delete" Command="{s:Action Delete}">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="Delete" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Easing" ItemsSource="{Binding EasingViewModels}">
<MenuItem.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
@@ -39,7 +39,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{
if (KeyframeViewModels.Any(k => k.Keyframe == keyframe))
continue;
KeyframeViewModels.Add(_propertyTrackKeyframeViewModelFactory.Create(keyframe));
KeyframeViewModels.Add(_propertyTrackKeyframeViewModelFactory.Create(this, keyframe));
}
UpdateKeyframes(PropertyTimelineViewModel.LayerPropertiesViewModel.PixelsPerSecond);