Add a way to hide the drag handle

This commit is contained in:
smoogipoo 2020-02-14 16:09:15 +09:00
parent 5e871f9838
commit 1909ea2bd3
2 changed files with 17 additions and 2 deletions

View File

@ -23,6 +23,9 @@ namespace osu.Game.Graphics.Containers
private Color4 handleColour = Color4.White; private Color4 handleColour = Color4.White;
/// <summary>
/// The colour of the drag handle.
/// </summary>
protected Color4 HandleColour protected Color4 HandleColour
{ {
get => handleColour; get => handleColour;
@ -38,6 +41,11 @@ namespace osu.Game.Graphics.Containers
} }
} }
/// <summary>
/// Whether the drag handle should be shown.
/// </summary>
protected virtual bool ShowDragHandle => true;
private PlaylistItemHandle handle; private PlaylistItemHandle handle;
protected OsuRearrangeableListItem(TModel item) protected OsuRearrangeableListItem(TModel item)
@ -50,6 +58,8 @@ namespace osu.Game.Graphics.Containers
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Container handleContainer;
InternalChild = new GridContainer InternalChild = new GridContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -58,7 +68,7 @@ namespace osu.Game.Graphics.Containers
{ {
new[] new[]
{ {
new Container handleContainer = new Container
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -78,6 +88,9 @@ namespace osu.Game.Graphics.Containers
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) } RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
}; };
if (!ShowDragHandle)
handleContainer.Alpha = 0;
} }
protected override bool OnDragStart(DragStartEvent e) protected override bool OnDragStart(DragStartEvent e)
@ -107,7 +120,7 @@ namespace osu.Game.Graphics.Containers
protected abstract Drawable CreateContent(); protected abstract Drawable CreateContent();
private class PlaylistItemHandle : SpriteIcon public class PlaylistItemHandle : SpriteIcon
{ {
public bool HandlingDrag { get; private set; } public bool HandlingDrag { get; private set; }
private bool isHovering; private bool isHovering;

View File

@ -34,6 +34,8 @@ namespace osu.Game.Screens.Multi
public Action<PlaylistItem> RequestSelection; public Action<PlaylistItem> RequestSelection;
public Action<PlaylistItem> RequestDeletion; public Action<PlaylistItem> RequestDeletion;
protected override bool ShowDragHandle => allowEdit;
private Container maskingContainer; private Container maskingContainer;
private Container difficultyIconContainer; private Container difficultyIconContainer;
private LinkFlowContainer beatmapText; private LinkFlowContainer beatmapText;