mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Make ShowDragHandle into a bindable
This commit is contained in:
parent
17e8171827
commit
1260e30cde
@ -12,13 +12,13 @@ namespace osu.Game.Graphics.Containers
|
||||
/// <summary>
|
||||
/// Whether any item is currently being dragged. Used to hide other items' drag handles.
|
||||
/// </summary>
|
||||
private readonly BindableBool playlistDragActive = new BindableBool();
|
||||
protected readonly BindableBool DragActive = new BindableBool();
|
||||
|
||||
protected override ScrollContainer<Drawable> CreateScrollContainer() => new OsuScrollContainer();
|
||||
|
||||
protected sealed override RearrangeableListItem<TModel> CreateDrawable(TModel item) => CreateOsuDrawable(item).With(d =>
|
||||
{
|
||||
d.PlaylistDragActive.BindTo(playlistDragActive);
|
||||
d.DragActive.BindTo(DragActive);
|
||||
});
|
||||
|
||||
protected abstract OsuRearrangeableListItem<TModel> CreateOsuDrawable(TModel item);
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Graphics.Containers
|
||||
/// <summary>
|
||||
/// Whether any item is currently being dragged. Used to hide other items' drag handles.
|
||||
/// </summary>
|
||||
public readonly BindableBool PlaylistDragActive = new BindableBool();
|
||||
public readonly BindableBool DragActive = new BindableBool();
|
||||
|
||||
private Color4 handleColour = Color4.White;
|
||||
|
||||
@ -44,8 +44,9 @@ namespace osu.Game.Graphics.Containers
|
||||
/// <summary>
|
||||
/// Whether the drag handle should be shown.
|
||||
/// </summary>
|
||||
protected virtual bool ShowDragHandle => true;
|
||||
protected readonly Bindable<bool> ShowDragHandle = new Bindable<bool>();
|
||||
|
||||
private Container handleContainer;
|
||||
private PlaylistItemHandle handle;
|
||||
|
||||
protected OsuRearrangeableListItem(TModel item)
|
||||
@ -58,8 +59,6 @@ namespace osu.Game.Graphics.Containers
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Container handleContainer;
|
||||
|
||||
InternalChild = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -88,9 +87,12 @@ namespace osu.Game.Graphics.Containers
|
||||
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
|
||||
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
||||
};
|
||||
}
|
||||
|
||||
if (!ShowDragHandle)
|
||||
handleContainer.Alpha = 0;
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ShowDragHandle.BindValueChanged(show => handleContainer.Alpha = show.NewValue ? 1 : 0, true);
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
@ -98,13 +100,13 @@ namespace osu.Game.Graphics.Containers
|
||||
if (!base.OnDragStart(e))
|
||||
return false;
|
||||
|
||||
PlaylistDragActive.Value = true;
|
||||
DragActive.Value = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnDragEnd(DragEndEvent e)
|
||||
{
|
||||
PlaylistDragActive.Value = false;
|
||||
DragActive.Value = false;
|
||||
base.OnDragEnd(e);
|
||||
}
|
||||
|
||||
@ -112,7 +114,7 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
handle.UpdateHoverState(IsDragged || !PlaylistDragActive.Value);
|
||||
handle.UpdateHoverState(IsDragged || !DragActive.Value);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,6 @@ namespace osu.Game.Screens.Multi
|
||||
|
||||
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
protected override bool ShowDragHandle => allowEdit;
|
||||
|
||||
private Container maskingContainer;
|
||||
private Container difficultyIconContainer;
|
||||
private LinkFlowContainer beatmapText;
|
||||
@ -63,12 +61,13 @@ namespace osu.Game.Screens.Multi
|
||||
|
||||
// TODO: edit support should be moved out into a derived class
|
||||
this.allowEdit = allowEdit;
|
||||
|
||||
this.allowSelection = allowSelection;
|
||||
|
||||
beatmap.BindTo(item.Beatmap);
|
||||
ruleset.BindTo(item.Ruleset);
|
||||
requiredMods.BindTo(item.RequiredMods);
|
||||
|
||||
ShowDragHandle.Value = allowEdit;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
Reference in New Issue
Block a user