-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2509 from erri120/feat/composite-2
Rework TreeDataGrid for Loadouts
- Loading branch information
Showing
41 changed files
with
713 additions
and
894 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
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
50 changes: 50 additions & 0 deletions
50
src/NexusMods.App.UI/Controls/TreeDataGrid/ImageComponent.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Avalonia.Media.Imaging; | ||
using BitFaster.Caching; | ||
using JetBrains.Annotations; | ||
using NexusMods.Abstractions.Resources; | ||
using R3; | ||
|
||
namespace NexusMods.App.UI.Controls; | ||
|
||
/// <summary> | ||
/// Component for <see cref="Bitmap"/>. | ||
/// </summary> | ||
[PublicAPI] | ||
public sealed class ImageComponent : AValueComponent<Bitmap>, IItemModelComponent<ImageComponent>, IComparable<ImageComponent> | ||
{ | ||
/// <inheritdoc/> | ||
public int CompareTo(ImageComponent? other) => other is null ? 1 : 0; | ||
|
||
/// <inheritdoc/> | ||
public ImageComponent( | ||
Bitmap initialValue, | ||
IObservable<Bitmap> valueObservable, | ||
bool subscribeWhenCreated = false) : base(initialValue, valueObservable, subscribeWhenCreated) { } | ||
|
||
/// <inheritdoc/> | ||
public ImageComponent( | ||
Bitmap initialValue, | ||
Observable<Bitmap> valueObservable, | ||
bool subscribeWhenCreated = false) : base(initialValue, valueObservable, subscribeWhenCreated) { } | ||
|
||
/// <inheritdoc/> | ||
public ImageComponent(Bitmap value) : base(value) { } | ||
|
||
public static ImageComponent FromPipeline<TId>( | ||
IResourceLoader<TId, Bitmap> pipeline, | ||
TId id, | ||
Bitmap initialValue) | ||
where TId : notnull | ||
{ | ||
var observable = Observable | ||
.Return(id) | ||
.ObserveOnThreadPool() | ||
.SelectAwait(async (_, cancellationToken) => await pipeline.LoadResourceAsync(id, cancellationToken), configureAwait: false) | ||
.Select(static resource => resource.Data); | ||
|
||
return new ImageComponent( | ||
initialValue: initialValue, | ||
valueObservable: observable | ||
); | ||
} | ||
} |
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.