mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profile editor - Reimplemented more of the timeline
This commit is contained in:
1 parent
bb687607ec
commit
e18af234c7
24 files changed
+294
-296
No files matched your search
+22
-24
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Shared;
|
||||
@@ -10,16 +8,16 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingModifierViewModel : PropertyChangedBase
|
||||
public class DataBindingModifierViewModel<TLayerProperty, TProperty> : PropertyChangedBase
|
||||
{
|
||||
private readonly IDataBindingService _dataBindingService;
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private DataBindingModifierType _selectedModifierType;
|
||||
private DataModelDynamicViewModel _dynamicSelectionViewModel;
|
||||
private DataBindingModifierType _selectedModifierType;
|
||||
private DataModelStaticViewModel _staticInputViewModel;
|
||||
|
||||
public DataBindingModifierViewModel(DataBindingModifier modifier,
|
||||
public DataBindingModifierViewModel(DataBindingModifier<TLayerProperty, TProperty> modifier,
|
||||
IDataBindingService dataBindingService,
|
||||
ISettingsService settingsService,
|
||||
IDataModelUIService dataModelUIService,
|
||||
@@ -42,7 +40,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
public DelegateCommand SelectModifierTypeCommand { get; }
|
||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||
public DataBindingModifier Modifier { get; }
|
||||
public DataBindingModifier<TLayerProperty, TProperty> Modifier { get; }
|
||||
public BindableCollection<DataBindingModifierType> ModifierTypes { get; }
|
||||
|
||||
public DataBindingModifierType SelectedModifierType
|
||||
@@ -62,7 +60,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
get => _staticInputViewModel;
|
||||
private set => SetAndNotify(ref _staticInputViewModel, value);
|
||||
}
|
||||
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
Modifier.DataBinding.RemoveModifier(Modifier);
|
||||
}
|
||||
|
||||
public void SwapType()
|
||||
{
|
||||
if (Modifier.ParameterType == ProfileRightSideType.Dynamic)
|
||||
Modifier.UpdateParameter(Modifier.DataBinding.GetSourceType().GetDefault());
|
||||
else
|
||||
Modifier.UpdateParameter(null, null);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
private void ParameterSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
|
||||
{
|
||||
Modifier.UpdateParameter(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.PropertyPath);
|
||||
@@ -89,7 +102,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
StaticInputViewModel = null;
|
||||
DynamicSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||
DynamicSelectionViewModel.PropertySelected += ParameterSelectionViewModelOnPropertySelected;
|
||||
DynamicSelectionViewModel.FilterTypes = new[] { sourceType };
|
||||
DynamicSelectionViewModel.FilterTypes = new[] {sourceType};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,20 +133,5 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
Modifier.DataBinding.RemoveModifier(Modifier);
|
||||
}
|
||||
|
||||
public void SwapType()
|
||||
{
|
||||
if (Modifier.ParameterType == ProfileRightSideType.Dynamic)
|
||||
Modifier.UpdateParameter(Modifier.DataBinding.GetSourceType().GetDefault());
|
||||
else
|
||||
Modifier.UpdateParameter(null, null);
|
||||
|
||||
Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
-17
@@ -10,23 +10,23 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingViewModel : PropertyChangedBase, IDisposable
|
||||
public class DataBindingViewModel<TLayerProperty, TProperty> : Screen, IDataBindingViewModel
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private DataBinding _dataBinding;
|
||||
private DataBinding<TLayerProperty, TProperty> _dataBinding;
|
||||
private int _easingTime;
|
||||
private bool _isDataBindingEnabled;
|
||||
private bool _isEasingTimeEnabled;
|
||||
private DataBindingMode _selectedDataBindingMode;
|
||||
private TimelineEasingViewModel _selectedEasingViewModel;
|
||||
private DataModelDynamicViewModel _targetSelectionViewModel;
|
||||
private object _testInputValue;
|
||||
private object _testResultValue;
|
||||
private TProperty _testInputValue;
|
||||
private TProperty _testResultValue;
|
||||
private bool _updating;
|
||||
|
||||
public DataBindingViewModel(DataBindingRegistration registration,
|
||||
public DataBindingViewModel(DataBindingRegistration<TLayerProperty, TProperty> registration,
|
||||
IProfileEditorService profileEditorService,
|
||||
IDataModelUIService dataModelUIService,
|
||||
IDataBindingsVmFactory dataBindingsVmFactory)
|
||||
@@ -40,7 +40,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
DataBindingModes = new BindableCollection<ValueDescription>(EnumUtilities.GetAllValuesAndDescriptions(typeof(DataBindingMode)));
|
||||
EasingViewModels = new BindableCollection<TimelineEasingViewModel>();
|
||||
ModifierViewModels = new BindableCollection<DataBindingModifierViewModel>();
|
||||
ModifierViewModels = new BindableCollection<DataBindingModifierViewModel<TLayerProperty, TProperty>>();
|
||||
|
||||
DataBinding = Registration.DataBinding;
|
||||
if (DataBinding != null)
|
||||
@@ -52,12 +52,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
Execute.PostToUIThread(Initialize);
|
||||
}
|
||||
|
||||
public DataBindingRegistration Registration { get; }
|
||||
public string DisplayName { get; }
|
||||
public DataBindingRegistration<TLayerProperty, TProperty> Registration { get; }
|
||||
|
||||
public BindableCollection<ValueDescription> DataBindingModes { get; }
|
||||
public BindableCollection<TimelineEasingViewModel> EasingViewModels { get; }
|
||||
public BindableCollection<DataBindingModifierViewModel> ModifierViewModels { get; }
|
||||
public BindableCollection<DataBindingModifierViewModel<TLayerProperty, TProperty>> ModifierViewModels { get; }
|
||||
|
||||
public DataBindingMode SelectedDataBindingMode
|
||||
{
|
||||
@@ -114,7 +113,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
}
|
||||
}
|
||||
|
||||
public DataBinding DataBinding
|
||||
public DataBinding<TLayerProperty, TProperty> DataBinding
|
||||
{
|
||||
get => _dataBinding;
|
||||
set
|
||||
@@ -124,13 +123,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
}
|
||||
}
|
||||
|
||||
public object TestInputValue
|
||||
public TProperty TestInputValue
|
||||
{
|
||||
get => _testInputValue;
|
||||
set => SetAndNotify(ref _testInputValue, value);
|
||||
}
|
||||
|
||||
public object TestResultValue
|
||||
public TProperty TestResultValue
|
||||
{
|
||||
get => _testResultValue;
|
||||
set => SetAndNotify(ref _testResultValue, value);
|
||||
@@ -167,7 +166,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
if (DataBinding == null)
|
||||
return;
|
||||
|
||||
var modifier = new DataBindingModifier(ProfileRightSideType.Dynamic);
|
||||
var modifier = new DataBindingModifier<TLayerProperty, TProperty>(ProfileRightSideType.Dynamic);
|
||||
DataBinding.AddModifier(modifier);
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
@@ -175,7 +174,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
EasingViewModels.AddRange(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(v => new TimelineEasingViewModel(null, v)));
|
||||
EasingViewModels.AddRange(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(v => new TimelineEasingViewModel(v, false)));
|
||||
TargetSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||
TargetSelectionViewModel.PropertySelected += TargetSelectionViewModelOnPropertySelected;
|
||||
_profileEditorService.ProfilePreviewUpdated += ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
@@ -229,9 +228,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
var currentValue = TargetSelectionViewModel.SelectedPropertyViewModel?.GetCurrentValue();
|
||||
if (currentValue == null && Registration.Property.PropertyType.IsValueType)
|
||||
currentValue = Activator.CreateInstance(Registration.Property.PropertyType);
|
||||
|
||||
TestInputValue = Convert.ChangeType(currentValue, Registration.Property.PropertyType);
|
||||
TestResultValue = DataBinding?.GetValue(TestInputValue);
|
||||
|
||||
TestInputValue = currentValue is TProperty testInputValue ? testInputValue : default;
|
||||
if (DataBinding != null)
|
||||
TestResultValue = DataBinding.GetValue(TestInputValue);
|
||||
else
|
||||
TestInputValue = default;
|
||||
}
|
||||
|
||||
private void UpdateModifierViewModels()
|
||||
@@ -268,4 +270,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
DataBinding.ModifiersUpdated -= DataBindingOnModifiersUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IDataBindingViewModel : IScreen, IDisposable
|
||||
{
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DataBindingsTabsView"
|
||||
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:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<TabControl ItemsSource="{Binding Tabs}" DisplayMemberPath="DisplayName" Style="{StaticResource MaterialDesignTabControl}">
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</UserControl>
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingsTabsViewModel : PropertyChangedBase
|
||||
{
|
||||
public DataBindingsTabsViewModel()
|
||||
{
|
||||
Tabs = new BindableCollection<DataBindingViewModel>();
|
||||
}
|
||||
|
||||
public BindableCollection<DataBindingViewModel> Tabs { get; set; }
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -3,14 +3,14 @@
|
||||
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.ProfileEditor.LayerProperties.DataBindings"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:DataBindingsViewModel}">
|
||||
<Grid>
|
||||
<!-- Use tabs for multiple properties only, only one of these VMs is set -->
|
||||
<ContentControl s:View.Model="{Binding DataBindingsTabsViewModel}" />
|
||||
<ContentControl s:View.Model="{Binding DataBindingViewModel}" />
|
||||
</Grid>
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<TabControl ItemsSource="{Binding Items}" DisplayMemberPath="DisplayName" Style="{StaticResource MaterialDesignTabControl}">
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</UserControl>
|
||||
+7
-38
@@ -6,58 +6,27 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingsViewModel : PropertyChangedBase, IDisposable
|
||||
public class DataBindingsViewModel<T> : Conductor<IDataBindingViewModel>.Collection.AllActive
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private DataBindingsTabsViewModel _dataBindingsTabsViewModel;
|
||||
private DataBindingViewModel _dataBindingViewModel;
|
||||
|
||||
public DataBindingsViewModel(BaseLayerProperty layerProperty, IDataBindingsVmFactory dataBindingsVmFactory)
|
||||
|
||||
public DataBindingsViewModel(LayerProperty<T> layerProperty, IDataBindingsVmFactory dataBindingsVmFactory)
|
||||
{
|
||||
_dataBindingsVmFactory = dataBindingsVmFactory;
|
||||
LayerProperty = layerProperty;
|
||||
Initialise();
|
||||
}
|
||||
|
||||
public BaseLayerProperty LayerProperty { get; }
|
||||
|
||||
public DataBindingViewModel DataBindingViewModel
|
||||
{
|
||||
get => _dataBindingViewModel;
|
||||
set => SetAndNotify(ref _dataBindingViewModel, value);
|
||||
}
|
||||
|
||||
public DataBindingsTabsViewModel DataBindingsTabsViewModel
|
||||
{
|
||||
get => _dataBindingsTabsViewModel;
|
||||
set => SetAndNotify(ref _dataBindingsTabsViewModel, value);
|
||||
}
|
||||
public LayerProperty<T> LayerProperty { get; }
|
||||
|
||||
private void Initialise()
|
||||
{
|
||||
DataBindingViewModel?.Dispose();
|
||||
DataBindingViewModel = null;
|
||||
DataBindingsTabsViewModel = null;
|
||||
|
||||
var registrations = LayerProperty.DataBindingRegistrations;
|
||||
if (registrations == null || registrations.Count == 0)
|
||||
return;
|
||||
var registrations = LayerProperty.GetAllDataBindingRegistrations();
|
||||
|
||||
// Create a data binding VM for each data bindable property. These VMs will be responsible for retrieving
|
||||
// and creating the actual data bindings
|
||||
if (registrations.Count == 1)
|
||||
DataBindingViewModel = _dataBindingsVmFactory.DataBindingViewModel(registrations.First());
|
||||
else
|
||||
{
|
||||
DataBindingsTabsViewModel = new DataBindingsTabsViewModel();
|
||||
foreach (var registration in registrations)
|
||||
DataBindingsTabsViewModel.Tabs.Add(_dataBindingsVmFactory.DataBindingViewModel(registration));
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DataBindingViewModel?.Dispose();
|
||||
foreach (var registration in registrations)
|
||||
ActivateItem(_dataBindingsVmFactory.DataBindingViewModel(registration));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user