Remove OnAdd/OnRemove of HitObjectContainer

Instead, override `AddDrawable`/`RemoveDrawable`.
This commit is contained in:
ekrctb
2021-05-31 23:07:32 +09:00
parent 0ce7baa3f3
commit b321b20e9d
2 changed files with 20 additions and 35 deletions

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Layout;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
@ -140,17 +142,20 @@ namespace osu.Game.Rulesets.UI.Scrolling
}
}
protected override void OnAdd(DrawableHitObject drawableHitObject)
protected override void AddDrawable(HitObjectLifetimeEntry entry, DrawableHitObject drawable)
{
invalidateHitObject(drawableHitObject);
drawableHitObject.DefaultsApplied += invalidateHitObject;
base.AddDrawable(entry, drawable);
invalidateHitObject(drawable);
drawable.DefaultsApplied += invalidateHitObject;
}
protected override void OnRemove(DrawableHitObject drawableHitObject)
protected override void RemoveDrawable(HitObjectLifetimeEntry entry, DrawableHitObject drawable)
{
layoutComputed.Remove(drawableHitObject);
base.RemoveDrawable(entry, drawable);
drawableHitObject.DefaultsApplied -= invalidateHitObject;
drawable.DefaultsApplied -= invalidateHitObject;
layoutComputed.Remove(drawable);
}
private void invalidateHitObject(DrawableHitObject hitObject)
@ -199,6 +204,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
private double computeOriginAdjustedLifetimeStart(DrawableHitObject hitObject)
{
// Origin position may be relative to the parent size
Debug.Assert(hitObject.Parent != null);
float originAdjustment = 0.0f;
// calculate the dimension of the part of the hitobject that should already be visible