Layer timeline - Show keyframes of collapsed groups

Profile editor - Don't reload UI elements on undo/redo if there's nothing to undo/redo
Layer properties - Properly show/hide properties
This commit is contained in:
SpoinkyNL committed 2020-05-29 17:21:29 +02:00
1 parent e6080eb897
commit 22ecf5028d
20 files changed
+182 -83

No files matched your search

@@ -61,7 +61,7 @@
<Grid x:Name="ContainerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
@@ -196,16 +196,15 @@
HorizontalAlignment="Stretch"
ZIndex="2"
Background="{DynamicResource MaterialDesignCardBackground}">
<!-- Zoom control -->
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Slider Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="10"
Minimum="31"
Maximum="350"
Value="{Binding ProfileEditorService.PixelsPerSecond}"
Width="319" />
</StackPanel>
<Slider Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="10 5"
Minimum="31"
Maximum="350"
Value="{Binding ProfileEditorService.PixelsPerSecond}"
Width="319" />
</StackPanel>
</Grid>
</UserControl>
@@ -92,6 +92,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
#region View model managament
public List<LayerPropertyGroupViewModel> GetAllLayerPropertyGroupViewModels()
{
var groups = LayerPropertyGroups.ToList();
groups.AddRange(groups.SelectMany(g => g.Children).Where(g => g is LayerPropertyGroupViewModel).Cast<LayerPropertyGroupViewModel>());
return groups;
}
private void PopulateProperties(ProfileElement profileElement)
{
if (SelectedLayer != null)
@@ -23,8 +23,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
TimelinePropertyGroupViewModel = new TimelinePropertyGroupViewModel(this);
PopulateChildren();
LayerPropertyGroup.VisibilityChanged += LayerPropertyGroupOnVisibilityChanged;
}
public override bool IsExpanded
{
get => LayerPropertyGroup.Layer.IsPropertyGroupExpanded(LayerPropertyGroup);
@@ -68,7 +70,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public override List<BaseLayerPropertyKeyframe> GetKeyframes(bool visibleOnly)
{
var result = new List<BaseLayerPropertyKeyframe>();
if (!IsExpanded)
if (visibleOnly && !IsExpanded)
return result;
foreach (var layerPropertyBaseViewModel in Children)
@@ -81,6 +83,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
{
foreach (var layerPropertyBaseViewModel in Children)
layerPropertyBaseViewModel.Dispose();
LayerPropertyGroup.VisibilityChanged -= LayerPropertyGroupOnVisibilityChanged;
TimelinePropertyGroupViewModel.Dispose();
}
public List<LayerPropertyBaseViewModel> GetAllChildren()
@@ -95,5 +100,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
return result;
}
private void LayerPropertyGroupOnVisibilityChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(IsVisible));
}
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
@@ -33,6 +34,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
else
PropertyDescription.Name = $"Unknown {typeof(T).Name} property";
}
LayerProperty.VisibilityChanged += LayerPropertyOnVisibilityChanged;
}
public override bool IsVisible => !LayerProperty.IsHidden;
@@ -51,6 +54,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
{
TreePropertyViewModel.Dispose();
TimelinePropertyViewModel.Dispose();
LayerProperty.VisibilityChanged -= LayerPropertyOnVisibilityChanged;
}
public void SetCurrentValue(T value, bool saveChanges)
@@ -61,6 +66,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
else
ProfileEditorService.UpdateProfilePreview();
}
private void LayerPropertyOnVisibilityChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(IsVisible));
}
}
public abstract class LayerPropertyViewModel : LayerPropertyBaseViewModel
@@ -30,42 +30,17 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Left" Value="{Binding}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Fill="{StaticResource PrimaryHueMidBrush}"
<Ellipse Fill="{StaticResource MaterialDesignCheckBoxDisabled}"
Stroke="White"
StrokeThickness="0"
Width="10"
Height="10"
Margin="-5,6,0,0"
s:View.ActionTarget="{Binding}">
<Ellipse.Style>
<Style TargetType="{x:Type Ellipse}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="StrokeThickness"
To="1" Duration="0:0:0.25" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="StrokeThickness"
To="0" Duration="0:0:0.25" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
Margin="-5,6,0,0">
</Ellipse>
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -1,4 +1,8 @@
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using System;
using System.ComponentModel;
using System.Linq;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{
@@ -7,8 +11,40 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public TimelinePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel)
{
LayerPropertyGroupViewModel = (LayerPropertyGroupViewModel) layerPropertyBaseViewModel;
TimelineKeyframeViewModels = new BindableCollection<double>();
LayerPropertyGroupViewModel.ProfileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
LayerPropertyGroupViewModel.PropertyChanged += LayerPropertyGroupViewModelOnPropertyChanged;
UpdateKeyframes();
}
public LayerPropertyGroupViewModel LayerPropertyGroupViewModel { get; }
public BindableCollection<double> TimelineKeyframeViewModels { get; set; }
public TimelineViewModel TimelineViewModel { get; set; }
public void UpdateKeyframes()
{
TimelineKeyframeViewModels.Clear();
TimelineKeyframeViewModels.AddRange(LayerPropertyGroupViewModel.GetKeyframes(false)
.Select(k => LayerPropertyGroupViewModel.ProfileEditorService.PixelsPerSecond * k.Position.TotalSeconds));
}
public void Dispose()
{
LayerPropertyGroupViewModel.ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
LayerPropertyGroupViewModel.PropertyChanged -= LayerPropertyGroupViewModelOnPropertyChanged;
}
private void LayerPropertyGroupViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(LayerPropertyGroupViewModel.IsExpanded))
UpdateKeyframes();
}
private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e)
{
UpdateKeyframes();
}
}
}
@@ -32,6 +32,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{
foreach (var layerPropertyGroupViewModel in LayerPropertyGroups)
{
layerPropertyGroupViewModel.TimelinePropertyGroupViewModel.TimelineViewModel = this;
layerPropertyGroupViewModel.TimelinePropertyGroupViewModel.UpdateKeyframes();
foreach (var layerPropertyBaseViewModel in layerPropertyGroupViewModel.GetAllChildren())
{
if (layerPropertyBaseViewModel is LayerPropertyViewModel layerPropertyViewModel)
@@ -11,6 +11,7 @@ using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
using Artemis.UI.Services.Interfaces;
@@ -110,12 +111,28 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
public void Undo()
{
// Expanded status is also undone because undoing works a bit crude, that's annoying
var beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels();
var expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList();
_profileEditorService.UndoUpdateProfile(Module);
// Restore the expanded status
foreach (var allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels())
allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path);
}
public void Redo()
{
// Expanded status is also undone because undoing works a bit crude, that's annoying
var beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels();
var expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList();
_profileEditorService.RedoUpdateProfile(Module);
// Restore the expanded status
foreach (var allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels())
allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path);
}
protected override void OnInitialActivate()