mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Data bindings - Fixed internal easing state
Data bindings - Some UI improvements :) Data bindings - Added floor modifier Layer properties - Fixed new base values not applying
This commit is contained in:
1 parent
6b309cb1f3
commit
5d540530af
12 files changed
+148
-115
No files matched your search
+24
-26
@@ -37,7 +37,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
SelectModifierTypeCommand = new DelegateCommand(ExecuteSelectModifierTypeCommand);
|
||||
|
||||
// Initialize async, no need to wait for it
|
||||
Execute.PostToUIThread(Initialize);
|
||||
Execute.PostToUIThread(Update);
|
||||
}
|
||||
|
||||
public DelegateCommand SelectModifierTypeCommand { get; }
|
||||
@@ -62,30 +62,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
get => _staticInputViewModel;
|
||||
private set => SetAndNotify(ref _staticInputViewModel, value);
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
var sourceType = Modifier.DataBinding.GetSourceType();
|
||||
if (sourceType == null)
|
||||
throw new ArtemisUIException("Cannot initialize a data binding modifier VM for a data binding without a source");
|
||||
|
||||
if (Modifier.ParameterType == ProfileRightSideType.Dynamic)
|
||||
{
|
||||
StaticInputViewModel = null;
|
||||
DynamicSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||
DynamicSelectionViewModel.PropertySelected += ParameterSelectionViewModelOnPropertySelected;
|
||||
DynamicSelectionViewModel.FilterTypes = new[] {sourceType};
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicSelectionViewModel = null;
|
||||
StaticInputViewModel = _dataModelUIService.GetStaticInputViewModel(sourceType);
|
||||
StaticInputViewModel.ValueUpdated += StaticInputViewModelOnValueUpdated;
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
private void ParameterSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
|
||||
{
|
||||
Modifier.UpdateParameter(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.PropertyPath);
|
||||
@@ -99,6 +76,27 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
private void Update()
|
||||
{
|
||||
var sourceType = Modifier.DataBinding.GetSourceType();
|
||||
if (sourceType == null)
|
||||
throw new ArtemisUIException("Cannot use a data binding modifier VM for a data binding without a source");
|
||||
|
||||
if (Modifier.ModifierType == null || !Modifier.ModifierType.SupportsParameter)
|
||||
{
|
||||
StaticInputViewModel = null;
|
||||
DynamicSelectionViewModel = null;
|
||||
}
|
||||
else if (Modifier.ParameterType == ProfileRightSideType.Dynamic)
|
||||
{
|
||||
StaticInputViewModel = null;
|
||||
DynamicSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||
DynamicSelectionViewModel.PropertySelected += ParameterSelectionViewModelOnPropertySelected;
|
||||
DynamicSelectionViewModel.FilterTypes = new[] { sourceType };
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicSelectionViewModel = null;
|
||||
StaticInputViewModel = _dataModelUIService.GetStaticInputViewModel(sourceType);
|
||||
StaticInputViewModel.ValueUpdated += StaticInputViewModelOnValueUpdated;
|
||||
}
|
||||
|
||||
// Modifier type
|
||||
ModifierTypes.Clear();
|
||||
@@ -135,7 +133,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
else
|
||||
Modifier.UpdateParameter(null, null);
|
||||
|
||||
Initialize();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
-29
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline;
|
||||
@@ -11,21 +10,20 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingViewModel : PropertyChangedBase
|
||||
public class DataBindingViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly Timer _updateTimer;
|
||||
private DataBinding _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 TimelineEasingViewModel _selectedEasingViewModel;
|
||||
private DataBindingMode _selectedDataBindingMode;
|
||||
private int _easingTime;
|
||||
private bool _isEasingTimeEnabled;
|
||||
private bool _updating;
|
||||
|
||||
public DataBindingViewModel(DataBindingRegistration registration,
|
||||
@@ -37,7 +35,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
_profileEditorService = profileEditorService;
|
||||
_dataModelUIService = dataModelUIService;
|
||||
_dataBindingsVmFactory = dataBindingsVmFactory;
|
||||
_updateTimer = new Timer(500);
|
||||
|
||||
DisplayName = Registration.Property.Name.ToUpper();
|
||||
|
||||
@@ -181,18 +178,16 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
EasingViewModels.AddRange(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(v => new TimelineEasingViewModel(null, v)));
|
||||
TargetSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||
TargetSelectionViewModel.PropertySelected += TargetSelectionViewModelOnPropertySelected;
|
||||
_profileEditorService.ProfilePreviewUpdated += ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
|
||||
Update();
|
||||
|
||||
_updateTimer.Start();
|
||||
_updateTimer.Elapsed += OnUpdateTimerOnElapsed;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_updating)
|
||||
return;
|
||||
|
||||
|
||||
if (DataBinding == null)
|
||||
{
|
||||
TargetSelectionViewModel.IsEnabled = false;
|
||||
@@ -201,7 +196,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
}
|
||||
|
||||
_updating = true;
|
||||
|
||||
|
||||
SelectedDataBindingMode = DataBinding.Mode;
|
||||
EasingTime = (int) DataBinding.EasingTime.TotalMilliseconds;
|
||||
SelectedEasingViewModel = EasingViewModels.First(vm => vm.EasingFunction == DataBinding.EasingFunction);
|
||||
@@ -229,22 +224,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
Update();
|
||||
}
|
||||
|
||||
private void DataBindingOnModifiersUpdated(object sender, EventArgs e)
|
||||
{
|
||||
UpdateModifierViewModels();
|
||||
}
|
||||
|
||||
private void TargetSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
|
||||
{
|
||||
DataBinding.UpdateSource(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.PropertyPath);
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
UpdateTestResult();
|
||||
}
|
||||
|
||||
private void UpdateTestResult()
|
||||
{
|
||||
var currentValue = TargetSelectionViewModel.SelectedPropertyViewModel?.GetCurrentValue();
|
||||
@@ -264,5 +243,29 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
foreach (var dataBindingModifier in DataBinding.Modifiers)
|
||||
ModifierViewModels.Add(_dataBindingsVmFactory.DataBindingModifierViewModel(dataBindingModifier));
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnProfilePreviewUpdated(object sender, EventArgs e)
|
||||
{
|
||||
UpdateTestResult();
|
||||
}
|
||||
|
||||
private void DataBindingOnModifiersUpdated(object sender, EventArgs e)
|
||||
{
|
||||
UpdateModifierViewModels();
|
||||
}
|
||||
|
||||
private void TargetSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
|
||||
{
|
||||
DataBinding.UpdateSource(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.PropertyPath);
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated;
|
||||
TargetSelectionViewModel.PropertySelected -= TargetSelectionViewModelOnPropertySelected;
|
||||
if (DataBinding != null)
|
||||
DataBinding.ModifiersUpdated -= DataBindingOnModifiersUpdated;
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-2
@@ -1,11 +1,12 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingsViewModel : PropertyChangedBase
|
||||
public class DataBindingsViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private DataBindingsTabsViewModel _dataBindingsTabsViewModel;
|
||||
@@ -34,6 +35,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
private void Initialise()
|
||||
{
|
||||
DataBindingViewModel?.Dispose();
|
||||
DataBindingViewModel = null;
|
||||
DataBindingsTabsViewModel = null;
|
||||
|
||||
@@ -52,5 +54,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
DataBindingsTabsViewModel.Tabs.Add(_dataBindingsVmFactory.DataBindingViewModel(registration));
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DataBindingViewModel?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,6 +204,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
MainTimelineSegmentViewModel = null;
|
||||
EndTimelineSegmentViewModel?.Dispose();
|
||||
EndTimelineSegmentViewModel = null;
|
||||
DataBindingsViewModel?.Dispose();
|
||||
DataBindingsViewModel = null;
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
@@ -241,6 +243,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
if (ProfileEditorService.SelectedDataBinding != null)
|
||||
{
|
||||
RightSideIndex = 1;
|
||||
DataBindingsViewModel?.Dispose();
|
||||
DataBindingsViewModel = _dataBindingsVmFactory.DataBindingsViewModel(ProfileEditorService.SelectedDataBinding);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user