mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Implement CancellableCommentEditor
This commit is contained in:
71
osu.Game/Overlays/Comments/CancellableCommentEditor.cs
Normal file
71
osu.Game/Overlays/Comments/CancellableCommentEditor.cs
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public abstract class CancellableCommentEditor : CommentEditor
|
||||
{
|
||||
public Action OnCancel;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ButtonsContainer.Add(new CancelButton
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Action = () => OnCancel?.Invoke()
|
||||
});
|
||||
}
|
||||
|
||||
private class CancelButton : OsuHoverContainer
|
||||
{
|
||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
||||
|
||||
private readonly Box background;
|
||||
|
||||
public CancelButton()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Child = new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
Height = 25,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding { Horizontal = 20 },
|
||||
Text = @"Cancel"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
IdleColour = colourProvider.GetColour(0.5f, 0.45f);
|
||||
HoverColour = colourProvider.GetColour(0.5f, 0.6f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user