|
@@ -5,9 +5,21 @@ namespace PixiEditor.ChangeableDocument.Changeables.Graph;
|
|
|
|
|
|
public class InputProperty : IInputProperty
|
|
|
{
|
|
|
+ private object _internalValue;
|
|
|
public string InternalPropertyName { get; }
|
|
|
public string DisplayName { get; }
|
|
|
- public object Value { get; set; }
|
|
|
+
|
|
|
+ public object Value
|
|
|
+ {
|
|
|
+ get => Connection != null ? Connection.Value : _internalValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ public object NonOverridenValue
|
|
|
+ {
|
|
|
+ get => _internalValue;
|
|
|
+ set => _internalValue = value;
|
|
|
+ }
|
|
|
+
|
|
|
public Node Node { get; }
|
|
|
public Type ValueType { get; }
|
|
|
IReadOnlyNode INodeProperty.Node => Node;
|
|
@@ -18,22 +30,22 @@ public class InputProperty : IInputProperty
|
|
|
{
|
|
|
InternalPropertyName = internalName;
|
|
|
DisplayName = displayName;
|
|
|
- Value = defaultValue;
|
|
|
+ _internalValue = defaultValue;
|
|
|
Node = node;
|
|
|
ValueType = valueType;
|
|
|
}
|
|
|
|
|
|
public InputProperty Clone(Node forNode)
|
|
|
{
|
|
|
- if(Value is ICloneable cloneable)
|
|
|
+ if(NonOverridenValue is ICloneable cloneable)
|
|
|
return new InputProperty(forNode, InternalPropertyName, DisplayName, cloneable.Clone(), ValueType);
|
|
|
|
|
|
- if (Value is Enum enumVal)
|
|
|
+ if (NonOverridenValue is Enum enumVal)
|
|
|
{
|
|
|
return new InputProperty(forNode, InternalPropertyName, DisplayName, enumVal, ValueType);
|
|
|
}
|
|
|
|
|
|
- if (Value is null)
|
|
|
+ if (NonOverridenValue is null)
|
|
|
{
|
|
|
object? nullValue = null;
|
|
|
if (ValueType.IsValueType)
|
|
@@ -44,10 +56,10 @@ public class InputProperty : IInputProperty
|
|
|
return new InputProperty(forNode, InternalPropertyName, DisplayName, nullValue, ValueType);
|
|
|
}
|
|
|
|
|
|
- if(!Value.GetType().IsPrimitive && Value.GetType() != typeof(string))
|
|
|
+ if(!NonOverridenValue.GetType().IsPrimitive && NonOverridenValue.GetType() != typeof(string))
|
|
|
throw new InvalidOperationException("Value is not cloneable and not a primitive type");
|
|
|
|
|
|
- return new InputProperty(forNode, InternalPropertyName, DisplayName, Value, ValueType);
|
|
|
+ return new InputProperty(forNode, InternalPropertyName, DisplayName, NonOverridenValue, ValueType);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -57,7 +69,12 @@ public class InputProperty<T> : InputProperty, IInputProperty<T>
|
|
|
public new T Value
|
|
|
{
|
|
|
get => (T)base.Value;
|
|
|
- set => base.Value = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public T NonOverridenValue
|
|
|
+ {
|
|
|
+ get => (T)base.NonOverridenValue;
|
|
|
+ set => base.NonOverridenValue = value;
|
|
|
}
|
|
|
|
|
|
internal InputProperty(Node node, string internalName, string displayName, T defaultValue) : base(node, internalName, displayName, defaultValue, typeof(T))
|