-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: avoid using setters in Node
- Loading branch information
Showing
9 changed files
with
316 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Beutl.Media; | ||
using Beutl.Serialization; | ||
|
||
namespace Beutl.NodeTree; | ||
|
||
public sealed class DefaultInputSocket<T> : InputSocket<T>, IDefaultInputSocket | ||
{ | ||
public void SetPropertyAdapter(NodePropertyAdapter<T> property) | ||
{ | ||
Property = property; | ||
property.Invalidated += OnAdapterInvalidated; | ||
} | ||
|
||
void IDefaultInputSocket.SetPropertyAdapter(object property) | ||
{ | ||
var obj = (NodePropertyAdapter<T>)property; | ||
Property = obj; | ||
obj.Invalidated += OnAdapterInvalidated; | ||
} | ||
|
||
private void OnAdapterInvalidated(object? sender, EventArgs e) | ||
{ | ||
RaiseInvalidated(new RenderInvalidatedEventArgs(this)); | ||
} | ||
|
||
public NodePropertyAdapter<T>? GetProperty() | ||
{ | ||
return Property as NodePropertyAdapter<T>; | ||
} | ||
|
||
public override void Serialize(ICoreSerializationContext context) | ||
{ | ||
base.Serialize(context); | ||
GetProperty()?.Serialize(context); | ||
} | ||
|
||
public override void Deserialize(ICoreSerializationContext context) | ||
{ | ||
base.Deserialize(context); | ||
GetProperty()?.Deserialize(context); | ||
} | ||
} |
16 changes: 7 additions & 9 deletions
16
...ojectSystem/NodeTree/NodeItemForSetter.cs → ...ProjectSystem/NodeTree/DefaultNodeItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tSystem/NodeTree/IInputSocketForSetter.cs → ...ectSystem/NodeTree/IDefaultInputSocket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.