Fix dialog dangerous button being clickable at edges

This commit is contained in:
Salman Ahmed
2022-04-11 21:05:37 +03:00
parent 74dfa79f17
commit bad30d9e60

View File

@ -12,37 +12,38 @@ namespace osu.Game.Overlays.Dialog
{ {
public class PopupDialogDangerousButton : PopupDialogButton public class PopupDialogDangerousButton : PopupDialogButton
{ {
private Box progressBox;
private DangerousConfirmContainer confirmContainer;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
ButtonColour = colours.Red3; ButtonColour = colours.Red3;
ColourContainer.Add(new ConfirmFillBox ColourContainer.Add(progressBox = new Box
{ {
Action = () => Action(),
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
}); });
}
private class ConfirmFillBox : HoldToConfirmContainer AddInternal(confirmContainer = new DangerousConfirmContainer
{ {
private Box box; Action = () => Action(),
RelativeSizeAxes = Axes.Both,
protected override double? HoldActivationDelay => 500; });
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
Child = box = new Box confirmContainer.Progress.BindValueChanged(progress => progressBox.Width = (float)progress.NewValue, true);
{
RelativeSizeAxes = Axes.Both,
};
Progress.BindValueChanged(progress => box.Width = (float)progress.NewValue, true);
} }
private class DangerousConfirmContainer : HoldToConfirmContainer
{
protected override double? HoldActivationDelay => 500;
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
BeginConfirm(); BeginConfirm();