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

Layer properties - Implement INotifyPropertyChanged on BaseValue

Profile editor - Don't show expand button on property groups without children
Profile editor - Alert user about extra options on brushes
This commit is contained in:
Robert 2021-05-21 18:24:47 +02:00
parent 87dce788d7
commit 3825c34be1
3 changed files with 45 additions and 12 deletions

View File

@ -15,7 +15,7 @@ namespace Artemis.Core
/// </para> /// </para>
/// </summary> /// </summary>
/// <typeparam name="T">The type of property encapsulated in this layer property</typeparam> /// <typeparam name="T">The type of property encapsulated in this layer property</typeparam>
public class LayerProperty<T> : ILayerProperty public class LayerProperty<T> : CorePropertyChanged, ILayerProperty
{ {
private bool _disposed; private bool _disposed;
@ -265,6 +265,7 @@ namespace Artemis.Core
_baseValue = value; _baseValue = value;
ReapplyUpdate(); ReapplyUpdate();
OnPropertyChanged(nameof(BaseValue));
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
@ -17,6 +18,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
private bool _isVisible; private bool _isVisible;
private TreeGroupViewModel _treeGroupViewModel; private TreeGroupViewModel _treeGroupViewModel;
private TimelineGroupViewModel _timelineGroupViewModel; private TimelineGroupViewModel _timelineGroupViewModel;
private bool _hasChildren;
public LayerPropertyGroupViewModel(LayerPropertyGroup layerPropertyGroup, IProfileEditorService profileEditorService, ILayerPropertyVmFactory layerPropertyVmFactory) public LayerPropertyGroupViewModel(LayerPropertyGroup layerPropertyGroup, IProfileEditorService profileEditorService, ILayerPropertyVmFactory layerPropertyVmFactory)
{ {
@ -62,6 +64,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
} }
} }
public bool HasChildren
{
get => _hasChildren;
set => SetAndNotify(ref _hasChildren, value);
}
protected override void OnInitialActivate() protected override void OnInitialActivate()
{ {
@ -169,6 +176,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
Items.Add(_layerPropertyVmFactory.LayerPropertyGroupViewModel(value)); Items.Add(_layerPropertyVmFactory.LayerPropertyGroupViewModel(value));
} }
} }
HasChildren = Items.Any(i => i is LayerPropertyViewModel {IsVisible: true} || i is LayerPropertyGroupViewModel {IsVisible: true});
} }
} }
} }

View File

@ -33,6 +33,7 @@
Foreground="{DynamicResource MaterialDesignBody}" Foreground="{DynamicResource MaterialDesignBody}"
Style="{StaticResource MaterialDesignExpandCollapseToggleStyle}" Style="{StaticResource MaterialDesignExpandCollapseToggleStyle}"
IsChecked="{Binding Path=LayerPropertyGroupViewModel.IsExpanded}" IsChecked="{Binding Path=LayerPropertyGroupViewModel.IsExpanded}"
Visibility="{Binding Path=LayerPropertyGroupViewModel.HasChildren, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
ClickMode="Press" /> ClickMode="Press" />
<StackPanel Grid.Column="1"> <StackPanel Grid.Column="1">
@ -121,17 +122,39 @@
ToolTip="{Binding LayerPropertyGroup.LayerBrush.Descriptor.Description}" ToolTip="{Binding LayerPropertyGroup.LayerBrush.Descriptor.Description}"
Margin="0 5 0 0" /> Margin="0 5 0 0" />
<Button Grid.Column="3" <StackPanel Grid.Column="3"
Style="{StaticResource MaterialDesignIconButton}" Orientation="Horizontal"
ToolTip="Open brush settings" HorizontalAlignment="Right"
Width="24" Visibility="{Binding LayerPropertyGroup.LayerBrush.ConfigurationDialog, Converter={StaticResource NullToVisibilityConverter}}">
Height="24" <TextBlock VerticalAlignment="Center">Extra options available!</TextBlock>
VerticalAlignment="Center" <materialDesign:PackIcon Kind="ChevronRight" VerticalAlignment="Center">
HorizontalAlignment="Right" <materialDesign:PackIcon.RenderTransform>
Command="{s:Action OpenBrushSettings}" <TranslateTransform X="0" />
Visibility="{Binding LayerPropertyGroup.LayerBrush.ConfigurationDialog, Converter={StaticResource NullToVisibilityConverter}}"> </materialDesign:PackIcon.RenderTransform>
<materialDesign:PackIcon Kind="Settings" Height="16" Width="16" /> <materialDesign:PackIcon.Triggers>
</Button> <EventTrigger RoutedEvent="materialDesign:PackIcon.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(materialDesign:PackIcon.RenderTransform).(TranslateTransform.X)"
From="0"
To="2"
Duration="0:0:0.5"
AutoReverse="True"
RepeatBehavior="Forever">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseInOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</materialDesign:PackIcon.Triggers>
</materialDesign:PackIcon>
<Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Open brush settings" Width="24" Height="24" HorizontalAlignment="Right" Command="{s:Action OpenBrushSettings}">
<materialDesign:PackIcon Kind="Settings" Height="16" Width="16" />
</Button>
</StackPanel>
</Grid> </Grid>
<!-- Type: LayerEffectRoot --> <!-- Type: LayerEffectRoot -->