Skip to content

Commit

Permalink
Enable NRT for RearrangeableListContainer<>
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Nov 15, 2024
1 parent abd8aab commit c383b67
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions osu.Framework/Graphics/Containers/RearrangeableListContainer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
Expand All @@ -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;

Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -193,7 +192,7 @@ private void sortItems()
if (drawable.Parent != ListContainer)
continue;

ListContainer!.SetLayoutPosition(drawable, i);
ListContainer.SetLayoutPosition(drawable, i);
}
}

Expand All @@ -218,9 +217,7 @@ protected override void Update()
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();

if (currentlyDraggedItem != null)
updateArrangement();
updateArrangement();
}

private void updateScrollPosition()
Expand All @@ -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);

Expand Down

0 comments on commit c383b67

Please sign in to comment.