mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Brushes - Allow hiding of properties
This commit is contained in:
parent
9f8fc9f70e
commit
26f9e90fa3
@ -7,12 +7,14 @@ using Artemis.Core.Plugins.Models;
|
|||||||
using Artemis.Core.Utilities;
|
using Artemis.Core.Utilities;
|
||||||
using Artemis.Storage.Entities.Profile;
|
using Artemis.Storage.Entities.Profile;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.LayerProperties
|
namespace Artemis.Core.Models.Profile.LayerProperties
|
||||||
{
|
{
|
||||||
public abstract class BaseLayerProperty
|
public abstract class BaseLayerProperty : PropertyChangedBase
|
||||||
{
|
{
|
||||||
private object _baseValue;
|
private object _baseValue;
|
||||||
|
private bool _isHidden;
|
||||||
|
|
||||||
protected BaseLayerProperty(Layer layer, PluginInfo pluginInfo, BaseLayerProperty parent, string id, string name, string description, Type type)
|
protected BaseLayerProperty(Layer layer, PluginInfo pluginInfo, BaseLayerProperty parent, string id, string name, string description, Type type)
|
||||||
{
|
{
|
||||||
@ -118,6 +120,19 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Type Type { get; protected set; }
|
public Type Type { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether this property is hidden in the UI.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsHidden
|
||||||
|
{
|
||||||
|
get => _isHidden;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isHidden = value;
|
||||||
|
OnVisibilityChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of keyframes defining different values of the property in time, this list contains the untyped
|
/// Gets a list of keyframes defining different values of the property in time, this list contains the untyped
|
||||||
/// <see cref="BaseKeyframe" />.
|
/// <see cref="BaseKeyframe" />.
|
||||||
@ -337,11 +352,23 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<EventArgs> ValueChanged;
|
public event EventHandler<EventArgs> ValueChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when this property or any of it's ancestors visibility is changed
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<EventArgs> VisibilityChanged;
|
||||||
|
|
||||||
protected virtual void OnValueChanged()
|
protected virtual void OnValueChanged()
|
||||||
{
|
{
|
||||||
ValueChanged?.Invoke(this, EventArgs.Empty);
|
ValueChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void OnVisibilityChanged()
|
||||||
|
{
|
||||||
|
VisibilityChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
foreach (var baseLayerProperty in Children)
|
||||||
|
baseLayerProperty.OnVisibilityChanged();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
_layerPropertyViewModels = new List<LayerPropertyViewModel>();
|
_layerPropertyViewModels = new List<LayerPropertyViewModel>();
|
||||||
|
|
||||||
PixelsPerSecond = 31;
|
PixelsPerSecond = 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Playing { get; set; }
|
public bool Playing { get; set; }
|
||||||
public bool RepeatAfterLastKeyframe { get; set; }
|
public bool RepeatAfterLastKeyframe { get; set; }
|
||||||
@ -79,7 +79,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
|
|
||||||
_profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
|
_profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
|
||||||
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
|
_profileEditorService.CurrentTimeChanged += ProfileEditorServiceOnCurrentTimeChanged;
|
||||||
|
|
||||||
base.OnInitialActivate();
|
base.OnInitialActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
{
|
{
|
||||||
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||||
_profileEditorService.CurrentTimeChanged -= ProfileEditorServiceOnCurrentTimeChanged;
|
_profileEditorService.CurrentTimeChanged -= ProfileEditorServiceOnCurrentTimeChanged;
|
||||||
|
|
||||||
if (_lastSelectedLayer != null)
|
if (_lastSelectedLayer != null)
|
||||||
{
|
{
|
||||||
_lastSelectedLayer.Properties.LayerPropertyRegistered -= LayerOnPropertyRegistered;
|
_lastSelectedLayer.Properties.LayerPropertyRegistered -= LayerOnPropertyRegistered;
|
||||||
@ -106,7 +106,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
Pause();
|
Pause();
|
||||||
base.OnDeactivate();
|
base.OnDeactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
|
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
|
||||||
{
|
{
|
||||||
PopulateProperties(e.ProfileElement);
|
PopulateProperties(e.ProfileElement);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private bool _keyframesEnabled;
|
private bool _keyframesEnabled;
|
||||||
|
private bool _isExpanded;
|
||||||
|
|
||||||
public LayerPropertyViewModel(BaseLayerProperty layerProperty, LayerPropertyViewModel parent, IKernel kernel, IProfileEditorService profileEditorService)
|
public LayerPropertyViewModel(BaseLayerProperty layerProperty, LayerPropertyViewModel parent, IKernel kernel, IProfileEditorService profileEditorService)
|
||||||
{
|
{
|
||||||
@ -34,7 +35,15 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
public LayerPropertyViewModel Parent { get; }
|
public LayerPropertyViewModel Parent { get; }
|
||||||
public List<LayerPropertyViewModel> Children { get; }
|
public List<LayerPropertyViewModel> Children { get; }
|
||||||
|
|
||||||
public bool IsExpanded { get; set; }
|
public bool IsExpanded
|
||||||
|
{
|
||||||
|
get => _isExpanded;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isExpanded = value;
|
||||||
|
OnExpandedStateChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool KeyframesEnabled
|
public bool KeyframesEnabled
|
||||||
{
|
{
|
||||||
@ -75,5 +84,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
|
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
public event EventHandler<EventArgs> ExpandedStateChanged;
|
||||||
|
protected virtual void OnExpandedStateChanged()
|
||||||
|
{
|
||||||
|
ExpandedStateChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
foreach (var layerPropertyViewModel in Children)
|
||||||
|
layerPropertyViewModel.OnExpandedStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,6 +87,7 @@
|
|||||||
<TreeView.ItemContainerStyle>
|
<TreeView.ItemContainerStyle>
|
||||||
<Style TargetType="TreeViewItem" BasedOn="{StaticResource PropertyTreeStyle}">
|
<Style TargetType="TreeViewItem" BasedOn="{StaticResource PropertyTreeStyle}">
|
||||||
<Setter Property="IsExpanded" Value="{Binding LayerPropertyViewModel.IsExpanded, Mode=TwoWay}" />
|
<Setter Property="IsExpanded" Value="{Binding LayerPropertyViewModel.IsExpanded, Mode=TwoWay}" />
|
||||||
|
<Setter Property="Visibility" Value="{Binding LayerPropertyViewModel.LayerProperty.IsHidden, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}" />
|
||||||
</Style>
|
</Style>
|
||||||
</TreeView.ItemContainerStyle>
|
</TreeView.ItemContainerStyle>
|
||||||
<TreeView.Resources>
|
<TreeView.Resources>
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<Border Height="25"
|
<Border Height="25"
|
||||||
BorderThickness="0,0,0,1"
|
BorderThickness="0,0,0,1"
|
||||||
BorderBrush="{DynamicResource MaterialDesignDivider}"
|
BorderBrush="{DynamicResource MaterialDesignDivider}"
|
||||||
Visibility="{Binding LayerPropertyViewModel.Parent.IsExpanded, Converter={StaticResource BoolToVisibilityConverter}}">
|
Visibility="{Binding MustDisplay, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||||
<ItemsControl ItemsSource="{Binding KeyframeViewModels}"
|
<ItemsControl ItemsSource="{Binding KeyframeViewModels}"
|
||||||
Background="{DynamicResource MaterialDesignToolBarBackground}"
|
Background="{DynamicResource MaterialDesignToolBarBackground}"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left">
|
||||||
|
|||||||
@ -19,12 +19,44 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
|
|
||||||
PopulateKeyframes();
|
PopulateKeyframes();
|
||||||
UpdateKeyframes(PropertyTimelineViewModel.LayerPropertiesViewModel.PixelsPerSecond);
|
UpdateKeyframes(PropertyTimelineViewModel.LayerPropertiesViewModel.PixelsPerSecond);
|
||||||
|
|
||||||
|
LayerPropertyViewModel.ExpandedStateChanged += (sender, args) => UpdateMustDisplay();
|
||||||
|
LayerPropertyViewModel.LayerProperty.VisibilityChanged += (sender, args) => UpdateMustDisplay();
|
||||||
|
UpdateMustDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PropertyTimelineViewModel PropertyTimelineViewModel { get; }
|
public PropertyTimelineViewModel PropertyTimelineViewModel { get; }
|
||||||
public LayerPropertyViewModel LayerPropertyViewModel { get; }
|
public LayerPropertyViewModel LayerPropertyViewModel { get; }
|
||||||
public BindableCollection<PropertyTrackKeyframeViewModel> KeyframeViewModels { get; set; }
|
public BindableCollection<PropertyTrackKeyframeViewModel> KeyframeViewModels { get; set; }
|
||||||
|
public bool MustDisplay { get; set; }
|
||||||
|
|
||||||
|
private void UpdateMustDisplay()
|
||||||
|
{
|
||||||
|
var expandedTest = LayerPropertyViewModel.Parent;
|
||||||
|
while (expandedTest != null)
|
||||||
|
{
|
||||||
|
if (!expandedTest.IsExpanded)
|
||||||
|
{
|
||||||
|
MustDisplay = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
expandedTest = expandedTest.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
var visibilityTest = LayerPropertyViewModel.LayerProperty;
|
||||||
|
while (visibilityTest != null)
|
||||||
|
{
|
||||||
|
if (visibilityTest.IsHidden)
|
||||||
|
{
|
||||||
|
MustDisplay = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visibilityTest = visibilityTest.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
MustDisplay = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void PopulateKeyframes()
|
public void PopulateKeyframes()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -19,11 +19,18 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
|||||||
{
|
{
|
||||||
GradientTypeProperty = RegisterLayerProperty("Brush.GradientType", "Gradient type", "The type of color brush to draw", GradientType.Solid);
|
GradientTypeProperty = RegisterLayerProperty("Brush.GradientType", "Gradient type", "The type of color brush to draw", GradientType.Solid);
|
||||||
GradientTypeProperty.CanUseKeyframes = false;
|
GradientTypeProperty.CanUseKeyframes = false;
|
||||||
|
ColorProperty = RegisterLayerProperty("Brush.Color", "Color", "The color of the brush", new SKColor(255, 0, 0));
|
||||||
|
GradientProperty = RegisterLayerProperty("Brush.Gradient", "Gradient", "The gradient of the brush", new ColorGradient());
|
||||||
|
GradientProperty.CanUseKeyframes = false;
|
||||||
|
if (!GradientProperty.Value.Stops.Any())
|
||||||
|
GradientProperty.Value.MakeFabulous();
|
||||||
|
|
||||||
UpdateColorProperties();
|
UpdateColorProperties();
|
||||||
|
|
||||||
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
||||||
GradientTypeProperty.ValueChanged += (sender, args) => UpdateColorProperties();
|
GradientTypeProperty.ValueChanged += (sender, args) => UpdateColorProperties();
|
||||||
|
ColorProperty.ValueChanged += (sender, args) => CreateShader();
|
||||||
|
GradientProperty.Value.PropertyChanged += (sender, args) => CreateShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayerProperty<SKColor> ColorProperty { get; set; }
|
public LayerProperty<SKColor> ColorProperty { get; set; }
|
||||||
@ -57,23 +64,9 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
|||||||
|
|
||||||
private void UpdateColorProperties()
|
private void UpdateColorProperties()
|
||||||
{
|
{
|
||||||
if (GradientTypeProperty.Value == GradientType.Solid)
|
ColorProperty.IsHidden = GradientTypeProperty.Value != GradientType.Solid;
|
||||||
{
|
GradientProperty.IsHidden = GradientTypeProperty.Value == GradientType.Solid;
|
||||||
UnRegisterLayerProperty(GradientProperty);
|
|
||||||
ColorProperty = RegisterLayerProperty("Brush.Color", "Color", "The color of the brush", new SKColor(255, 0, 0));
|
|
||||||
ColorProperty.ValueChanged += (sender, args) => CreateShader();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UnRegisterLayerProperty(ColorProperty);
|
|
||||||
GradientProperty = RegisterLayerProperty("Brush.Gradient", "Gradient", "The gradient of the brush", new ColorGradient());
|
|
||||||
GradientProperty.CanUseKeyframes = false;
|
|
||||||
GradientProperty.Value.PropertyChanged += (sender, args) => CreateShader();
|
|
||||||
|
|
||||||
if (!GradientProperty.Value.Stops.Any())
|
|
||||||
GradientProperty.Value.MakeFabulous();
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateShader();
|
CreateShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,11 +30,11 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
_y = Rand.Next(0, 4096);
|
_y = Rand.Next(0, 4096);
|
||||||
_z = Rand.Next(0, 4096);
|
_z = Rand.Next(0, 4096);
|
||||||
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
|
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
|
||||||
|
DetermineRenderScale();
|
||||||
|
|
||||||
ColorTypeProperty = RegisterLayerProperty("Brush.ColorType", "Color mapping type", "The way the noise is converted to colors", ColorMappingType.Simple);
|
ColorTypeProperty = RegisterLayerProperty("Brush.ColorType", "Color mapping type", "The way the noise is converted to colors", ColorMappingType.Simple);
|
||||||
|
ColorTypeProperty.CanUseKeyframes = false;
|
||||||
ColorTypeProperty.ValueChanged += (sender, args) => UpdateColorProperties();
|
ColorTypeProperty.ValueChanged += (sender, args) => UpdateColorProperties();
|
||||||
UpdateColorProperties();
|
|
||||||
|
|
||||||
ScaleProperty = RegisterLayerProperty("Brush.Scale", "Scale", "The scale of the noise.", new SKSize(100, 100));
|
ScaleProperty = RegisterLayerProperty("Brush.Scale", "Scale", "The scale of the noise.", new SKSize(100, 100));
|
||||||
ScaleProperty.MinInputValue = 0f;
|
ScaleProperty.MinInputValue = 0f;
|
||||||
HardnessProperty = RegisterLayerProperty("Brush.Hardness", "Hardness", "The hardness of the noise, lower means there are gradients in the noise, higher means hard lines", 500f);
|
HardnessProperty = RegisterLayerProperty("Brush.Hardness", "Hardness", "The hardness of the noise, lower means there are gradients in the noise, higher means hard lines", 500f);
|
||||||
@ -47,8 +47,16 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
AnimationSpeedProperty.MinInputValue = 0f;
|
AnimationSpeedProperty.MinInputValue = 0f;
|
||||||
AnimationSpeedProperty.MaxInputValue = 64f;
|
AnimationSpeedProperty.MaxInputValue = 64f;
|
||||||
ScaleProperty.InputAffix = "%";
|
ScaleProperty.InputAffix = "%";
|
||||||
|
MainColorProperty = RegisterLayerProperty("Brush.MainColor", "Main color", "The main color of the noise", new SKColor(255, 0, 0));
|
||||||
|
SecondaryColorProperty = RegisterLayerProperty("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise", new SKColor(0, 0, 255));
|
||||||
|
GradientColorProperty = RegisterLayerProperty("Brush.GradientColor", "Noise gradient map", "The gradient the noise will map it's value to", new ColorGradient());
|
||||||
|
GradientColorProperty.CanUseKeyframes = false;
|
||||||
|
if (!GradientColorProperty.Value.Stops.Any())
|
||||||
|
GradientColorProperty.Value.MakeFabulous();
|
||||||
|
GradientColorProperty.Value.PropertyChanged += CreateColorMap;
|
||||||
|
|
||||||
DetermineRenderScale();
|
UpdateColorProperties();
|
||||||
|
CreateColorMap(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,25 +72,9 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
|
|
||||||
private void UpdateColorProperties()
|
private void UpdateColorProperties()
|
||||||
{
|
{
|
||||||
if (GradientColorProperty != null)
|
GradientColorProperty.IsHidden = ColorTypeProperty.Value != ColorMappingType.Gradient;
|
||||||
GradientColorProperty.Value.PropertyChanged -= CreateColorMap;
|
MainColorProperty.IsHidden = ColorTypeProperty.Value != ColorMappingType.Simple;
|
||||||
if (ColorTypeProperty.Value == ColorMappingType.Simple)
|
SecondaryColorProperty.IsHidden = ColorTypeProperty.Value != ColorMappingType.Simple;
|
||||||
{
|
|
||||||
UnRegisterLayerProperty(GradientColorProperty);
|
|
||||||
MainColorProperty = RegisterLayerProperty("Brush.MainColor", "Main color", "The main color of the noise", new SKColor(255, 0, 0));
|
|
||||||
SecondaryColorProperty = RegisterLayerProperty("Brush.SecondaryColor", "Secondary color", "The secondary color of the noise", new SKColor(0, 0, 255));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UnRegisterLayerProperty(MainColorProperty);
|
|
||||||
UnRegisterLayerProperty(SecondaryColorProperty);
|
|
||||||
GradientColorProperty = RegisterLayerProperty("Brush.GradientColor", "Noise gradient map", "The gradient the noise will map it's value to", new ColorGradient());
|
|
||||||
if (!GradientColorProperty.Value.Stops.Any())
|
|
||||||
GradientColorProperty.Value.MakeFabulous();
|
|
||||||
|
|
||||||
GradientColorProperty.Value.PropertyChanged += CreateColorMap;
|
|
||||||
CreateColorMap(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(double deltaTime)
|
public override void Update(double deltaTime)
|
||||||
@ -136,7 +128,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
|||||||
else if (gradientColor != null && _colorMap.Length == 101)
|
else if (gradientColor != null && _colorMap.Length == 101)
|
||||||
{
|
{
|
||||||
var color = _colorMap[(int) Math.Round(alpha / 255f * 100, MidpointRounding.AwayFromZero)];
|
var color = _colorMap[(int) Math.Round(alpha / 255f * 100, MidpointRounding.AwayFromZero)];
|
||||||
_bitmap.SetPixel(x, y, new SKColor(color.Red, color.Green, color.Blue, 255));
|
_bitmap.SetPixel(x, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user