Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPublishOperator interface and update related classes #1187

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Beutl.ProjectSystem/Operation/IPublishOperator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Beutl.Graphics.Rendering;

namespace Beutl.Operation;

public interface IPublishOperator
{
Renderable Value { get; }
}
7 changes: 5 additions & 2 deletions src/Beutl.ProjectSystem/Operation/PublishOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static implicit operator PropertyWithDefaultValue(CoreProperty property)
}
}

public abstract class PublishOperator<T> : SourceOperator
public abstract class PublishOperator<T> : SourceOperator, IPublishOperator
where T : Renderable, new()
{
public static readonly CoreProperty<T> ValueProperty;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Beutl/ViewModels/PathEditorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public PathEditorViewModel(EditViewModel editViewModel, PlayerViewModel playerVi
Element = Context.Select(v => v?.GetService<Element>())
.ToReadOnlyReactivePropertySlim()
.DisposeWith(_disposables);
SourceOperator = Context.Select(v => v?.GetService<SourceOperator>() as StyledSourcePublisher)
SourceOperator = Context.Select(v => v?.GetService<SourceOperator>() 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);

Expand Down Expand Up @@ -129,7 +129,7 @@ private Matrix CalculateMatrix(Drawable drawable, Geometry? geometry)

public IReadOnlyReactiveProperty<Element?> Element { get; }

public ReadOnlyReactivePropertySlim<StyledSourcePublisher?> SourceOperator { get; }
public ReadOnlyReactivePropertySlim<IPublishOperator?> SourceOperator { get; }

public ReadOnlyReactivePropertySlim<Drawable?> Drawable { get; }

Expand Down
4 changes: 2 additions & 2 deletions src/Beutl/ViewModels/Tools/PathEditorTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public PathEditorTabViewModel(EditViewModel editViewModel)
Element = Context.Select(v => v?.GetService<Element>())
.ToReadOnlyReactivePropertySlim()
.DisposeWith(_disposables);
SourceOperator = Context.Select(v => v?.GetService<SourceOperator>() as StyledSourcePublisher)
SourceOperator = Context.Select(v => v?.GetService<SourceOperator>() as IPublishOperator)
.ToReadOnlyReactivePropertySlim()
.DisposeWith(_disposables);

Expand All @@ -63,7 +63,7 @@ public PathEditorTabViewModel(EditViewModel editViewModel)

public IReadOnlyReactiveProperty<Element?> Element { get; }

public ReadOnlyReactivePropertySlim<StyledSourcePublisher?> SourceOperator { get; }
public ReadOnlyReactivePropertySlim<IPublishOperator?> SourceOperator { get; }

public IReactiveProperty<PathSegment?> SelectedOperation { get; } = new ReactiveProperty<PathSegment?>();

Expand Down
Loading