mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Data bindings - Updated to new paths API
Data bindings - Fixed profile editor behavior
This commit is contained in:
1 parent
69ae42c039
commit
7610aeae4b
9 files changed
+264
-394
No files matched your search
+31
-6
@@ -20,10 +20,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
private bool _isEasingTimeEnabled;
|
||||
private DataBindingModeType _selectedDataBindingMode;
|
||||
private TimelineEasingViewModel _selectedEasingViewModel;
|
||||
|
||||
private bool _updating;
|
||||
private bool _applyTestResultToLayer;
|
||||
|
||||
private bool _updating;
|
||||
private bool _updatingTestResult;
|
||||
|
||||
public DataBindingViewModel(DataBindingRegistration<TLayerProperty, TProperty> registration,
|
||||
IProfileEditorService profileEditorService,
|
||||
@@ -74,7 +74,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
public bool ApplyTestResultToLayer
|
||||
{
|
||||
get => _applyTestResultToLayer;
|
||||
set => SetAndNotify(ref _applyTestResultToLayer, value);
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _applyTestResultToLayer, value)) return;
|
||||
_profileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
}
|
||||
|
||||
public TimelineEasingViewModel SelectedEasingViewModel
|
||||
@@ -111,6 +115,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
_updateTimer.Dispose();
|
||||
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
|
||||
|
||||
Registration.LayerProperty.Updated -= LayerPropertyOnUpdated;
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
@@ -119,6 +125,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
_updateTimer.Start();
|
||||
_updateTimer.Elapsed += OnUpdateTimerOnElapsed;
|
||||
Registration.LayerProperty.Updated += LayerPropertyOnUpdated;
|
||||
|
||||
CreateDataBindingModeModeViewModel();
|
||||
Update();
|
||||
@@ -216,14 +223,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
private void UpdateTestResult()
|
||||
{
|
||||
if (_updating || _updatingTestResult)
|
||||
return;
|
||||
|
||||
_updatingTestResult = true;
|
||||
|
||||
if (Registration.DataBinding == null || ActiveItem == null)
|
||||
{
|
||||
TestInputValue.UpdateValue(default);
|
||||
TestResultValue.UpdateValue(default);
|
||||
_updatingTestResult = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// While playing in preview data bindings aren't updated
|
||||
Registration.DataBinding.Update(0.04);
|
||||
|
||||
if (ActiveItem.SupportsTestValue)
|
||||
{
|
||||
TProperty currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty));
|
||||
@@ -235,11 +250,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
if (ApplyTestResultToLayer)
|
||||
{
|
||||
Registration.DataBinding.Apply();
|
||||
_profileEditorService.UpdateProfilePreview();
|
||||
// TODO: A bit crappy, the ProfileEditorService should really be doing this
|
||||
bool playing = ((Parent as Screen)?.Parent as LayerPropertiesViewModel)?.Playing ?? true;
|
||||
if (!playing)
|
||||
_profileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
_updatingTestResult = false;
|
||||
}
|
||||
|
||||
|
||||
private void EnableDataBinding()
|
||||
{
|
||||
if (Registration.DataBinding != null)
|
||||
@@ -264,6 +283,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
UpdateTestResult();
|
||||
}
|
||||
|
||||
private void LayerPropertyOnUpdated(object? sender, LayerPropertyEventArgs<TLayerProperty> e)
|
||||
{
|
||||
if (ApplyTestResultToLayer)
|
||||
Registration.DataBinding?.Apply();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IDataBindingViewModel : IScreen, IDisposable
|
||||
|
||||
+8
-9
@@ -94,10 +94,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
if (Modifier.ParameterType == ProfileRightSideType.Dynamic)
|
||||
{
|
||||
Type sourceType = Modifier.DirectDataBinding.GetSourceType();
|
||||
Modifier.UpdateParameter((Modifier.ModifierType.ParameterType ?? sourceType).GetDefault());
|
||||
Modifier.UpdateParameterStatic((Modifier.ModifierType.ParameterType ?? sourceType).GetDefault());
|
||||
}
|
||||
else
|
||||
Modifier.UpdateParameter(null, null);
|
||||
Modifier.UpdateParameterDynamic(null);
|
||||
|
||||
Update();
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
@@ -105,13 +105,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
private void ParameterSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
|
||||
{
|
||||
Modifier.UpdateParameter(e.DataModelPath.Target, e.DataModelPath.Path);
|
||||
Modifier.UpdateParameterDynamic(e.DataModelPath);
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
private void StaticInputViewModelOnValueUpdated(object sender, DataModelInputStaticEventArgs e)
|
||||
{
|
||||
Modifier.UpdateParameter(e.Value);
|
||||
Modifier.UpdateParameterStatic(e.Value);
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
@@ -166,11 +166,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
SelectedModifierType = Modifier.ModifierType;
|
||||
|
||||
// Parameter
|
||||
throw new NotImplementedException();
|
||||
// if (DynamicSelectionViewModel != null)
|
||||
// DynamicSelectionViewModel.PopulateSelectedPropertyViewModel(Modifier.ParameterDataModel, Modifier.ParameterPropertyPath);
|
||||
// else if (StaticInputViewModel != null)
|
||||
// StaticInputViewModel.Value = Modifier.ParameterStaticValue;
|
||||
if (DynamicSelectionViewModel != null)
|
||||
DynamicSelectionViewModel.ChangeDataModelPath(Modifier.ParameterPath);
|
||||
else if (StaticInputViewModel != null)
|
||||
StaticInputViewModel.Value = Modifier.ParameterStaticValue;
|
||||
}
|
||||
|
||||
private void ExecuteSelectModifierTypeCommand(object context)
|
||||
|
||||
+8
-7
@@ -56,18 +56,16 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
public void Update()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// TargetSelectionViewModel.PopulateSelectedPropertyViewModel(DirectDataBinding.SourceDataModel, DirectDataBinding.SourcePropertyPath);
|
||||
TargetSelectionViewModel.ChangeDataModelPath(DirectDataBinding.SourcePath);
|
||||
TargetSelectionViewModel.FilterTypes = new[] {DirectDataBinding.DataBinding.GetTargetType()};
|
||||
|
||||
CanAddModifier = DirectDataBinding.SourceDataModel != null;
|
||||
CanAddModifier = DirectDataBinding.SourcePath != null && DirectDataBinding.SourcePath.IsValid;
|
||||
UpdateModifierViewModels();
|
||||
}
|
||||
|
||||
public object GetTestValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// return TargetSelectionViewModel.SelectedPropertyViewModel?.GetCurrentValue();
|
||||
return DirectDataBinding.SourcePath?.GetValue();
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
@@ -114,8 +112,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
private void TargetSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// DirectDataBinding.UpdateSource(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.Path);
|
||||
DirectDataBinding.UpdateSource(e.DataModelPath);
|
||||
Update();
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
@@ -143,6 +140,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
modifierViewModel.Dispose();
|
||||
}
|
||||
|
||||
// Don't create children without a source or with an invalid source
|
||||
if (DirectDataBinding.SourcePath == null || !DirectDataBinding.SourcePath.IsValid)
|
||||
return;
|
||||
|
||||
// Add missing VMs
|
||||
foreach (DataBindingModifier<TLayerProperty, TProperty> modifier in DirectDataBinding.Modifiers)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user