Started work on the keyframe engine to tie everything together!

This commit is contained in:
Robert committed 2020-01-08 20:36:27 +01:00
1 parent 139e1879c1
commit d1e0267709
28 files changed
+339 -107

No files matched your search

@@ -61,7 +61,7 @@
</Canvas>
<!-- Timeline header -->
<ScrollViewer Grid.Row="0" x:Name="TimelineHeaderScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" >
<ScrollViewer Grid.Row="0" x:Name="TimelineHeaderScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<StackPanel>
<!-- Time -->
<timeline:PropertyTimelineHeader Margin="0 25 0 0"
@@ -12,8 +12,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
{
public class LayerPropertiesViewModel : ProfileEditorPanelViewModel
{
private readonly IProfileEditorService _profileEditorService;
private readonly ILayerPropertyViewModelFactory _layerPropertyViewModelFactory;
private readonly IProfileEditorService _profileEditorService;
public LayerPropertiesViewModel(IProfileEditorService profileEditorService, ILayerPropertyViewModelFactory layerPropertyViewModelFactory)
{
@@ -11,10 +11,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public class LayerPropertyViewModel : PropertyChangedBase
{
private readonly IKernel _kernel;
private bool _keyframesEnabled;
public LayerPropertyViewModel(BaseLayerProperty layerProperty,
LayerPropertyViewModel parent,
ILayerPropertyViewModelFactory layerPropertyViewModelFactory, IKernel kernel)
public LayerPropertyViewModel(BaseLayerProperty layerProperty, LayerPropertyViewModel parent, ILayerPropertyViewModelFactory layerPropertyViewModelFactory, IKernel kernel)
{
_kernel = kernel;
@@ -33,6 +32,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public bool IsExpanded { get; set; }
public bool KeyframesEnabled
{
get => _keyframesEnabled;
set
{
_keyframesEnabled = value;
UpdateKeyframes();
}
}
private void UpdateKeyframes()
{
}
public PropertyInputViewModel GetPropertyInputViewModel()
{
var match = _kernel.Get<List<PropertyInputViewModel>>().FirstOrDefault(p => p.CompatibleTypes.Contains(LayerProperty.Type));
@@ -1,10 +1,26 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class FloatPropertyInputViewModel : PropertyInputViewModel
{
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(float)};
protected override void UpdateBaseValue(object value)
{
throw new NotImplementedException();
}
protected override void UpdateKeyframeValue(BaseKeyframe keyframe, object value)
{
throw new NotImplementedException();
}
protected override void CreateKeyframeForValue(object value)
{
throw new NotImplementedException();
}
}
}
@@ -1,10 +1,26 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class IntPropertyInputViewModel : PropertyInputViewModel
{
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(int)};
protected override void UpdateBaseValue(object value)
{
throw new NotImplementedException();
}
protected override void UpdateKeyframeValue(BaseKeyframe keyframe, object value)
{
throw new NotImplementedException();
}
protected override void CreateKeyframeForValue(object value)
{
throw new NotImplementedException();
}
}
}
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Exceptions;
using Stylet;
@@ -12,6 +14,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
public abstract List<Type> CompatibleTypes { get; }
public LayerPropertyViewModel LayerPropertyViewModel { get; private set; }
public object InputValue
{
get => LayerPropertyViewModel.LayerProperty.KeyframeEngine.GetCurrentValue();
set => UpdateInputValue(value);
}
public void Initialize(LayerPropertyViewModel layerPropertyViewModel)
{
if (Initialized)
@@ -20,7 +28,32 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
throw new ArtemisUIException($"This input VM does not support the provided type {layerPropertyViewModel.LayerProperty.Type.Name}");
LayerPropertyViewModel = layerPropertyViewModel;
Update();
Initialized = true;
}
public void Update()
{
NotifyOfPropertyChange(() => InputValue);
}
private void UpdateInputValue(object value)
{
// If keyframes are disabled, update the base value
if (!LayerPropertyViewModel.KeyframesEnabled)
{
UpdateBaseValue(value);
return;
}
// If on a keyframe, update the keyframe TODO: Make decisions..
// var currentKeyframe = LayerPropertyViewModel.LayerProperty.UntypedKeyframes.FirstOrDefault(k => k.Position == LayerPropertyViewModel.)
// Otherwise, add a new keyframe at the current position
}
protected abstract void UpdateBaseValue(object value);
protected abstract void UpdateKeyframeValue(BaseKeyframe keyframe, object value);
protected abstract void CreateKeyframeForValue(object value);
}
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
@@ -7,5 +8,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
public class SKPointPropertyInputViewModel : PropertyInputViewModel
{
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(SKPoint)};
protected override void UpdateBaseValue(object value)
{
throw new NotImplementedException();
}
protected override void UpdateKeyframeValue(BaseKeyframe keyframe, object value)
{
throw new NotImplementedException();
}
protected override void CreateKeyframeForValue(object value)
{
throw new NotImplementedException();
}
}
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
@@ -7,5 +8,20 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
public class SKSizePropertyInputViewModel : PropertyInputViewModel
{
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(SKSize)};
protected override void UpdateBaseValue(object value)
{
throw new NotImplementedException();
}
protected override void UpdateKeyframeValue(BaseKeyframe keyframe, object value)
{
throw new NotImplementedException();
}
protected override void CreateKeyframeForValue(object value)
{
throw new NotImplementedException();
}
}
}
@@ -36,8 +36,8 @@
ToolTip="{Binding LayerPropertyViewModel.LayerProperty.Description}"
HorizontalAlignment="Left" />
<ContentControl Grid.Column="2" Margin="20 0" s:View.Model="{Binding PropertyInputViewModel}"/>
<ContentControl Grid.Column="2" Margin="20 0" s:View.Model="{Binding PropertyInputViewModel}" />
<Button Grid.Column="3"
Style="{StaticResource MaterialDesignOutlinedButton}"
Margin="0,1,0,1.2"
@@ -1,13 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
{
public class PropertyTreeChildViewModel : PropertyTreeItemViewModel
{
private bool _keyframesEnabled;
public PropertyTreeChildViewModel(LayerPropertyViewModel layerPropertyViewModel)
{
LayerPropertyViewModel = layerPropertyViewModel;
@@ -16,19 +12,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
public LayerPropertyViewModel LayerPropertyViewModel { get; }
public PropertyInputViewModel PropertyInputViewModel { get; set; }
public bool KeyframesEnabled
{
get => _keyframesEnabled;
set
{
_keyframesEnabled = value;
UpdateKeyframes();
}
}
private void UpdateKeyframes()
{
}
}
}
@@ -99,8 +99,8 @@
</StackPanel>
</HierarchicalDataTemplate>
<!-- Children show their full view -->
<DataTemplate DataType="{x:Type local:PropertyTreeChildViewModel}" >
<ContentControl s:View.Model="{Binding}"/>
<DataTemplate DataType="{x:Type local:PropertyTreeChildViewModel}">
<ContentControl s:View.Model="{Binding}" />
</DataTemplate>
</TreeView.Resources>
</TreeView>
@@ -1,5 +1,4 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using Stylet;