1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge pull request #506 from diogotr7/feature/reset-layerprop

Added reset layer property button
This commit is contained in:
Robert Beekman 2020-11-21 09:24:27 +01:00 committed by GitHub
commit bc8ac61388
3 changed files with 31 additions and 14 deletions

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@ -203,13 +203,14 @@ namespace Artemis.Core
/// <summary>
/// Overrides the property value with the default value
/// </summary>
public void ApplyDefaultValue()
public void ApplyDefaultValue(TimeSpan? time)
{
if (_disposed)
throw new ObjectDisposedException("LayerProperty");
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
string json = JsonConvert.SerializeObject(DefaultValue, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All });
SetCurrentValue(JsonConvert.DeserializeObject<T>(json), time);
}
private void ReapplyUpdate()
@ -506,7 +507,7 @@ namespace Artemis.Core
throw new ArtemisCoreException("Layer property is not yet initialized");
if (!IsLoadedFromStorage)
ApplyDefaultValue();
ApplyDefaultValue(null);
else
try
{

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:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -48,16 +48,17 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ToggleButton Grid.Column="0"
Style="{StaticResource MaterialDesignFlatToggleButton}"
ToolTip="Toggle key-framing"
Width="18"
Height="18"
Width="24"
Height="24"
IsChecked="{Binding KeyframesEnabled}"
IsEnabled="{Binding LayerProperty.KeyframesSupported}"
VerticalAlignment="Center" Padding="-25">
<materialDesign:PackIcon Kind="Stopwatch" Height="13" Width="13" />
<materialDesign:PackIcon Kind="Stopwatch" Height="16" Width="16" />
</ToggleButton>
<TextBlock Grid.Column="1"
@ -68,7 +69,7 @@
Text="{Binding LayerProperty.PropertyDescription.Name}"
ToolTip="{Binding LayerProperty.PropertyDescription.Description}"
HorizontalAlignment="Left" />
<ContentControl Grid.Column="2" Margin="20 0" s:View.Model="{Binding PropertyInputViewModel, IsAsync=True}">
<ContentControl.Resources>
<Style TargetType="TextBlock">
@ -78,17 +79,26 @@
</ContentControl.Resources>
</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}"
ToolTip="Change the property's data binding"
Width="20"
Height="20"
Width="24"
Height="24"
VerticalAlignment="Center"
IsLocked="True"
IsEnabled="{Binding LayerProperty.DataBindingsSupported}"
IsChecked="{Binding HasDataBinding, Mode=OneWay}"
Click="{s:Action ActivateDataBindingViewModel}">
<materialDesign:PackIcon Kind="VectorLink" Height="13" Width="13" />
<materialDesign:PackIcon Kind="VectorLink" Height="16" Width="16" />
</shared:LockableToggleButton>
</Grid>

View File

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