From 38a2b020e127415d33e7737c264e0cf487644824 Mon Sep 17 00:00:00 2001 From: Yuto Terada Date: Sat, 30 Nov 2024 13:14:07 +0900 Subject: [PATCH 1/2] feat: add IPublishOperator interface and implement it in PublishOperator class --- src/Beutl.ProjectSystem/Operation/IPublishOperator.cs | 8 ++++++++ src/Beutl.ProjectSystem/Operation/PublishOperator.cs | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/Beutl.ProjectSystem/Operation/IPublishOperator.cs diff --git a/src/Beutl.ProjectSystem/Operation/IPublishOperator.cs b/src/Beutl.ProjectSystem/Operation/IPublishOperator.cs new file mode 100644 index 000000000..c195413eb --- /dev/null +++ b/src/Beutl.ProjectSystem/Operation/IPublishOperator.cs @@ -0,0 +1,8 @@ +using Beutl.Graphics.Rendering; + +namespace Beutl.Operation; + +public interface IPublishOperator +{ + Renderable Value { get; } +} diff --git a/src/Beutl.ProjectSystem/Operation/PublishOperator.cs b/src/Beutl.ProjectSystem/Operation/PublishOperator.cs index 91fe25c6e..f845a3725 100644 --- a/src/Beutl.ProjectSystem/Operation/PublishOperator.cs +++ b/src/Beutl.ProjectSystem/Operation/PublishOperator.cs @@ -31,7 +31,7 @@ public static implicit operator PropertyWithDefaultValue(CoreProperty property) } } -public abstract class PublishOperator : SourceOperator +public abstract class PublishOperator : SourceOperator, IPublishOperator where T : Renderable, new() { public static readonly CoreProperty ValueProperty; @@ -64,6 +64,8 @@ public T Value set => SetAndRaise(ValueProperty, ref _value, value); } + Renderable IPublishOperator.Value => Value; + public override EvaluationTarget GetEvaluationTarget() => _evaluationTarget; public override void Evaluate(OperatorEvaluationContext context) @@ -166,7 +168,8 @@ protected override void OnPropertyChanged(PropertyChangedEventArgs args) } catch { - value = TypeDescriptor.GetConverter(value!.GetType()).ConvertTo(value, propertyType); + value = TypeDescriptor.GetConverter(value!.GetType()) + .ConvertTo(value, propertyType); } } From c6fbea2ab7a7d945cf5c4a02f917989fe4103691 Mon Sep 17 00:00:00 2001 From: Yuto Terada Date: Sat, 30 Nov 2024 13:14:16 +0900 Subject: [PATCH 2/2] feat: update SourceOperator type to IPublishOperator in PathEditorViewModel and PathEditorTabViewModel --- src/Beutl/ViewModels/PathEditorViewModel.cs | 6 +++--- src/Beutl/ViewModels/Tools/PathEditorTabViewModel.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Beutl/ViewModels/PathEditorViewModel.cs b/src/Beutl/ViewModels/PathEditorViewModel.cs index c249ab02e..ef41049e4 100644 --- a/src/Beutl/ViewModels/PathEditorViewModel.cs +++ b/src/Beutl/ViewModels/PathEditorViewModel.cs @@ -43,10 +43,10 @@ public PathEditorViewModel(EditViewModel editViewModel, PlayerViewModel playerVi Element = Context.Select(v => v?.GetService()) .ToReadOnlyReactivePropertySlim() .DisposeWith(_disposables); - SourceOperator = Context.Select(v => v?.GetService() as StyledSourcePublisher) + SourceOperator = Context.Select(v => v?.GetService() as IPublishOperator) .ToReadOnlyReactivePropertySlim() .DisposeWith(_disposables); - Drawable = SourceOperator.Select(v => v?.Instance?.Target as Drawable) + Drawable = SourceOperator.Select(v => v?.Value as Drawable) .ToReadOnlyReactivePropertySlim() .DisposeWith(_disposables); @@ -129,7 +129,7 @@ private Matrix CalculateMatrix(Drawable drawable, Geometry? geometry) public IReadOnlyReactiveProperty Element { get; } - public ReadOnlyReactivePropertySlim SourceOperator { get; } + public ReadOnlyReactivePropertySlim SourceOperator { get; } public ReadOnlyReactivePropertySlim Drawable { get; } diff --git a/src/Beutl/ViewModels/Tools/PathEditorTabViewModel.cs b/src/Beutl/ViewModels/Tools/PathEditorTabViewModel.cs index f35cfcd3e..4a2556e65 100644 --- a/src/Beutl/ViewModels/Tools/PathEditorTabViewModel.cs +++ b/src/Beutl/ViewModels/Tools/PathEditorTabViewModel.cs @@ -38,7 +38,7 @@ public PathEditorTabViewModel(EditViewModel editViewModel) Element = Context.Select(v => v?.GetService()) .ToReadOnlyReactivePropertySlim() .DisposeWith(_disposables); - SourceOperator = Context.Select(v => v?.GetService() as StyledSourcePublisher) + SourceOperator = Context.Select(v => v?.GetService() as IPublishOperator) .ToReadOnlyReactivePropertySlim() .DisposeWith(_disposables); @@ -63,7 +63,7 @@ public PathEditorTabViewModel(EditViewModel editViewModel) public IReadOnlyReactiveProperty Element { get; } - public ReadOnlyReactivePropertySlim SourceOperator { get; } + public ReadOnlyReactivePropertySlim SourceOperator { get; } public IReactiveProperty SelectedOperation { get; } = new ReactiveProperty();