2020-12-22 23:36:44 +08:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Containers
|
|
|
|
{
|
|
|
|
public class UserTrackingScrollContainer : UserTrackingScrollContainer<Drawable>
|
|
|
|
{
|
|
|
|
public UserTrackingScrollContainer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserTrackingScrollContainer(Direction direction)
|
|
|
|
: base(direction)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class UserTrackingScrollContainer<T> : OsuScrollContainer<T>
|
|
|
|
where T : Drawable
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the last scroll event was user triggered, directly on the scroll container.
|
|
|
|
/// </summary>
|
|
|
|
public bool UserScrolling { get; private set; }
|
|
|
|
|
|
|
|
public UserTrackingScrollContainer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserTrackingScrollContainer(Direction direction)
|
|
|
|
: base(direction)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
|
|
|
|
{
|
|
|
|
base.OnUserScroll(value, animated, distanceDecay);
|
2022-03-05 04:23:58 +08:00
|
|
|
OnScrollChange(true);
|
2020-12-22 23:36:44 +08:00
|
|
|
}
|
|
|
|
|
2021-08-20 16:40:41 +08:00
|
|
|
public new void ScrollIntoView(Drawable target, bool animated = true)
|
|
|
|
{
|
|
|
|
base.ScrollIntoView(target, animated);
|
2022-03-05 04:23:58 +08:00
|
|
|
OnScrollChange(false);
|
2021-08-20 16:40:41 +08:00
|
|
|
}
|
|
|
|
|
2020-12-22 23:36:44 +08:00
|
|
|
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
|
|
|
|
{
|
|
|
|
base.ScrollTo(value, animated, distanceDecay);
|
2022-03-05 04:23:58 +08:00
|
|
|
OnScrollChange(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public new void ScrollToStart(bool animated = true, bool allowDuringDrag = false)
|
|
|
|
{
|
|
|
|
base.ScrollToStart(animated, allowDuringDrag);
|
|
|
|
OnScrollChange(false);
|
2020-12-22 23:36:44 +08:00
|
|
|
}
|
2021-02-02 14:16:26 +08:00
|
|
|
|
|
|
|
public new void ScrollToEnd(bool animated = true, bool allowDuringDrag = false)
|
|
|
|
{
|
|
|
|
base.ScrollToEnd(animated, allowDuringDrag);
|
2022-03-05 04:23:58 +08:00
|
|
|
OnScrollChange(false);
|
2021-02-02 14:16:26 +08:00
|
|
|
}
|
2022-03-05 04:23:58 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2022-03-06 05:01:45 +08:00
|
|
|
/// Invoked when any scroll has been performed either programmatically or by user.
|
2022-03-05 04:23:58 +08:00
|
|
|
/// </summary>
|
|
|
|
protected virtual void OnScrollChange(bool byUser) => UserScrolling = byUser;
|
2020-12-22 23:36:44 +08:00
|
|
|
}
|
|
|
|
}
|