mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Refactored shape brushes to use the properties system
This commit is contained in:
1 parent
128a656f4b
commit
ebea8b16a3
40 files changed
+650
-686
No files matched your search
+3
-3
@@ -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);
|
||||
|
||||
+1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+28
@@ -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>
|
||||
+28
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+68
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -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>
|
||||
|
||||
-5
@@ -24,10 +24,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -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>
|
||||
+28
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user