Layer timeline - Show keyframes of collapsed groups

Profile editor - Don't reload UI elements on undo/redo if there's nothing to undo/redo
Layer properties - Properly show/hide properties
This commit is contained in:
SpoinkyNL committed 2020-05-29 17:21:29 +02:00
1 parent dd000e7bed
commit 728baa1b7f
20 files changed
+182 -83

No files matched your search

@@ -10,6 +10,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
public abstract class BaseLayerProperty
{
private bool _keyframesEnabled;
private bool _isHidden;
internal BaseLayerProperty()
{
@@ -48,7 +49,15 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// <summary>
/// Gets or sets whether the property is hidden in the UI
/// </summary>
public bool IsHidden { get; set; }
public bool IsHidden
{
get => _isHidden;
set
{
_isHidden = value;
OnVisibilityChanged();
}
}
/// <summary>
/// Indicates whether the BaseValue was loaded from storage, useful to check whether a default value must be applied
@@ -100,6 +109,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary>
public event EventHandler BaseValueChanged;
/// <summary>
/// Occurs when the <see cref="IsHidden"/> value of the layer property was updated
/// </summary>
public event EventHandler VisibilityChanged;
/// <summary>
/// Occurs when keyframes are enabled/disabled
/// </summary>
@@ -125,6 +139,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties
BaseValueChanged?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnVisibilityChanged()
{
VisibilityChanged?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnKeyframesToggled()
{
KeyframesToggled?.Invoke(this, EventArgs.Empty);
@@ -143,5 +162,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
#endregion
public abstract void ApplyDefaultValue();
}
}
@@ -284,6 +284,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
public override void ApplyDefaultValue()
{
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
}
}
@@ -4,7 +4,7 @@ using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class ColorGradientLayerProperty : LayerProperty<ColorGradient>
{
internal ColorGradientLayerProperty()
@@ -12,21 +12,17 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false;
}
internal override void ApplyToLayerProperty(PropertyEntity entity, LayerPropertyGroup layerPropertyGroup, bool fromStorage)
{
base.ApplyToLayerProperty(entity, layerPropertyGroup, fromStorage);
// Don't allow color gradients to be null
if (BaseValue == null)
{
BaseValue = DefaultValue ?? new ColorGradient();
}
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
throw new ArtemisCoreException("Color Gradients do not support keyframes.");
}
internal override void ApplyToLayerProperty(PropertyEntity entity, LayerPropertyGroup layerPropertyGroup, bool fromStorage)
{
base.ApplyToLayerProperty(entity, layerPropertyGroup, fromStorage);
// Don't allow color gradients to be null
BaseValue ??= DefaultValue ?? new ColorGradient();
}
}
}
@@ -18,6 +18,7 @@ namespace Artemis.Core.Models.Profile
private readonly List<BaseLayerProperty> _layerProperties;
private readonly List<LayerPropertyGroup> _layerPropertyGroups;
private ReadOnlyCollection<BaseLayerProperty> _allLayerProperties;
private bool _isHidden;
protected LayerPropertyGroup()
{
@@ -53,7 +54,15 @@ namespace Artemis.Core.Models.Profile
/// <summary>
/// Gets or sets whether the property is hidden in the UI
/// </summary>
public bool IsHidden { get; set; }
public bool IsHidden
{
get => _isHidden;
set
{
_isHidden = value;
OnVisibilityChanged();
}
}
/// <summary>
/// A list of all layer properties in this group
@@ -211,6 +220,11 @@ namespace Artemis.Core.Models.Profile
internal event EventHandler<PropertyGroupUpdatingEventArgs> PropertyGroupOverriding;
public event EventHandler PropertyGroupInitialized;
/// <summary>
/// Occurs when the <see cref="IsHidden" /> value of the layer property was updated
/// </summary>
public event EventHandler VisibilityChanged;
internal virtual void OnPropertyGroupUpdating(PropertyGroupUpdatingEventArgs e)
{
PropertyGroupUpdating?.Invoke(this, e);
@@ -221,6 +235,11 @@ namespace Artemis.Core.Models.Profile
PropertyGroupOverriding?.Invoke(this, e);
}
protected virtual void OnVisibilityChanged()
{
VisibilityChanged?.Invoke(this, EventArgs.Empty);
}
#endregion
}
}
@@ -26,13 +26,13 @@ namespace Artemis.Core.Services.Storage.Interfaces
/// </summary>
/// <param name="selectedProfile"></param>
/// <param name="module"></param>
void UndoUpdateProfile(Profile selectedProfile, ProfileModule module);
bool UndoUpdateProfile(Profile selectedProfile, ProfileModule module);
/// <summary>
/// Attempts to restore the profile to the state it had before the last <see cref="UndoUpdateProfile" /> call.
/// </summary>
/// <param name="selectedProfile"></param>
/// <param name="module"></param>
void RedoUpdateProfile(Profile selectedProfile, ProfileModule module);
bool RedoUpdateProfile(Profile selectedProfile, ProfileModule module);
}
}
@@ -123,12 +123,12 @@ namespace Artemis.Core.Services.Storage
_profileRepository.Save(profile.ProfileEntity);
}
public void UndoUpdateProfile(Profile profile, ProfileModule module)
public bool UndoUpdateProfile(Profile profile, ProfileModule module)
{
if (!profile.UndoStack.Any())
{
_logger.Debug("Undo profile update - Failed, undo stack empty");
return;
return false;
}
ActivateProfile(module, null);
@@ -140,14 +140,15 @@ namespace Artemis.Core.Services.Storage
ActivateProfile(module, profile);
_logger.Debug("Undo profile update - Success");
return true;
}
public void RedoUpdateProfile(Profile profile, ProfileModule module)
public bool RedoUpdateProfile(Profile profile, ProfileModule module)
{
if (!profile.RedoStack.Any())
{
_logger.Debug("Redo profile update - Failed, redo empty");
return;
return false;
}
ActivateProfile(module, null);
@@ -159,6 +160,7 @@ namespace Artemis.Core.Services.Storage
ActivateProfile(module, profile);
_logger.Debug("Redo profile update - Success");
return true;
}
private void InitializeLayerProperties(Profile profile)
@@ -169,7 +171,9 @@ namespace Artemis.Core.Services.Storage
layer.General.InitializeProperties(_layerService, layer, "General.");
if (!layer.Transform.PropertiesInitialized)
layer.Transform.InitializeProperties(_layerService, layer, "Transform.");
};
}
;
}
private void InstantiateLayerBrushes(Profile profile)
@@ -178,7 +182,7 @@ namespace Artemis.Core.Services.Storage
foreach (var layer in profile.GetAllLayers().Where(l => l.LayerBrush == null))
_layerService.InstantiateLayerBrush(layer);
}
private void ActiveProfilesPopulateLeds(ArtemisSurface surface)
{
var profileModules = _pluginService.GetPluginsOfType<ProfileModule>();
@@ -192,7 +196,7 @@ namespace Artemis.Core.Services.Storage
foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList())
InstantiateLayerBrushes(profileModule.ActiveProfile);
}
#region Event handlers
private void OnActiveSurfaceConfigurationSelected(object sender, SurfaceConfigurationEventArgs e)