From 9cc6ee2ebca06e9c325aeb67f97d2421debc7fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Sch=C3=BCrz?= Date: Thu, 10 Oct 2024 20:14:11 +0200 Subject: [PATCH 1/3] Fix SelectionBox buttons freezing when button is triggered via key event --- .../Edit/Compose/Components/SelectionBox.cs | 20 +++++++++++++++---- .../Compose/Components/SelectionBoxButton.cs | 16 ++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs index d685fe74b0d3..2171ba696fc8 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs @@ -150,13 +150,25 @@ protected override bool OnKeyDown(KeyDownEvent e) switch (e.Key) { case Key.G: - return CanReverse && reverseButton?.TriggerClick() == true; + if (!CanReverse || reverseButton == null) + return false; + + reverseButton.TriggerAction(); + return true; case Key.Comma: - return canRotate.Value && rotateCounterClockwiseButton?.TriggerClick() == true; + if (!canRotate.Value || rotateCounterClockwiseButton == null) + return false; + + rotateCounterClockwiseButton.TriggerAction(); + return true; case Key.Period: - return canRotate.Value && rotateClockwiseButton?.TriggerClick() == true; + if (!canRotate.Value || rotateClockwiseButton == null) + return false; + + rotateClockwiseButton.TriggerAction(); + return true; } return base.OnKeyDown(e); @@ -285,7 +297,7 @@ private SelectionBoxButton addButton(IconUsage icon, string tooltip, Action acti Action = action }; - button.OperationStarted += freezeButtonPosition; + button.Clicked += freezeButtonPosition; button.HoverLost += unfreezeButtonPosition; button.OperationStarted += operationStarted; diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs index e355add40bfc..1d2150dc1d2e 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs @@ -21,6 +21,8 @@ public sealed partial class SelectionBoxButton : SelectionBoxControl, IHasToolti public Action? Action; + public event Action? Clicked; + public event Action? HoverLost; public SelectionBoxButton(IconUsage iconUsage, string tooltip) @@ -51,9 +53,10 @@ protected override bool OnClick(ClickEvent e) { Circle.FlashColour(Colours.GrayF, 300); - TriggerOperationStarted(); - Action?.Invoke(); - TriggerOperationEnded(); + Clicked?.Invoke(); + + TriggerAction(); + return true; } @@ -71,5 +74,12 @@ protected override void OnHoverLost(HoverLostEvent e) } public LocalisableString TooltipText { get; } + + internal void TriggerAction() + { + TriggerOperationStarted(); + Action?.Invoke(); + TriggerOperationEnded(); + } } } From fc7ad96fcd99176320650bd3b57479281e4c3390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Sch=C3=BCrz?= Date: Thu, 10 Oct 2024 20:20:02 +0200 Subject: [PATCH 2/3] Move circle flash to `TriggerAction` --- .../Screens/Edit/Compose/Components/SelectionBoxButton.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs index 1d2150dc1d2e..88272c2e5df0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs @@ -51,8 +51,6 @@ private void load() protected override bool OnClick(ClickEvent e) { - Circle.FlashColour(Colours.GrayF, 300); - Clicked?.Invoke(); TriggerAction(); @@ -77,6 +75,8 @@ protected override void OnHoverLost(HoverLostEvent e) internal void TriggerAction() { + Circle.FlashColour(Colours.GrayF, 300); + TriggerOperationStarted(); Action?.Invoke(); TriggerOperationEnded(); From af55585dc8ab2ba743224404b0cf901b8ffd2865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Sch=C3=BCrz?= Date: Thu, 10 Oct 2024 20:50:47 +0200 Subject: [PATCH 3/3] Make `TriggerAction` public --- osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs index 88272c2e5df0..8f263cdf4fb9 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionBoxButton.cs @@ -73,7 +73,7 @@ protected override void OnHoverLost(HoverLostEvent e) public LocalisableString TooltipText { get; } - internal void TriggerAction() + public void TriggerAction() { Circle.FlashColour(Colours.GrayF, 300);