1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 09:43:46 +00:00

Added reset layer property button

This commit is contained in:
Diogo Trindade 2020-11-20 21:27:30 +00:00
parent 8d901027ee
commit f637c131c4
3 changed files with 30 additions and 12 deletions

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
@ -208,8 +208,10 @@ namespace Artemis.Core
if (_disposed) if (_disposed)
throw new ObjectDisposedException("LayerProperty"); throw new ObjectDisposedException("LayerProperty");
BaseValue = DefaultValue; string json = JsonConvert.SerializeObject(DefaultValue, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All });
CurrentValue = DefaultValue;
BaseValue = JsonConvert.DeserializeObject<T>(json);
CurrentValue = JsonConvert.DeserializeObject<T>(json);
} }
private void ReapplyUpdate() private void ReapplyUpdate()

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree.TreePropertyView" <UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree.TreePropertyView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -48,16 +48,17 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ToggleButton Grid.Column="0" <ToggleButton Grid.Column="0"
Style="{StaticResource MaterialDesignFlatToggleButton}" Style="{StaticResource MaterialDesignFlatToggleButton}"
ToolTip="Toggle key-framing" ToolTip="Toggle key-framing"
Width="18" Width="24"
Height="18" Height="24"
IsChecked="{Binding KeyframesEnabled}" IsChecked="{Binding KeyframesEnabled}"
IsEnabled="{Binding LayerProperty.KeyframesSupported}" IsEnabled="{Binding LayerProperty.KeyframesSupported}"
VerticalAlignment="Center" Padding="-25"> VerticalAlignment="Center" Padding="-25">
<materialDesign:PackIcon Kind="Stopwatch" Height="13" Width="13" /> <materialDesign:PackIcon Kind="Stopwatch" Height="16" Width="16" />
</ToggleButton> </ToggleButton>
<TextBlock Grid.Column="1" <TextBlock Grid.Column="1"
@ -68,7 +69,7 @@
Text="{Binding LayerProperty.PropertyDescription.Name}" Text="{Binding LayerProperty.PropertyDescription.Name}"
ToolTip="{Binding LayerProperty.PropertyDescription.Description}" ToolTip="{Binding LayerProperty.PropertyDescription.Description}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<ContentControl Grid.Column="2" Margin="20 0" s:View.Model="{Binding PropertyInputViewModel, IsAsync=True}"> <ContentControl Grid.Column="2" Margin="20 0" s:View.Model="{Binding PropertyInputViewModel, IsAsync=True}">
<ContentControl.Resources> <ContentControl.Resources>
<Style TargetType="TextBlock"> <Style TargetType="TextBlock">
@ -78,17 +79,26 @@
</ContentControl.Resources> </ContentControl.Resources>
</ContentControl> </ContentControl>
<shared:LockableToggleButton Grid.Column="3" <Button Grid.Column="3"
Command="{s:Action ResetToDefault}"
Style="{StaticResource MaterialDesignIconButton}"
ToolTip="Reset the property to its default value."
Width="24"
Height="24">
<materialDesign:PackIcon Kind="BackupRestore" Height="16" Width="16" />
</Button>
<shared:LockableToggleButton Grid.Column="4"
Style="{StaticResource DataBindingsButton}" Style="{StaticResource DataBindingsButton}"
ToolTip="Change the property's data binding" ToolTip="Change the property's data binding"
Width="20" Width="24"
Height="20" Height="24"
VerticalAlignment="Center" VerticalAlignment="Center"
IsLocked="True" IsLocked="True"
IsEnabled="{Binding LayerProperty.DataBindingsSupported}" IsEnabled="{Binding LayerProperty.DataBindingsSupported}"
IsChecked="{Binding HasDataBinding, Mode=OneWay}" IsChecked="{Binding HasDataBinding, Mode=OneWay}"
Click="{s:Action ActivateDataBindingViewModel}"> Click="{s:Action ActivateDataBindingViewModel}">
<materialDesign:PackIcon Kind="VectorLink" Height="13" Width="13" /> <materialDesign:PackIcon Kind="VectorLink" Height="16" Width="16" />
</shared:LockableToggleButton> </shared:LockableToggleButton>
</Grid> </Grid>

View File

@ -49,6 +49,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
_profileEditorService.ChangeSelectedDataBinding(LayerProperty); _profileEditorService.ChangeSelectedDataBinding(LayerProperty);
} }
public void ResetToDefault()
{
LayerProperty.ApplyDefaultValue();
_profileEditorService.UpdateSelectedProfileElement();
}
private void ApplyKeyframesEnabled(bool enable) private void ApplyKeyframesEnabled(bool enable)
{ {
// If enabling keyframes for the first time, add a keyframe with the current value at the current position // If enabling keyframes for the first time, add a keyframe with the current value at the current position