mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Add scrolling for long difficulty lists in beatmap card
This commit is contained in:
parent
af35652b8b
commit
0f74389389
@ -3,13 +3,17 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -24,7 +28,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
|
|
||||||
public Drawable Dropdown
|
public Drawable Dropdown
|
||||||
{
|
{
|
||||||
set => dropdownContent.Child = value;
|
set => dropdownScroll.Child = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bindable<bool> Expanded { get; } = new BindableBool();
|
public Bindable<bool> Expanded { get; } = new BindableBool();
|
||||||
@ -33,6 +37,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
private readonly Container bodyContent;
|
private readonly Container bodyContent;
|
||||||
private readonly Container dropdownContent;
|
private readonly Container dropdownContent;
|
||||||
|
private readonly OsuScrollContainer dropdownScroll;
|
||||||
private readonly Container borderContainer;
|
private readonly Container borderContainer;
|
||||||
|
|
||||||
public BeatmapCardDropdown(float height)
|
public BeatmapCardDropdown(float height)
|
||||||
@ -71,7 +76,12 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
keep();
|
keep();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Unhovered = _ => checkForHide()
|
Unhovered = _ => checkForHide(),
|
||||||
|
Child = dropdownScroll = new DropdownScrollContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
ScrollbarVisible = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
borderContainer = new Container
|
borderContainer = new Container
|
||||||
{
|
{
|
||||||
@ -168,5 +178,54 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
Hollow = true,
|
Hollow = true,
|
||||||
}, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
}, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DropdownScrollContainer : OsuScrollContainer
|
||||||
|
{
|
||||||
|
public DropdownScrollContainer()
|
||||||
|
{
|
||||||
|
ScrollbarVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Height = Math.Min(Content.DrawHeight, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool allowScroll => !Precision.AlmostEquals(DrawSize, Content.DrawSize);
|
||||||
|
|
||||||
|
protected override bool OnDragStart(DragStartEvent e)
|
||||||
|
{
|
||||||
|
if (!allowScroll)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return base.OnDragStart(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDrag(DragEvent e)
|
||||||
|
{
|
||||||
|
if (!allowScroll)
|
||||||
|
return;
|
||||||
|
|
||||||
|
base.OnDrag(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDragEnd(DragEndEvent e)
|
||||||
|
{
|
||||||
|
if (!allowScroll)
|
||||||
|
return;
|
||||||
|
|
||||||
|
base.OnDragEnd(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnScroll(ScrollEvent e)
|
||||||
|
{
|
||||||
|
if (!allowScroll)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return base.OnScroll(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user