1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 06:42:54 +08:00

Hide drag handles of all playlist items not currently being dragged

This commit is contained in:
Dean Herbert 2020-02-06 18:38:00 +09:00
parent 0c30e802c0
commit 48350638a2
2 changed files with 25 additions and 1 deletions

View File

@ -18,6 +18,11 @@ namespace osu.Game.Overlays.Music
public readonly Bindable<BeatmapSetInfo> SelectedSet = new Bindable<BeatmapSetInfo>(); public readonly Bindable<BeatmapSetInfo> SelectedSet = new Bindable<BeatmapSetInfo>();
/// <summary>
/// Whether any item is currently being dragged. Used to hide other items' drag handles.
/// </summary>
private readonly BindableBool playlistDragActive = new BindableBool();
public new MarginPadding Padding public new MarginPadding Padding
{ {
get => base.Padding; get => base.Padding;
@ -31,6 +36,7 @@ namespace osu.Game.Overlays.Music
protected override RearrangeableListItem<BeatmapSetInfo> CreateDrawable(BeatmapSetInfo item) => new PlaylistItem(item) protected override RearrangeableListItem<BeatmapSetInfo> CreateDrawable(BeatmapSetInfo item) => new PlaylistItem(item)
{ {
SelectedSet = { BindTarget = SelectedSet }, SelectedSet = { BindTarget = SelectedSet },
PlaylistDragActive = { BindTarget = playlistDragActive },
RequestSelection = set => RequestSelection?.Invoke(set) RequestSelection = set => RequestSelection?.Invoke(set)
}; };

View File

@ -23,7 +23,10 @@ namespace osu.Game.Overlays.Music
{ {
private const float fade_duration = 100; private const float fade_duration = 100;
public BindableBool PlaylistDragActive = new BindableBool();
public readonly Bindable<BeatmapSetInfo> SelectedSet = new Bindable<BeatmapSetInfo>(); public readonly Bindable<BeatmapSetInfo> SelectedSet = new Bindable<BeatmapSetInfo>();
public Action<BeatmapSetInfo> RequestSelection; public Action<BeatmapSetInfo> RequestSelection;
private PlaylistItemHandle handle; private PlaylistItemHandle handle;
@ -122,11 +125,26 @@ namespace osu.Game.Overlays.Music
return true; return true;
} }
protected override bool OnDragStart(DragStartEvent e)
{
if (!base.OnDragStart(e))
return false;
PlaylistDragActive.Value = true;
return true;
}
protected override void OnDragEnd(DragEndEvent e)
{
PlaylistDragActive.Value = false;
base.OnDragEnd(e);
}
protected override bool IsDraggableAt(Vector2 screenSpacePos) => handle.HandlingDrag; protected override bool IsDraggableAt(Vector2 screenSpacePos) => handle.HandlingDrag;
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
handle.UpdateHoverState(true); handle.UpdateHoverState(IsDragged || !PlaylistDragActive.Value);
return base.OnHover(e); return base.OnHover(e);
} }