Refactored shape brushes to use the properties system

This commit is contained in:
Robert committed 2020-02-11 16:36:34 +01:00
1 parent 128a656f4b
commit ebea8b16a3
40 files changed
+650 -686

No files matched your search

+16
View File
@@ -169,6 +169,10 @@
</Compile>
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertyViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\BrushPropertyInputView.xaml.cs">
<DependentUpon>BrushPropertyInputView.xaml</DependentUpon>
</Compile>
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\BrushPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\EnumPropertyInputView.xaml.cs">
<DependentUpon>EnumPropertyInputView.xaml</DependentUpon>
</Compile>
@@ -176,6 +180,10 @@
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\FloatPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\IntPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\PropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKColorPropertyInputView.xaml.cs">
<DependentUpon>SKColorPropertyInputView.xaml</DependentUpon>
</Compile>
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKColorPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKPointPropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyTreeChildViewModel.cs" />
@@ -302,6 +310,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\BrushPropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\EnumPropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -314,6 +326,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKColorPropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKPointPropertyInputView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -15,11 +15,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
// Keeping the scroll viewers in sync is up to the view, not a viewmodel concern
private void TimelineScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (sender == TimelineHeaderScrollViewer)
if (e.OriginalSource == TimelineHeaderScrollViewer)
TimelineRailsScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
else if (sender == PropertyTreeScrollViewer)
else if (e.OriginalSource == PropertyTreeScrollViewer)
TimelineRailsScrollViewer.ScrollToVerticalOffset(e.VerticalOffset);
else if (sender == TimelineRailsScrollViewer)
else if (e.OriginalSource == TimelineRailsScrollViewer)
{
TimelineHeaderScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset);
PropertyTreeScrollViewer.ScrollToVerticalOffset(e.VerticalOffset);
@@ -41,6 +41,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
PopulateProperties();
_profileEditorService.SelectedProfileElementChanged += (sender, args) => PopulateProperties();
_profileEditorService.SelectedProfileChanged += (sender, args) => PopulateProperties();
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
}
@@ -0,0 +1,28 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.BrushPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<ComboBox Width="132"
Margin="0 2"
Padding="0 -1"
Height="15"
materialDesign:ValidationAssist.UsePopup="True"
HorizontalAlignment="Left"
ItemsSource="{Binding Path=EnumValues}"
SelectedValuePath="Value"
DisplayMemberPath="Description"
SelectedValue="{Binding Path=BrushInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
materialDesign:ComboBoxAssist.ClassicMode="True">
</ComboBox>
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for BrushPropertyInputView.xaml
/// </summary>
public partial class BrushPropertyInputView : UserControl
{
public BrushPropertyInputView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Utilities;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class BrushPropertyInputViewModel : PropertyInputViewModel
{
private readonly ILayerService _layerService;
private readonly IPluginService _pluginService;
public BrushPropertyInputViewModel(IProfileEditorService profileEditorService, ILayerService layerService, IPluginService pluginService) : base(profileEditorService)
{
_layerService = layerService;
_pluginService = pluginService;
EnumValues = new BindableCollection<ValueDescription>();
_pluginService.PluginLoaded += (sender, args) => UpdateEnumValues();
}
public BindableCollection<ValueDescription> EnumValues { get; }
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(LayerBrushReference)};
public LayerBrushReference BrushInputValue
{
get => (LayerBrushReference) InputValue;
set
{
InputValue = value;
_layerService.InstantiateLayerBrush(LayerPropertyViewModel.LayerProperty.Layer);
}
}
protected override void OnInitialized()
{
UpdateEnumValues();
base.OnInitialized();
}
public void UpdateEnumValues()
{
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
var descriptors = layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors).ToList();
EnumValues.Clear();
foreach (var layerBrushDescriptor in descriptors)
{
var brushName = layerBrushDescriptor.LayerBrushType.Name;
var brushGuid = layerBrushDescriptor.LayerBrushProvider.PluginInfo.Guid;
if (BrushInputValue != null && BrushInputValue.BrushType == brushName && BrushInputValue.BrushPluginGuid == brushGuid)
EnumValues.Add(new ValueDescription {Description = layerBrushDescriptor.DisplayName, Value = BrushInputValue});
else
EnumValues.Add(new ValueDescription {Description = layerBrushDescriptor.DisplayName, Value = new LayerBrushReference {BrushType = brushName, BrushPluginGuid = brushGuid}});
}
}
public override void Update()
{
NotifyOfPropertyChange(() => BrushInputValue);
}
}
}
@@ -23,11 +23,6 @@
SelectedValue="{Binding Path=EnumInputValue}"
RequestBringIntoView="{s:Action OnRequestBringIntoView}"
materialDesign:ComboBoxAssist.ClassicMode="True">
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource MaterialDesignComboBoxItemStyle}">
<EventSetter Event="RequestBringIntoView" Handler="OnRequestBringIntoView"/>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
@@ -24,10 +24,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
{
InitializeComponent();
}
private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
e.Handled = true;
}
}
}
@@ -0,0 +1,25 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput.SKColorPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:artemis="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:SKColorPropertyInputViewModel}">
<UserControl.Resources>
<converters:SKColorToColorConverter x:Key="SKColorToColorConverter" />
</UserControl.Resources>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="0 0 5 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
<artemis:ColorPicker Width="132"
Margin="0 2"
Padding="0 -1"
Color="{Binding SKColorInputValue, Converter={StaticResource SKColorToColorConverter}}" />
<TextBlock Margin="5 0 0 0" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
</StackPanel>
</UserControl>
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
/// <summary>
/// Interaction logic for SKColorPropertyInputView.xaml
/// </summary>
public partial class SKColorPropertyInputView : UserControl
{
public SKColorPropertyInputView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using Artemis.UI.Services.Interfaces;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput
{
public class SKColorPropertyInputViewModel : PropertyInputViewModel
{
public SKColorPropertyInputViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
{
}
public sealed override List<Type> CompatibleTypes { get; } = new List<Type> {typeof(SKColor)};
public SKColor SKColorInputValue
{
get => (SKColor?) InputValue ?? new SKColor();
set => InputValue = value;
}
public override void Update()
{
NotifyOfPropertyChange(() => SKColorInputValue);
}
}
}
@@ -16,12 +16,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree
public override void Update(bool forceUpdate)
{
if (forceUpdate)
PropertyInputViewModel.Update();
PropertyInputViewModel?.Update();
else
{
// Only update if visible and if keyframes are enabled
if (LayerPropertyViewModel.Parent.IsExpanded && LayerPropertyViewModel.KeyframesEnabled)
PropertyInputViewModel.Update();
PropertyInputViewModel?.Update();
}
}
}
@@ -91,10 +91,10 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Grid.Column="0" Fill="{DynamicResource MaterialDesignPaper}" />
<Rectangle Grid.Row="0" Grid.Column="0" Fill="Black" Opacity="0.15" />
<Rectangle Grid.Row="0" Grid.Column="1" />
<Rectangle Grid.Row="1" Grid.Column="0" />
<Rectangle Grid.Row="1" Grid.Column="1" Fill="{DynamicResource MaterialDesignPaper}" />
<Rectangle Grid.Row="1" Grid.Column="1" Fill="Black" Opacity="0.15" />
</Grid>
</VisualBrush.Visual>
</VisualBrush>