mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profile editor - Added F5 previewing
Core - Performance fixes
This commit is contained in:
1 parent
5b183d3010
commit
8c7bbc3f0f
11 files changed
+180
-82
No files matched your search
@@ -5,6 +5,7 @@
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Controls"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="350"
|
||||
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.PropertiesView"
|
||||
x:DataType="local:PropertiesViewModel">
|
||||
|
||||
@@ -31,6 +31,7 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
||||
private ObservableAsPropertyHelper<ILayerProperty?>? _layerProperty;
|
||||
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
||||
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
||||
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
|
||||
|
||||
/// <inheritdoc />
|
||||
public PropertiesViewModel(IProfileEditorService profileEditorService,
|
||||
@@ -55,6 +56,7 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
||||
_profileElement = profileEditorService.ProfileElement.ToProperty(this, vm => vm.ProfileElement).DisposeWith(d);
|
||||
_pixelsPerSecond = profileEditorService.PixelsPerSecond.ToProperty(this, vm => vm.PixelsPerSecond).DisposeWith(d);
|
||||
_layerProperty = profileEditorService.LayerProperty.ToProperty(this, vm => vm.LayerProperty).DisposeWith(d);
|
||||
_suspendedEditing = profileEditorService.SuspendedEditing.ToProperty(this, vm => vm.SuspendedEditing).DisposeWith(d);
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
_settingsService.SaveAllSettings();
|
||||
@@ -94,11 +96,13 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
||||
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
||||
public Layer? Layer => _profileElement?.Value as Layer;
|
||||
public ILayerProperty? LayerProperty => _layerProperty?.Value;
|
||||
public bool SuspendedEditing => _suspendedEditing?.Value ?? false;
|
||||
|
||||
public int PixelsPerSecond => _pixelsPerSecond?.Value ?? 0;
|
||||
public IObservable<bool> Playing => _profileEditorService.Playing;
|
||||
public PluginSetting<double> PropertiesTreeWidth => _settingsService.GetSetting("ProfileEditor.PropertiesTreeWidth", 500.0);
|
||||
|
||||
|
||||
private void UpdatePropertyGroups()
|
||||
{
|
||||
if (ProfileElement == null)
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
</ItemsControl>
|
||||
|
||||
<!-- The middle layer contains visualizers -->
|
||||
<ItemsControl Items="{CompiledBinding Visualizers}" ClipToBounds="False">
|
||||
<ItemsControl Items="{CompiledBinding Visualizers}" ClipToBounds="False" IsVisible="{CompiledBinding !SuspendedEditing}">
|
||||
<ItemsControl.Styles>
|
||||
<Style Selector="ContentPresenter">
|
||||
<Setter Property="Canvas.Left" Value="{Binding X}" />
|
||||
@@ -74,7 +74,7 @@
|
||||
</ItemsControl>
|
||||
|
||||
<!-- The top layer contains tools -->
|
||||
<ItemsControl Items="{CompiledBinding Tools}" ClipToBounds="False">
|
||||
<ItemsControl Items="{CompiledBinding Tools}" ClipToBounds="False" IsVisible="{CompiledBinding !SuspendedEditing}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid />
|
||||
|
||||
@@ -22,6 +22,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
|
||||
private readonly SourceList<IVisualizerViewModel> _visualizers;
|
||||
private readonly IProfileEditorVmFactory _vmFactory;
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
|
||||
private ReadOnlyObservableCollection<IToolViewModel> _tools;
|
||||
|
||||
public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService, IProfileEditorVmFactory vmFactory)
|
||||
@@ -38,12 +39,10 @@ public class VisualEditorViewModel : ActivatableViewModelBase
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_profileConfiguration = profileEditorService.ProfileConfiguration
|
||||
.ToProperty(this, vm => vm.ProfileConfiguration)
|
||||
.DisposeWith(d);
|
||||
profileEditorService.ProfileConfiguration
|
||||
.Subscribe(CreateVisualizers)
|
||||
.DisposeWith(d);
|
||||
_profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d);
|
||||
_suspendedEditing = profileEditorService.SuspendedEditing.ToProperty(this, vm => vm.SuspendedEditing).DisposeWith(d);
|
||||
profileEditorService.ProfileConfiguration.Subscribe(CreateVisualizers).DisposeWith(d);
|
||||
|
||||
profileEditorService.Tools
|
||||
.Connect()
|
||||
.AutoRefreshOnObservable(t => t.WhenAnyValue(vm => vm.IsSelected)).Filter(t => t.IsSelected).Bind(out ReadOnlyObservableCollection<IToolViewModel> tools)
|
||||
@@ -71,6 +70,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
public bool SuspendedEditing => _suspendedEditing?.Value ?? false;
|
||||
|
||||
public ObservableCollection<ArtemisDevice> Devices { get; }
|
||||
public ReadOnlyObservableCollection<IVisualizerViewModel> Visualizers { get; }
|
||||
|
||||
@@ -13,9 +13,19 @@
|
||||
<UserControl.Resources>
|
||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter"></converters:DoubleToGridLengthConverter>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Styles>
|
||||
<Style Selector="Border.suspended-editing">
|
||||
<Setter Property="Margin" Value="-10" />
|
||||
<Setter Property="Background" Value="{DynamicResource SmokeFillColorDefault}" />
|
||||
<Setter Property="IsVisible" Value="{CompiledBinding SuspendedEditing}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource CardCornerRadius}" />
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<UserControl.KeyBindings>
|
||||
<KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5"></KeyBinding>
|
||||
<KeyBinding Command="{CompiledBinding ToggleAutoSuspend}" Gesture="Shift+F5"></KeyBinding>
|
||||
</UserControl.KeyBindings>
|
||||
<UserControl.Styles>
|
||||
<Style Selector="GridSplitter.editor-grid-splitter-vertical">
|
||||
@@ -78,7 +88,23 @@
|
||||
<GridSplitter Grid.Row="1" Classes="editor-grid-splitter-horizontal" />
|
||||
|
||||
<Border Grid.Row="2" Classes="card card-condensed" Margin="4" Padding="0" ClipToBounds="True">
|
||||
<ContentControl Content="{CompiledBinding PropertiesViewModel}" />
|
||||
<Panel>
|
||||
<ContentControl Content="{CompiledBinding PropertiesViewModel}" />
|
||||
<Border Classes="suspended-editing">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="16">
|
||||
<avalonia:MaterialIcon Kind="TimerOffOutline" Width="125" Height="125" HorizontalAlignment="Center" />
|
||||
<TextBlock Classes="h4" TextWrapping="Wrap" HorizontalAlignment="Center" Margin="0 10">
|
||||
Timeline suspended
|
||||
</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center">
|
||||
The profile is currently running in normal mode and the timeline cannot be edited.
|
||||
</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center">
|
||||
Press F5 to switch between editor mode and normal mode. Auto-switching can be disabled in the run menu.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Panel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -91,13 +117,19 @@
|
||||
<RowDefinition Height="{CompiledBinding ConditionsHeight.Value, Mode=TwoWay, Converter={StaticResource DoubleToGridLengthConverter}}" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" Classes="card card-condensed" Margin="4 0 4 4">
|
||||
<ContentControl Content="{CompiledBinding ProfileTreeViewModel}" />
|
||||
<Panel>
|
||||
<ContentControl Content="{CompiledBinding ProfileTreeViewModel}" />
|
||||
<Border Classes="suspended-editing" />
|
||||
</Panel>
|
||||
</Border>
|
||||
|
||||
<GridSplitter Grid.Row="1" Classes="editor-grid-splitter-horizontal" />
|
||||
|
||||
<Border Grid.Row="2" Classes="card card-condensed" Margin="4">
|
||||
<ContentControl Content="{CompiledBinding DisplayConditionScriptViewModel}"></ContentControl>
|
||||
<Panel>
|
||||
<ContentControl Content="{CompiledBinding DisplayConditionScriptViewModel}"></ContentControl>
|
||||
<Border Classes="suspended-editing" />
|
||||
</Panel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
@@ -17,9 +18,11 @@ namespace Artemis.UI.Screens.ProfileEditor;
|
||||
|
||||
public class ProfileEditorViewModel : MainScreenViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
|
||||
private ReadOnlyObservableCollection<IToolViewModel>? _tools;
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -34,6 +37,7 @@ public class ProfileEditorViewModel : MainScreenViewModel
|
||||
StatusBarViewModel statusBarViewModel)
|
||||
: base(hostScreen, "profile-editor")
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_settingsService = settingsService;
|
||||
VisualEditorViewModel = visualEditorViewModel;
|
||||
ProfileTreeViewModel = profileTreeViewModel;
|
||||
@@ -41,11 +45,12 @@ public class ProfileEditorViewModel : MainScreenViewModel
|
||||
DisplayConditionScriptViewModel = displayConditionScriptViewModel;
|
||||
StatusBarViewModel = statusBarViewModel;
|
||||
TitleBarViewModel = profileEditorTitleBarViewModel;
|
||||
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d);
|
||||
_history = profileEditorService.History.ToProperty(this, vm => vm.History).DisposeWith(d);
|
||||
_suspendedEditing = profileEditorService.SuspendedEditing.ToProperty(this, vm => vm.SuspendedEditing).DisposeWith(d);
|
||||
profileEditorService.Tools.Connect()
|
||||
.Filter(t => t.ShowInToolbar)
|
||||
.Sort(SortExpressionComparer<IToolViewModel>.Ascending(vm => vm.Order))
|
||||
@@ -54,6 +59,9 @@ public class ProfileEditorViewModel : MainScreenViewModel
|
||||
.DisposeWith(d);
|
||||
Tools = tools;
|
||||
});
|
||||
|
||||
ToggleSuspend = ReactiveCommand.Create(ExecuteToggleSuspend);
|
||||
ToggleAutoSuspend = ReactiveCommand.Create(ExecuteToggleAutoSuspend);
|
||||
}
|
||||
|
||||
public VisualEditorViewModel VisualEditorViewModel { get; }
|
||||
@@ -70,12 +78,24 @@ public class ProfileEditorViewModel : MainScreenViewModel
|
||||
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
public ProfileEditorHistory? History => _history?.Value;
|
||||
public bool SuspendedEditing => _suspendedEditing?.Value ?? false;
|
||||
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 ReactiveCommand<Unit, Unit> ToggleSuspend { get; }
|
||||
public ReactiveCommand<Unit, Unit> ToggleAutoSuspend { get; }
|
||||
|
||||
public void OpenUrl(string url)
|
||||
{
|
||||
Utilities.OpenUrl(url);
|
||||
}
|
||||
|
||||
private void ExecuteToggleSuspend()
|
||||
{
|
||||
_profileEditorService.ChangeSuspendedEditing(!SuspendedEditing);
|
||||
}
|
||||
|
||||
private void ExecuteToggleAutoSuspend()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user