Profile editor - Fixed new layers not saving in some situations

Profile tree - Improved buttons visibility
Layer brushes - Support transformation by default, unless a RGB.NET brush
This commit is contained in:
SpoinkyNL committed 2020-06-11 12:47:46 +02:00
1 parent c3a9a6ce9f
commit 692cf806b7
13 files changed
+88 -40

No files matched your search

@@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerPropertiesView"
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -8,16 +8,14 @@
xmlns:timeline="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:behaviors="clr-namespace:Artemis.UI.Behaviors"
xmlns:Converters="clr-namespace:Artemis.UI.Converters" x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerPropertiesView"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:LayerPropertiesViewModel}"
d:DataContext="{d:DesignInstance {x:Type local:LayerPropertiesViewModel}}"
behaviors:InputBindingBehavior.PropagateInputBindingsToWindow="True">
<UserControl.InputBindings>
<KeyBinding Command="{s:Action Play}" Key="Space" />
<KeyBinding Command="{s:Action PlayFromStart}" Modifiers="Shift" Key="Space" />
</UserControl.InputBindings>
<UserControl.Resources>
<Converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
<Style x:Key="SvStyle" TargetType="{x:Type ScrollViewer}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
@@ -33,7 +31,7 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollContentPresenter Grid.ColumnSpan="2" Grid.RowSpan="2" />
<ScrollBar Name="PART_VerticalScrollBar"
<ScrollBar x:Name="PART_VerticalScrollBar"
HorizontalAlignment="Right"
Opacity="0.5"
Grid.Row="0"
@@ -42,7 +40,7 @@
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
<ScrollBar Name="PART_HorizontalScrollBar"
<ScrollBar x:Name="PART_HorizontalScrollBar"
VerticalAlignment="Bottom"
Orientation="Horizontal"
Opacity="0.5"
@@ -58,6 +56,10 @@
</Setter>
</Style>
</UserControl.Resources>
<UserControl.InputBindings>
<KeyBinding Command="{s:Action Play}" Key="Space" />
<KeyBinding Command="{s:Action PlayFromStart}" Modifiers="Shift" Key="Space" />
</UserControl.InputBindings>
<Grid x:Name="ContainerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
@@ -147,13 +149,13 @@
VerticalScrollBarVisibility="Hidden" ScrollChanged="TimelineScrollChanged">
<Grid Background="{DynamicResource MaterialDesignCardBackground}">
<!-- Caret -->
<Canvas ZIndex="1"
<Canvas Panel.ZIndex="1"
Margin="{Binding TimeCaretPosition}"
Cursor="SizeWE"
MouseDown="{s:Action TimelineMouseDown}"
MouseUp="{s:Action TimelineMouseUp}"
MouseMove="{s:Action TimelineMouseMove}">
<Polygon Points="-10,0 0,20, 10,00" Fill="{StaticResource SecondaryAccentBrush}" />
<Polygon Points="-10,0 0,20 10,0" Fill="{StaticResource SecondaryAccentBrush}" />
<Line X1="0" X2="0" Y1="0" Y2="{Binding ActualHeight, ElementName=ContainerGrid}"
StrokeThickness="2" Stroke="{StaticResource SecondaryAccentBrush}" />
</Canvas>
@@ -175,7 +177,7 @@
VerticalScrollBarVisibility="Auto"
ScrollChanged="TimelineScrollChanged">
<Grid>
<Canvas ZIndex="1"
<Canvas Panel.ZIndex="1"
Margin="{Binding TimeCaretPosition}"
Cursor="SizeWE"
MouseDown="{s:Action TimelineMouseDown}"
@@ -194,7 +196,7 @@
Grid.ColumnSpan="2"
Grid.Column="0"
HorizontalAlignment="Stretch"
ZIndex="2"
Panel.ZIndex="2"
Background="{DynamicResource MaterialDesignCardBackground}">
<!-- Selected layer controls -->
<Grid.ColumnDefinitions>
@@ -206,15 +208,26 @@
<ColumnDefinition />
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="6">
<StackPanel Grid.Column="0"
Orientation="Horizontal"
Margin="6"
Visibility="{Binding SelectedLayer, Converter={StaticResource NullToVisibilityConverter}}">
<materialDesign:PackIcon Kind="Layers" Width="16" />
<materialDesign:PackIcon Kind="{Binding SelectedLayer.LayerBrush.Descriptor.Icon}"
Width="16"
Margin="5 0 0 0"
ToolTip="{Binding SelectedLayer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
Background="Transparent" />
Background="Transparent"
Visibility="{Binding SelectedLayer.LayerBrush, Converter={StaticResource NullToVisibilityConverter}}"/>
<TextBlock Text="{Binding SelectedLayer.Name}" Margin="5 0 0 0" />
</StackPanel>
<StackPanel Grid.Column="0"
Orientation="Horizontal"
Margin="6"
Visibility="{Binding SelectedFolder, Converter={StaticResource NullToVisibilityConverter}}">
<materialDesign:PackIcon Kind="Folder" Width="16" />
<TextBlock Text="{Binding SelectedFolder.Name}" Margin="5 0 0 0" />
</StackPanel>
<Button Grid.Column="1"
Style="{StaticResource MaterialDesignFlatMidBgButton}"
Margin="0 -2"
@@ -224,7 +237,7 @@
ToolTip="Change the property's data binding"
VerticalAlignment="Center">
<TextBlock FontSize="10">ADD EFFECT</TextBlock>
<TextBlock FontSize="10"><Run Text="ADD EFFECT"/></TextBlock>
</Button>
</Grid>
@@ -47,6 +47,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
}
public Layer SelectedLayer { get; set; }
public Folder SelectedFolder { get; set; }
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups { get; set; }
public TreeViewModel TreeViewModel { get; set; }
public TimelineViewModel TimelineViewModel { get; set; }
@@ -104,6 +106,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private void PopulateProperties(ProfileElement profileElement)
{
if (SelectedFolder != null)
{
SelectedFolder = null;
}
if (SelectedLayer != null)
{
SelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated;
@@ -115,7 +121,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
LayerPropertyGroups.Clear();
_brushPropertyGroup = null;
if (profileElement is Layer layer)
if (profileElement is Folder folder)
{
SelectedFolder = folder;
}
else if (profileElement is Layer layer)
{
SelectedLayer = layer;
SelectedLayer.LayerBrushUpdated += SelectedLayerOnLayerBrushUpdated;
@@ -151,7 +161,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
if (SelectedLayer == null)
return;
var hideRenderRelatedProperties = SelectedLayer?.LayerBrush?.BrushType == LayerBrushType.Regular && SelectedLayer.LayerBrush.SupportsTransformation;
var hideRenderRelatedProperties = SelectedLayer?.LayerBrush != null && !SelectedLayer.LayerBrush.SupportsTransformation;
SelectedLayer.General.ShapeType.IsHidden = hideRenderRelatedProperties;
SelectedLayer.General.FillType.IsHidden = hideRenderRelatedProperties;
SelectedLayer.General.BlendMode.IsHidden = hideRenderRelatedProperties;
@@ -47,21 +47,23 @@
</TreeView>
<StackPanel HorizontalAlignment="Right" Grid.Row="2" Orientation="Horizontal" Margin="8">
<Button Style="{StaticResource MaterialDesignToolButton}"
Width="30"
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
Padding="2 0 2 0"
Width="30"
Height="30"
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add new folder to root"
Command="{s:Action AddFolder}">
<materialDesign:PackIcon Kind="CreateNewFolder" />
<materialDesign:PackIcon Kind="CreateNewFolder" Width="15"/>
</Button>
<Button Style="{StaticResource MaterialDesignToolButton}"
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
Width="30"
Height="30"
Padding="2 0 2 0"
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add new layer to root"
Command="{s:Action AddLayer}">
<materialDesign:PackIcon Kind="LayersPlus" />
<materialDesign:PackIcon Kind="LayersPlus" Width="15"/>
</Button>
</StackPanel>
</Grid>
@@ -78,7 +78,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree
break;
}
_profileEditorService.UpdateSelectedProfile();
_profileEditorService.UpdateSelectedProfile(true);
}
// ReSharper disable once UnusedMember.Global - Called from view
@@ -114,7 +114,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
ProfileElement.AddChild(new Folder(ProfileElement.Profile, ProfileElement, "New folder"));
UpdateProfileElements();
_profileEditorService.UpdateSelectedProfile();
_profileEditorService.UpdateSelectedProfile(true);
}
public void AddLayer()
@@ -124,7 +124,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
_layerService.CreateLayer(ProfileElement.Profile, ProfileElement, "New layer");
UpdateProfileElements();
_profileEditorService.UpdateSelectedProfile();
_profileEditorService.UpdateSelectedProfile(true);
}
// ReSharper disable once UnusedMember.Global - Called from view
@@ -136,7 +136,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
if (result is string newName)
{
ProfileElement.Name = newName;
_profileEditorService.UpdateSelectedProfile();
_profileEditorService.UpdateSelectedProfile(true);
}
}
@@ -153,11 +153,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
// Farewell, cruel world
var parent = Parent;
ProfileElement.Parent.RemoveChild(ProfileElement);
ProfileElement.Parent?.RemoveChild(ProfileElement);
parent.RemoveExistingElement(this);
parent.UpdateProfileElements();
_profileEditorService.UpdateSelectedProfile();
_profileEditorService.UpdateSelectedProfile(true);
}
public void UpdateProfileElements()
@@ -7,6 +7,7 @@ using System.Windows.Media.Imaging;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.UI.Extensions;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
@@ -147,7 +148,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
break;
}
shapeGeometry.Transform = _layerEditorService.GetLayerTransformGroup(Layer);
if (Layer.LayerBrush == null || Layer.LayerBrush.SupportsTransformation)
shapeGeometry.Transform = _layerEditorService.GetLayerTransformGroup(Layer);
ShapeGeometry = shapeGeometry;
});
}
@@ -207,7 +207,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
if (_profileEditorService.SelectedProfileElement is Layer layer)
{
CanApplyToLayer = true;
CanSelectEditTool = (layer.LayerBrush == null || layer.LayerBrush.BrushType == LayerBrushType.Regular) && layer.Leds.Any();
CanSelectEditTool = (layer.LayerBrush == null || layer.LayerBrush.SupportsTransformation) && layer.Leds.Any();
}
else
{
@@ -58,7 +58,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
newLayer.AddLeds(selectedLeds);
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
ProfileEditorService.UpdateSelectedProfileElement();
ProfileEditorService.UpdateSelectedProfile();
ProfileEditorService.UpdateSelectedProfile(false);
}
// If no folder selected, apply it to a new layer in the root folder
else
@@ -68,7 +68,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
newLayer.AddLeds(selectedLeds);
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
ProfileEditorService.UpdateSelectedProfileElement();
ProfileEditorService.UpdateSelectedProfile();
ProfileEditorService.UpdateSelectedProfile(false);
}
}