mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 20:52:54 +08:00
Add capability to remove breaks via context menu
This commit is contained in:
parent
3bf3e9133b
commit
9414aec8bf
@ -9,20 +9,31 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||||
{
|
{
|
||||||
public partial class TimelineBreak : CompositeDrawable
|
public partial class TimelineBreak : CompositeDrawable, IHasContextMenu
|
||||||
{
|
{
|
||||||
public Bindable<BreakPeriod> Break { get; } = new Bindable<BreakPeriod>();
|
public Bindable<BreakPeriod> Break { get; } = new Bindable<BreakPeriod>();
|
||||||
|
|
||||||
|
public Action<BreakPeriod>? OnDeleted { get; init; }
|
||||||
|
|
||||||
|
private Box background = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
public TimelineBreak(BreakPeriod b)
|
public TimelineBreak(BreakPeriod b)
|
||||||
{
|
{
|
||||||
Break.Value = b;
|
Break.Value = b;
|
||||||
@ -42,7 +53,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Horizontal = 5 },
|
Padding = new MarginPadding { Horizontal = 5 },
|
||||||
Child = new Box
|
Child = background = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.Gray5,
|
Colour = colours.Gray5,
|
||||||
@ -77,6 +88,28 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
updateState();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
updateState();
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
background.FadeColour(IsHovered ? colours.Gray6 : colours.Gray5, 400, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuItem[]? ContextMenuItems => new MenuItem[]
|
||||||
|
{
|
||||||
|
new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, () => OnDeleted?.Invoke(Break.Value)),
|
||||||
|
};
|
||||||
|
|
||||||
private partial class DragHandle : FillFlowContainer
|
private partial class DragHandle : FillFlowContainer
|
||||||
{
|
{
|
||||||
public Bindable<BreakPeriod> Break { get; } = new Bindable<BreakPeriod>();
|
public Bindable<BreakPeriod> Break { get; } = new Bindable<BreakPeriod>();
|
||||||
|
@ -71,7 +71,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
if (!shouldBeVisible(breakPeriod))
|
if (!shouldBeVisible(breakPeriod))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Add(new TimelineBreak(breakPeriod));
|
Add(new TimelineBreak(breakPeriod)
|
||||||
|
{
|
||||||
|
OnDeleted = b => breaks.Remove(b),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user