diff --git a/src/Avalonia/Artemis.UI.Shared/Services/ProfileEditor/Commands/UpdateLayerProperty.cs b/src/Avalonia/Artemis.UI.Shared/Services/ProfileEditor/Commands/UpdateLayerProperty.cs index d4dc4a800..d6179bb4e 100644 --- a/src/Avalonia/Artemis.UI.Shared/Services/ProfileEditor/Commands/UpdateLayerProperty.cs +++ b/src/Avalonia/Artemis.UI.Shared/Services/ProfileEditor/Commands/UpdateLayerProperty.cs @@ -23,6 +23,8 @@ public class UpdateLayerProperty : IProfileEditorCommand _originalValue = layerProperty.CurrentValue; _newValue = newValue; _time = time; + + DisplayName = $"Update {_layerProperty.PropertyDescription.Name ?? "property"}"; } /// @@ -34,17 +36,27 @@ public class UpdateLayerProperty : IProfileEditorCommand _originalValue = originalValue; _newValue = newValue; _time = time; + + DisplayName = $"Update {_layerProperty.PropertyDescription.Name ?? "property"}"; } #region Implementation of IProfileEditorCommand /// - public string DisplayName => $"Update {_layerProperty.PropertyDescription.Name ?? "property"}"; + public string DisplayName { get; private set; } /// public void Execute() { - _newKeyframe = _layerProperty.SetCurrentValue(_newValue, _time); + // If there was already a keyframe from a previous execute that was undone, put it back + if (_newKeyframe != null) + _layerProperty.AddKeyframe(_newKeyframe); + else + { + _newKeyframe = _layerProperty.SetCurrentValue(_newValue, _time); + if (_newKeyframe != null) + DisplayName = $"Add {_layerProperty.PropertyDescription.Name ?? "property"} keyframe"; + } } /// diff --git a/src/Avalonia/Artemis.UI/Converters/DoubleToGridLengthConverter.cs b/src/Avalonia/Artemis.UI/Converters/DoubleToGridLengthConverter.cs new file mode 100644 index 000000000..f8077eb57 --- /dev/null +++ b/src/Avalonia/Artemis.UI/Converters/DoubleToGridLengthConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Globalization; +using Avalonia.Controls; +using Avalonia.Data.Converters; + +namespace Artemis.UI.Converters; + +public class DoubleToGridLengthConverter : IValueConverter +{ + #region Implementation of IValueConverter + + /// + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is double doubleValue) + return new GridLength(doubleValue, GridUnitType.Pixel); + return new GridLength(1, GridUnitType.Star); + } + + /// + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is GridLength gridLength) + return gridLength.Value; + return 0.0; + } + + #endregion +} \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml index 4fe95180c..5b694742c 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml @@ -4,12 +4,21 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:Artemis.UI.Controls" xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + xmlns:converters="clr-namespace:Artemis.UI.Converters" + mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="350" x:Class="Artemis.UI.Screens.ProfileEditor.Properties.PropertiesView"> - + + + + + + + + + @@ -97,7 +106,7 @@ - _cachedViewModels; private readonly ILayerPropertyVmFactory _layerPropertyVmFactory; private readonly IProfileEditorService _profileEditorService; + private readonly ISettingsService _settingsService; private ObservableAsPropertyHelper? _pixelsPerSecond; private ObservableAsPropertyHelper? _profileElement; /// - public PropertiesViewModel(IProfileEditorService profileEditorService, ILayerPropertyVmFactory layerPropertyVmFactory, PlaybackViewModel playbackViewModel) + public PropertiesViewModel(IProfileEditorService profileEditorService, ISettingsService settingsService, ILayerPropertyVmFactory layerPropertyVmFactory, PlaybackViewModel playbackViewModel) { _profileEditorService = profileEditorService; + _settingsService = settingsService; _layerPropertyVmFactory = layerPropertyVmFactory; - PropertyGroupViewModels = new ObservableCollection(); _cachedViewModels = new Dictionary(); + PropertyGroupViewModels = new ObservableCollection(); PlaybackViewModel = playbackViewModel; TimelineViewModel = layerPropertyVmFactory.TimelineViewModel(PropertyGroupViewModels); @@ -54,19 +57,22 @@ public class PropertiesViewModel : ActivatableViewModelBase { _profileElement = profileEditorService.ProfileElement.ToProperty(this, vm => vm.ProfileElement).DisposeWith(d); _pixelsPerSecond = profileEditorService.PixelsPerSecond.ToProperty(this, vm => vm.PixelsPerSecond).DisposeWith(d); + Disposable.Create(() => _settingsService.SaveAllSettings()).DisposeWith(d); }); this.WhenAnyValue(vm => vm.ProfileElement).Subscribe(_ => UpdateGroups()); } + public ObservableCollection PropertyGroupViewModels { get; } public PlaybackViewModel PlaybackViewModel { get; } public TimelineViewModel TimelineViewModel { get; } + public RenderProfileElement? ProfileElement => _profileElement?.Value; public Layer? Layer => _profileElement?.Value as Layer; + public int PixelsPerSecond => _pixelsPerSecond?.Value ?? 0; public IObservable Playing => _profileEditorService.Playing; - - public ObservableCollection PropertyGroupViewModels { get; } - + public PluginSetting PropertiesTreeWidth => _settingsService.GetSetting("ProfileEditor.PropertiesTreeWidth", 500.0); + private void UpdateGroups() { if (ProfileElement == null) diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml index f0a87752a..056002025 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml @@ -4,8 +4,12 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" + xmlns:converters="clr-namespace:Artemis.UI.Converters" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"> + + + @@ -35,13 +39,23 @@ - + + + + + + - + + + + + + @@ -73,7 +87,12 @@ - + + + + + + diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs index e75dfb043..81919ca36 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Reactive.Disposables; using Artemis.Core; +using Artemis.Core.Services; using Artemis.UI.Screens.ProfileEditor.MenuBar; using Artemis.UI.Screens.ProfileEditor.ProfileTree; using Artemis.UI.Screens.ProfileEditor.Properties; @@ -14,13 +15,14 @@ namespace Artemis.UI.Screens.ProfileEditor { public class ProfileEditorViewModel : MainScreenViewModel { + private readonly ISettingsService _settingsService; private ObservableAsPropertyHelper? _profileConfiguration; private ObservableAsPropertyHelper? _history; /// public ProfileEditorViewModel(IScreen hostScreen, - IKernel kernel, IProfileEditorService profileEditorService, + ISettingsService settingsService, VisualEditorViewModel visualEditorViewModel, ProfileTreeViewModel profileTreeViewModel, ProfileEditorTitleBarViewModel profileEditorTitleBarViewModel, @@ -29,6 +31,7 @@ namespace Artemis.UI.Screens.ProfileEditor StatusBarViewModel statusBarViewModel) : base(hostScreen, "profile-editor") { + _settingsService = settingsService; VisualEditorViewModel = visualEditorViewModel; ProfileTreeViewModel = profileTreeViewModel; PropertiesViewModel = propertiesViewModel; @@ -51,6 +54,9 @@ namespace Artemis.UI.Screens.ProfileEditor public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value; public ProfileEditorHistory? History => _history?.Value; + public PluginSetting TreeWidth => _settingsService.GetSetting("ProfileEditor.TreeWidth", 350.0); + public PluginSetting ConditionsHeight => _settingsService.GetSetting("ProfileEditor.ConditionsHeight", 300.0); + public PluginSetting PropertiesHeight => _settingsService.GetSetting("ProfileEditor.PropertiesHeight", 300.0); public void OpenUrl(string url) {