mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Nodes - Renamed easing nodes to transition nodes
This commit is contained in:
parent
6240e42e74
commit
ea4ada7a8c
@ -9,7 +9,6 @@ public abstract class RenderElementEntity
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; }
|
||||
public List<PropertyEntity> PropertyEntities { get; set; }
|
||||
|
||||
public IConditionEntity DisplayCondition { get; set; }
|
||||
public TimelineEntity Timeline { get; set; }
|
||||
|
||||
@ -9,7 +9,6 @@ public class FolderEntity : RenderElementEntity
|
||||
{
|
||||
public FolderEntity()
|
||||
{
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,6 @@ public class LayerEntity : RenderElementEntity
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
}
|
||||
|
||||
|
||||
87
src/Artemis.Storage/Migrations/M0022TransitionNodes.cs
Normal file
87
src/Artemis.Storage/Migrations/M0022TransitionNodes.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.Conditions;
|
||||
using Artemis.Storage.Entities.Profile.Nodes;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Migrations;
|
||||
|
||||
public class M0022TransitionNodes : IStorageMigration
|
||||
{
|
||||
private void MigrateNodeScript(NodeScriptEntity nodeScript)
|
||||
{
|
||||
if (nodeScript == null)
|
||||
return;
|
||||
|
||||
foreach (NodeEntity node in nodeScript.Nodes)
|
||||
{
|
||||
if (node.Type == "NumericEasingNode")
|
||||
node.Type = "NumericTransitionNode";
|
||||
else if (node.Type == "ColorGradientEasingNode")
|
||||
node.Type = "ColorGradientTransitionNode";
|
||||
else if (node.Type == "SKColorEasingNode")
|
||||
node.Type = "SKColorTransitionNode";
|
||||
else if (node.Type == "EasingTypeNode")
|
||||
node.Type = "EasingFunctionNode";
|
||||
}
|
||||
}
|
||||
|
||||
private void MigratePropertyGroup(PropertyGroupEntity propertyGroup)
|
||||
{
|
||||
if (propertyGroup == null)
|
||||
return;
|
||||
|
||||
foreach (PropertyGroupEntity childPropertyGroup in propertyGroup.PropertyGroups)
|
||||
MigratePropertyGroup(childPropertyGroup);
|
||||
foreach (PropertyEntity property in propertyGroup.Properties)
|
||||
MigrateNodeScript(property.DataBinding?.NodeScript);
|
||||
}
|
||||
|
||||
private void MigrateDisplayCondition(IConditionEntity conditionEntity)
|
||||
{
|
||||
if (conditionEntity is EventConditionEntity eventConditionEntity)
|
||||
MigrateNodeScript(eventConditionEntity.Script);
|
||||
else if (conditionEntity is StaticConditionEntity staticConditionEntity)
|
||||
MigrateNodeScript(staticConditionEntity.Script);
|
||||
}
|
||||
|
||||
public int UserVersion => 22;
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
// Migrate profile configuration display conditions
|
||||
List<ProfileCategoryEntity> categories = repository.Query<ProfileCategoryEntity>().ToList();
|
||||
foreach (ProfileCategoryEntity profileCategoryEntity in categories)
|
||||
{
|
||||
foreach (ProfileConfigurationEntity profileConfigurationEntity in profileCategoryEntity.ProfileConfigurations)
|
||||
MigrateNodeScript(profileConfigurationEntity.ActivationCondition);
|
||||
repository.Update(profileCategoryEntity);
|
||||
}
|
||||
|
||||
// Migrate profile display conditions and data bindings
|
||||
List<ProfileEntity> profiles = repository.Query<ProfileEntity>().ToList();
|
||||
foreach (ProfileEntity profileEntity in profiles)
|
||||
{
|
||||
foreach (LayerEntity layer in profileEntity.Layers)
|
||||
{
|
||||
MigratePropertyGroup(layer.LayerBrush?.PropertyGroup);
|
||||
MigratePropertyGroup(layer.GeneralPropertyGroup);
|
||||
MigratePropertyGroup(layer.TransformPropertyGroup);
|
||||
foreach (LayerEffectEntity layerEffectEntity in layer.LayerEffects)
|
||||
MigratePropertyGroup(layerEffectEntity?.PropertyGroup);
|
||||
MigrateDisplayCondition(layer.DisplayCondition);
|
||||
}
|
||||
|
||||
foreach (FolderEntity folder in profileEntity.Folders)
|
||||
{
|
||||
foreach (LayerEffectEntity folderLayerEffect in folder.LayerEffects)
|
||||
MigratePropertyGroup(folderLayerEffect?.PropertyGroup);
|
||||
MigrateDisplayCondition(folder.DisplayCondition);
|
||||
}
|
||||
|
||||
repository.Update(profileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing;
|
||||
|
||||
[Node("Easing Type", "Outputs a selectable easing type.", "Easing", OutputType = typeof(Easings.Functions))]
|
||||
public class EasingTypeNode : Node<Easings.Functions, EasingTypeNodeCustomViewModel>
|
||||
{
|
||||
public EasingTypeNode()
|
||||
{
|
||||
Output = CreateOutputPin<Easings.Functions>();
|
||||
}
|
||||
|
||||
public OutputPin<Easings.Functions> Output { get; }
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
|
||||
public class EasingTypeNodeCustomView : ReactiveUserControl<EasingTypeNodeCustomViewModel>
|
||||
{
|
||||
public EasingTypeNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,7 @@
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics;
|
||||
|
||||
[Node("Normalize", "Normalizes the number into range between 0-1",
|
||||
"Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
[Node("Normalize", "Normalizes the number into range between 0-1", "Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
public class NormalizeNode : Node
|
||||
{
|
||||
public InputPin<Numeric> Input { get; }
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing;
|
||||
namespace Artemis.VisualScripting.Nodes.Mathematics;
|
||||
|
||||
[Node("Numeric Easing", "Interpolates a value from 0-1 to 0-1 with the given function",
|
||||
"Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
[Node("Numeric Easing", "Interpolates a value from 0-1 to 0-1 with the given function", "Mathematics", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
public class NumericEasingNode : Node
|
||||
{
|
||||
public InputPin<Numeric> Input { get; }
|
||||
@ -15,7 +14,7 @@ public class NumericEasingNode : Node
|
||||
public NumericEasingNode()
|
||||
{
|
||||
Input = CreateInputPin<Numeric>("Input");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("EasingFunction");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("Function");
|
||||
|
||||
Result = CreateOutputPin<Numeric>();
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing;
|
||||
namespace Artemis.VisualScripting.Nodes.Transition;
|
||||
|
||||
[Node("Color Gradient Easing", "Outputs an eased color gradient value", "Easing", InputType = typeof(ColorGradient), OutputType = typeof(ColorGradient))]
|
||||
public class ColorGradientEasingNode : Node
|
||||
[Node("Color Gradient Transition", "Outputs smoothly transitioned changes to the input color gradient", "Transition", InputType = typeof(ColorGradient), OutputType = typeof(ColorGradient))]
|
||||
public class ColorGradientTransitionNode : Node
|
||||
{
|
||||
private DateTime _lastEvaluate = DateTime.MinValue;
|
||||
private float _progress;
|
||||
@ -11,11 +11,11 @@ public class ColorGradientEasingNode : Node
|
||||
private ColorGradient? _sourceValue;
|
||||
private ColorGradient? _targetValue;
|
||||
|
||||
public ColorGradientEasingNode()
|
||||
public ColorGradientTransitionNode()
|
||||
{
|
||||
Input = CreateInputPin<ColorGradient>();
|
||||
EasingTime = CreateInputPin<Numeric>("delay");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("function");
|
||||
EasingTime = CreateInputPin<Numeric>("Delay");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("Function");
|
||||
|
||||
Output = CreateOutputPin<ColorGradient>();
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Nodes.Transition.Screens;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Transition;
|
||||
|
||||
[Node("Easing Function", "Outputs a selectable easing function", "Transition", OutputType = typeof(Easings.Functions))]
|
||||
public class EasingFunctionNode : Node<Easings.Functions, EasingFunctionNodeCustomViewModel>
|
||||
{
|
||||
public EasingFunctionNode()
|
||||
{
|
||||
Output = CreateOutputPin<Easings.Functions>();
|
||||
}
|
||||
|
||||
public OutputPin<Easings.Functions> Output { get; }
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Output.Value = Storage;
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing;
|
||||
namespace Artemis.VisualScripting.Nodes.Transition;
|
||||
|
||||
[Node("Numeric Transition", "Outputs an eased numeric value", "Easing", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
[Node("Numeric Transition", "Outputs smoothly transitioned changes to the input numeric value", "Transition", InputType = typeof(Numeric), OutputType = typeof(Numeric))]
|
||||
public class NumericTransitionNode : Node
|
||||
{
|
||||
private float _currentValue;
|
||||
@ -14,8 +14,8 @@ public class NumericTransitionNode : Node
|
||||
public NumericTransitionNode()
|
||||
{
|
||||
Input = CreateInputPin<Numeric>();
|
||||
EasingTime = CreateInputPin<Numeric>("delay");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("function");
|
||||
EasingTime = CreateInputPin<Numeric>("Delay");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("Function");
|
||||
|
||||
Output = CreateOutputPin<Numeric>();
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
using Artemis.Core;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing;
|
||||
namespace Artemis.VisualScripting.Nodes.Transition;
|
||||
|
||||
[Node("Color Easing", "Outputs an eased color value", "Easing", InputType = typeof(SKColor), OutputType = typeof(SKColor))]
|
||||
public class SKColorEasingNode : Node
|
||||
[Node("Color Transition", "Outputs smoothly transitioned changes to the input color", "Transition", InputType = typeof(SKColor), OutputType = typeof(SKColor))]
|
||||
public class SKColorTransitionNode : Node
|
||||
{
|
||||
private SKColor _currentValue;
|
||||
private DateTime _lastEvaluate = DateTime.MinValue;
|
||||
@ -12,11 +12,11 @@ public class SKColorEasingNode : Node
|
||||
private SKColor _sourceValue;
|
||||
private SKColor _targetValue;
|
||||
|
||||
public SKColorEasingNode()
|
||||
public SKColorTransitionNode()
|
||||
{
|
||||
Input = CreateInputPin<SKColor>();
|
||||
EasingTime = CreateInputPin<Numeric>("delay");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("function");
|
||||
EasingTime = CreateInputPin<Numeric>("Delay");
|
||||
EasingFunction = CreateInputPin<Easings.Functions>("Function");
|
||||
|
||||
Output = CreateOutputPin<SKColor>();
|
||||
}
|
||||
@ -2,9 +2,9 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Easing.Screens"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Transition.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Easing.Screens.EasingTypeNodeCustomView"
|
||||
x:DataType="screens:EasingTypeNodeCustomViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Transition.Screens.EasingFunctionNodeCustomView"
|
||||
x:DataType="screens:EasingFunctionNodeCustomViewModel">
|
||||
<ComboBox Classes="condensed" MinWidth="75" Items="{CompiledBinding EasingViewModels}" SelectedItem="{CompiledBinding SelectedEasingViewModel}" />
|
||||
</UserControl>
|
||||
@ -0,0 +1,17 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Transition.Screens;
|
||||
|
||||
public class EasingFunctionNodeCustomView : ReactiveUserControl<EasingFunctionNodeCustomViewModel>
|
||||
{
|
||||
public EasingFunctionNodeCustomView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@ -5,26 +5,26 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Artemis.UI.Shared.VisualScripting;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
namespace Artemis.VisualScripting.Nodes.Transition.Screens;
|
||||
|
||||
public class EasingTypeNodeCustomViewModel : CustomNodeViewModel
|
||||
public class EasingFunctionNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly EasingTypeNode _node;
|
||||
private readonly EasingFunctionNode _node;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
|
||||
public EasingTypeNodeCustomViewModel(EasingTypeNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
public EasingFunctionNodeCustomViewModel(EasingFunctionNode node, INodeScript script, INodeEditorService nodeEditorService) : base(node, script)
|
||||
{
|
||||
_node = node;
|
||||
_nodeEditorService = nodeEditorService;
|
||||
|
||||
NodeModified += (_, _) => this.RaisePropertyChanged(nameof(SelectedEasingViewModel));
|
||||
EasingViewModels =
|
||||
new ObservableCollection<EasingTypeNodeEasingViewModel>(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(e => new EasingTypeNodeEasingViewModel(e)));
|
||||
new ObservableCollection<EasingFunctionViewModel>(Enum.GetValues(typeof(Easings.Functions)).Cast<Easings.Functions>().Select(e => new EasingFunctionViewModel(e)));
|
||||
}
|
||||
|
||||
public ObservableCollection<EasingTypeNodeEasingViewModel> EasingViewModels { get; }
|
||||
public ObservableCollection<EasingFunctionViewModel> EasingViewModels { get; }
|
||||
|
||||
public EasingTypeNodeEasingViewModel? SelectedEasingViewModel
|
||||
public EasingFunctionViewModel? SelectedEasingViewModel
|
||||
{
|
||||
get => EasingViewModels.FirstOrDefault(e => e.EasingFunction == _node.Storage);
|
||||
set
|
||||
@ -2,10 +2,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Easing.Screens"
|
||||
xmlns:screens="clr-namespace:Artemis.VisualScripting.Nodes.Transition.Screens"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.VisualScripting.Nodes.Easing.Screens.EasingTypeNodeEasingView"
|
||||
x:DataType="screens:EasingTypeNodeEasingViewModel">
|
||||
x:Class="Artemis.VisualScripting.Nodes.Transition.Screens.EasingFunctionView"
|
||||
x:DataType="screens:EasingFunctionViewModel">
|
||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||
<Polyline Stroke="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
StrokeThickness="1"
|
||||
@ -1,11 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
namespace Artemis.VisualScripting.Nodes.Transition.Screens;
|
||||
|
||||
public class EasingTypeNodeEasingView : UserControl
|
||||
public class EasingFunctionView : UserControl
|
||||
{
|
||||
public EasingTypeNodeEasingView()
|
||||
public EasingFunctionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@ -3,11 +3,11 @@ using Artemis.UI.Shared;
|
||||
using Avalonia;
|
||||
using Humanizer;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.Easing.Screens;
|
||||
namespace Artemis.VisualScripting.Nodes.Transition.Screens;
|
||||
|
||||
public class EasingTypeNodeEasingViewModel : ViewModelBase
|
||||
public class EasingFunctionViewModel : ViewModelBase
|
||||
{
|
||||
public EasingTypeNodeEasingViewModel(Easings.Functions easingFunction)
|
||||
public EasingFunctionViewModel(Easings.Functions easingFunction)
|
||||
{
|
||||
EasingFunction = easingFunction;
|
||||
Description = easingFunction.Humanize();
|
||||
Loading…
x
Reference in New Issue
Block a user