Refactor channel scrolling container to handle manual scrolls resiliently

This commit is contained in:
Salman Ahmed
2022-03-04 23:23:58 +03:00
parent 4de66bb1c6
commit 5b3ffb12b7
3 changed files with 49 additions and 18 deletions

View File

@ -25,8 +25,6 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public bool UserScrolling { get; private set; }
public void CancelUserScroll() => UserScrolling = false;
public UserTrackingScrollContainer()
{
}
@ -38,26 +36,37 @@ namespace osu.Game.Graphics.Containers
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
{
UserScrolling = true;
base.OnUserScroll(value, animated, distanceDecay);
OnScrollChange(true);
}
public new void ScrollIntoView(Drawable target, bool animated = true)
{
UserScrolling = false;
base.ScrollIntoView(target, animated);
OnScrollChange(false);
}
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
{
UserScrolling = false;
base.ScrollTo(value, animated, distanceDecay);
OnScrollChange(false);
}
public new void ScrollToStart(bool animated = true, bool allowDuringDrag = false)
{
base.ScrollToStart(animated, allowDuringDrag);
OnScrollChange(false);
}
public new void ScrollToEnd(bool animated = true, bool allowDuringDrag = false)
{
UserScrolling = false;
base.ScrollToEnd(animated, allowDuringDrag);
OnScrollChange(false);
}
/// <summary>
/// Invoked when any scroll has been performed either automatically or by user.
/// </summary>
protected virtual void OnScrollChange(bool byUser) => UserScrolling = byUser;
}
}