-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable NRT for
RearrangeableListContainer<>
- Loading branch information
Showing
1 changed file
with
8 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
|
@@ -21,6 +19,7 @@ namespace osu.Framework.Graphics.Containers | |
/// </remarks> | ||
/// <typeparam name="TModel">The type of rearrangeable item.</typeparam> | ||
public abstract partial class RearrangeableListContainer<TModel> : CompositeDrawable | ||
where TModel : notnull | ||
{ | ||
private const float exp_base = 1.05f; | ||
|
||
|
@@ -50,7 +49,7 @@ public abstract partial class RearrangeableListContainer<TModel> : CompositeDraw | |
protected IReadOnlyDictionary<TModel, RearrangeableListItem<TModel>> ItemMap => itemMap; | ||
|
||
private readonly Dictionary<TModel, RearrangeableListItem<TModel>> itemMap = new Dictionary<TModel, RearrangeableListItem<TModel>>(); | ||
private RearrangeableListItem<TModel> currentlyDraggedItem; | ||
private RearrangeableListItem<TModel>? currentlyDraggedItem; | ||
private Vector2 screenSpaceDragPosition; | ||
|
||
/// <summary> | ||
|
@@ -81,7 +80,7 @@ protected virtual void OnItemsChanged() | |
{ | ||
} | ||
|
||
private void collectionChanged(object sender, NotifyCollectionChangedEventArgs e) | ||
private void collectionChanged(object? sender, NotifyCollectionChangedEventArgs e) | ||
{ | ||
switch (e.Action) | ||
{ | ||
|
@@ -193,7 +192,7 @@ private void sortItems() | |
if (drawable.Parent != ListContainer) | ||
continue; | ||
|
||
ListContainer!.SetLayoutPosition(drawable, i); | ||
ListContainer.SetLayoutPosition(drawable, i); | ||
} | ||
} | ||
|
||
|
@@ -218,9 +217,7 @@ protected override void Update() | |
protected override void UpdateAfterChildren() | ||
{ | ||
base.UpdateAfterChildren(); | ||
|
||
if (currentlyDraggedItem != null) | ||
updateArrangement(); | ||
updateArrangement(); | ||
} | ||
|
||
private void updateScrollPosition() | ||
|
@@ -245,6 +242,9 @@ private void updateScrollPosition() | |
|
||
private void updateArrangement() | ||
{ | ||
if (currentlyDraggedItem == null) | ||
return; | ||
|
||
var localPos = ListContainer.ToLocalSpace(screenSpaceDragPosition); | ||
int srcIndex = Items.IndexOf(currentlyDraggedItem.Model); | ||
|
||
|