mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile editor - Store panel sizes as settings
This commit is contained in:
parent
642823add5
commit
76ef542e18
@ -23,6 +23,8 @@ public class UpdateLayerProperty<T> : IProfileEditorCommand
|
|||||||
_originalValue = layerProperty.CurrentValue;
|
_originalValue = layerProperty.CurrentValue;
|
||||||
_newValue = newValue;
|
_newValue = newValue;
|
||||||
_time = time;
|
_time = time;
|
||||||
|
|
||||||
|
DisplayName = $"Update {_layerProperty.PropertyDescription.Name ?? "property"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -34,17 +36,27 @@ public class UpdateLayerProperty<T> : IProfileEditorCommand
|
|||||||
_originalValue = originalValue;
|
_originalValue = originalValue;
|
||||||
_newValue = newValue;
|
_newValue = newValue;
|
||||||
_time = time;
|
_time = time;
|
||||||
|
|
||||||
|
DisplayName = $"Update {_layerProperty.PropertyDescription.Name ?? "property"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IProfileEditorCommand
|
#region Implementation of IProfileEditorCommand
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string DisplayName => $"Update {_layerProperty.PropertyDescription.Name ?? "property"}";
|
public string DisplayName { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Execute()
|
public void Execute()
|
||||||
|
{
|
||||||
|
// 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);
|
_newKeyframe = _layerProperty.SetCurrentValue(_newValue, _time);
|
||||||
|
if (_newKeyframe != null)
|
||||||
|
DisplayName = $"Add {_layerProperty.PropertyDescription.Name ?? "property"} keyframe";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value is GridLength gridLength)
|
||||||
|
return gridLength.Value;
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@ -4,12 +4,21 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:controls="clr-namespace:Artemis.UI.Controls"
|
xmlns:controls="clr-namespace:Artemis.UI.Controls"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties"
|
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">
|
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.PropertiesView">
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<StyleInclude Source="/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/Segment.axaml" />
|
<StyleInclude Source="/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/Segment.axaml" />
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
<Grid ColumnDefinitions="*,Auto,*" Name="ContainerGrid">
|
<UserControl.Resources>
|
||||||
|
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter"></converters:DoubleToGridLengthConverter>
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid Name="ContainerGrid">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="{Binding PropertiesTreeWidth.Value, Mode=TwoWay, Converter={StaticResource DoubleToGridLengthConverter}}" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<Grid RowDefinitions="48,*">
|
<Grid RowDefinitions="48,*">
|
||||||
<ContentControl Grid.Row="0" Content="{Binding PlaybackViewModel}" />
|
<ContentControl Grid.Row="0" Content="{Binding PlaybackViewModel}" />
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ using System.Reactive.Linq;
|
|||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.LayerBrushes;
|
using Artemis.Core.LayerBrushes;
|
||||||
using Artemis.Core.LayerEffects;
|
using Artemis.Core.LayerEffects;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Ninject.Factories;
|
using Artemis.UI.Ninject.Factories;
|
||||||
using Artemis.UI.Screens.ProfileEditor.Playback;
|
using Artemis.UI.Screens.ProfileEditor.Playback;
|
||||||
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
|
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
|
||||||
@ -22,16 +23,18 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
|||||||
private readonly Dictionary<LayerPropertyGroup, PropertyGroupViewModel> _cachedViewModels;
|
private readonly Dictionary<LayerPropertyGroup, PropertyGroupViewModel> _cachedViewModels;
|
||||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
|
private readonly ISettingsService _settingsService;
|
||||||
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
||||||
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public PropertiesViewModel(IProfileEditorService profileEditorService, ILayerPropertyVmFactory layerPropertyVmFactory, PlaybackViewModel playbackViewModel)
|
public PropertiesViewModel(IProfileEditorService profileEditorService, ISettingsService settingsService, ILayerPropertyVmFactory layerPropertyVmFactory, PlaybackViewModel playbackViewModel)
|
||||||
{
|
{
|
||||||
_profileEditorService = profileEditorService;
|
_profileEditorService = profileEditorService;
|
||||||
|
_settingsService = settingsService;
|
||||||
_layerPropertyVmFactory = layerPropertyVmFactory;
|
_layerPropertyVmFactory = layerPropertyVmFactory;
|
||||||
PropertyGroupViewModels = new ObservableCollection<PropertyGroupViewModel>();
|
|
||||||
_cachedViewModels = new Dictionary<LayerPropertyGroup, PropertyGroupViewModel>();
|
_cachedViewModels = new Dictionary<LayerPropertyGroup, PropertyGroupViewModel>();
|
||||||
|
PropertyGroupViewModels = new ObservableCollection<PropertyGroupViewModel>();
|
||||||
PlaybackViewModel = playbackViewModel;
|
PlaybackViewModel = playbackViewModel;
|
||||||
TimelineViewModel = layerPropertyVmFactory.TimelineViewModel(PropertyGroupViewModels);
|
TimelineViewModel = layerPropertyVmFactory.TimelineViewModel(PropertyGroupViewModels);
|
||||||
|
|
||||||
@ -54,18 +57,21 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
|||||||
{
|
{
|
||||||
_profileElement = profileEditorService.ProfileElement.ToProperty(this, vm => vm.ProfileElement).DisposeWith(d);
|
_profileElement = profileEditorService.ProfileElement.ToProperty(this, vm => vm.ProfileElement).DisposeWith(d);
|
||||||
_pixelsPerSecond = profileEditorService.PixelsPerSecond.ToProperty(this, vm => vm.PixelsPerSecond).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());
|
this.WhenAnyValue(vm => vm.ProfileElement).Subscribe(_ => UpdateGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<PropertyGroupViewModel> PropertyGroupViewModels { get; }
|
||||||
public PlaybackViewModel PlaybackViewModel { get; }
|
public PlaybackViewModel PlaybackViewModel { get; }
|
||||||
public TimelineViewModel TimelineViewModel { get; }
|
public TimelineViewModel TimelineViewModel { get; }
|
||||||
|
|
||||||
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
||||||
public Layer? Layer => _profileElement?.Value as Layer;
|
public Layer? Layer => _profileElement?.Value as Layer;
|
||||||
|
|
||||||
public int PixelsPerSecond => _pixelsPerSecond?.Value ?? 0;
|
public int PixelsPerSecond => _pixelsPerSecond?.Value ?? 0;
|
||||||
public IObservable<bool> Playing => _profileEditorService.Playing;
|
public IObservable<bool> Playing => _profileEditorService.Playing;
|
||||||
|
public PluginSetting<double> PropertiesTreeWidth => _settingsService.GetSetting("ProfileEditor.PropertiesTreeWidth", 500.0);
|
||||||
public ObservableCollection<PropertyGroupViewModel> PropertyGroupViewModels { get; }
|
|
||||||
|
|
||||||
private void UpdateGroups()
|
private void UpdateGroups()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,8 +4,12 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
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"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView">
|
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter"></converters:DoubleToGridLengthConverter>
|
||||||
|
</UserControl.Resources>
|
||||||
<UserControl.KeyBindings>
|
<UserControl.KeyBindings>
|
||||||
<KeyBinding Command="{Binding History.Undo}" Gesture="Ctrl+Z"></KeyBinding>
|
<KeyBinding Command="{Binding History.Undo}" Gesture="Ctrl+Z"></KeyBinding>
|
||||||
<KeyBinding Command="{Binding History.Redo}" Gesture="Ctrl+Y"></KeyBinding>
|
<KeyBinding Command="{Binding History.Redo}" Gesture="Ctrl+Y"></KeyBinding>
|
||||||
@ -35,13 +39,23 @@
|
|||||||
<Setter Property="Margin" Value="0 41 4 4"></Setter>
|
<Setter Property="Margin" Value="0 41 4 4"></Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
<Grid ColumnDefinitions="4*,Auto,*" Classes="editor-grid">
|
<Grid Classes="editor-grid">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="{Binding TreeWidth.Value, Mode=TwoWay, Converter={StaticResource DoubleToGridLengthConverter}}"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ContentControl Content="{Binding MenuBarViewModel}"></ContentControl>
|
<ContentControl Content="{Binding MenuBarViewModel}"></ContentControl>
|
||||||
<Grid Grid.Column="0" RowDefinitions="3*,Auto,*">
|
<Grid Grid.Row="0" Grid.Column="0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="{Binding PropertiesHeight.Value, Mode=TwoWay, Converter={StaticResource DoubleToGridLengthConverter}}"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<Border Grid.Row="0" Classes="card" Padding="0" Margin="4 0 4 4" ClipToBounds="True">
|
<Border Grid.Row="0" Classes="card" Padding="0" Margin="4 0 4 4" ClipToBounds="True">
|
||||||
<Grid ColumnDefinitions="Auto,*">
|
<Grid ColumnDefinitions="Auto,*">
|
||||||
<Border Grid.Column="0" Background="{DynamicResource CardStrokeColorDefaultSolidBrush}">
|
<Border Grid.Column="0" Background="{DynamicResource CardStrokeColorDefaultSolidBrush}">
|
||||||
@ -73,7 +87,12 @@
|
|||||||
|
|
||||||
<GridSplitter Grid.Row="0" Grid.Column="1" Classes="editor-grid-splitter-vertical" />
|
<GridSplitter Grid.Row="0" Grid.Column="1" Classes="editor-grid-splitter-vertical" />
|
||||||
|
|
||||||
<Grid Grid.Row="0" Grid.Column="2" RowDefinitions="*,Auto,*">
|
<Grid Grid.Row="0" Grid.Column="2">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="{Binding ConditionsHeight.Value, Mode=TwoWay, Converter={StaticResource DoubleToGridLengthConverter}}"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
<Border Grid.Row="0" Classes="card card-condensed" Margin="4 0 4 4">
|
<Border Grid.Row="0" Classes="card card-condensed" Margin="4 0 4 4">
|
||||||
<ContentControl Content="{Binding ProfileTreeViewModel}" />
|
<ContentControl Content="{Binding ProfileTreeViewModel}" />
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Screens.ProfileEditor.MenuBar;
|
using Artemis.UI.Screens.ProfileEditor.MenuBar;
|
||||||
using Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
using Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||||
using Artemis.UI.Screens.ProfileEditor.Properties;
|
using Artemis.UI.Screens.ProfileEditor.Properties;
|
||||||
@ -14,13 +15,14 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
{
|
{
|
||||||
public class ProfileEditorViewModel : MainScreenViewModel
|
public class ProfileEditorViewModel : MainScreenViewModel
|
||||||
{
|
{
|
||||||
|
private readonly ISettingsService _settingsService;
|
||||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||||
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public ProfileEditorViewModel(IScreen hostScreen,
|
public ProfileEditorViewModel(IScreen hostScreen,
|
||||||
IKernel kernel,
|
|
||||||
IProfileEditorService profileEditorService,
|
IProfileEditorService profileEditorService,
|
||||||
|
ISettingsService settingsService,
|
||||||
VisualEditorViewModel visualEditorViewModel,
|
VisualEditorViewModel visualEditorViewModel,
|
||||||
ProfileTreeViewModel profileTreeViewModel,
|
ProfileTreeViewModel profileTreeViewModel,
|
||||||
ProfileEditorTitleBarViewModel profileEditorTitleBarViewModel,
|
ProfileEditorTitleBarViewModel profileEditorTitleBarViewModel,
|
||||||
@ -29,6 +31,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
StatusBarViewModel statusBarViewModel)
|
StatusBarViewModel statusBarViewModel)
|
||||||
: base(hostScreen, "profile-editor")
|
: base(hostScreen, "profile-editor")
|
||||||
{
|
{
|
||||||
|
_settingsService = settingsService;
|
||||||
VisualEditorViewModel = visualEditorViewModel;
|
VisualEditorViewModel = visualEditorViewModel;
|
||||||
ProfileTreeViewModel = profileTreeViewModel;
|
ProfileTreeViewModel = profileTreeViewModel;
|
||||||
PropertiesViewModel = propertiesViewModel;
|
PropertiesViewModel = propertiesViewModel;
|
||||||
@ -51,6 +54,9 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
|
|
||||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||||
public ProfileEditorHistory? History => _history?.Value;
|
public ProfileEditorHistory? History => _history?.Value;
|
||||||
|
public PluginSetting<double> TreeWidth => _settingsService.GetSetting("ProfileEditor.TreeWidth", 350.0);
|
||||||
|
public PluginSetting<double> ConditionsHeight => _settingsService.GetSetting("ProfileEditor.ConditionsHeight", 300.0);
|
||||||
|
public PluginSetting<double> PropertiesHeight => _settingsService.GetSetting("ProfileEditor.PropertiesHeight", 300.0);
|
||||||
|
|
||||||
public void OpenUrl(string url)
|
public void OpenUrl(string url)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user