Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure at least one scale popover axis is active at any time #30219

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Oct 11, 2024

Spotted in passing when reviewing #30080. The popover would very arbitrarily revert to scaling by Y axis if both checkboxes were checked off.

Not sure how this passed review.

Spotted in passing when reviewing ppy#30080.
The popover would very arbitrarily revert to scaling by Y axis if both
checkboxes were checked off.

Not sure how this passed review.
@OliBomby
Copy link
Contributor

I agree this is how it should behave if both axes are turned off.

Maybe we should disable the ability to turn off both axes because i dont think the user ever intends to turn off both axes and make the scale tool useless. It should automatically turn on the other checkbox if you turn off the last checkbox.

@peppy peppy self-requested a review October 13, 2024 14:28
@peppy
Copy link
Member

peppy commented Oct 13, 2024

I don't get these checkboxes. You uncheck both and it still scales Y now?

Would appreciate if someone can ping me for new UX like this. I think these checkboxes feel really bad / confusing.

@OliBomby
Copy link
Contributor

I don't get these checkboxes. You uncheck both and it still scales Y now?

Would appreciate if someone can ping me for new UX like this. I think these checkboxes feel really bad / confusing.

osu!_VoKgpGgBDk

It's not really new UX. These have been in osu! stable for ages and they're supposed to not scale if both axes are off.

@peppy
Copy link
Member

peppy commented Oct 13, 2024

I didn't add those and it's stupid and really shouldn't exist. There are multiple better ways of implementing this which make for a much better UX than what is there. I'd think the standard way of having two sliders for x/y scale and a single checkbox to lock adjustments to both (preserve aspect).

But for now, as you propose, one axis should always be required. ie. this should be a radio control.

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As proposed

@bdach
Copy link
Collaborator Author

bdach commented Oct 13, 2024

Would appreciate if someone can ping me for new UX like this

Originally this was added in #28309 which I guess I didn't ping for reviews thinking that obviously it's in stable so it's fine. But then you authored #28559, and reviewed #26311 which touched (and regressed) this. I don't like pulling receipts but that sort of response makes me a little miffed.

I don't go around making UX shotcalls without consultation and that should be pretty apparent from my track record on requesting double checks on such things.

@peppy
Copy link
Member

peppy commented Oct 13, 2024

It's completely on me for letting it slip through. But it's definitely the first time I've been actively aware of these checkboxes so please allow me to have a kneejerk reaction to their jank 😄.

The fact it exists on stable is also a surprise to me, but it makes more sense that it was copied across without further consideration.

@peppy
Copy link
Member

peppy commented Oct 14, 2024

I propose this:

diff --git a/osu.Game.Rulesets.Osu/Edit/PreciseScalePopover.cs b/osu.Game.Rulesets.Osu/Edit/PreciseScalePopover.cs
index 25515a90d5..71a7793fc9 100644
--- a/osu.Game.Rulesets.Osu/Edit/PreciseScalePopover.cs
+++ b/osu.Game.Rulesets.Osu/Edit/PreciseScalePopover.cs
@@ -136,8 +136,26 @@ protected override void LoadComplete()
             });
             scaleInput.Current.BindValueChanged(scale => scaleInfo.Value = scaleInfo.Value with { Scale = scale.NewValue });
 
-            xCheckBox.Current.BindValueChanged(x => setAxis(x.NewValue, yCheckBox.Current.Value));
-            yCheckBox.Current.BindValueChanged(y => setAxis(xCheckBox.Current.Value, y.NewValue));
+            xCheckBox.Current.BindValueChanged(_ =>
+            {
+                if (!xCheckBox.Current.Value && !yCheckBox.Current.Value)
+                {
+                    yCheckBox.Current.Value = true;
+                    return;
+                }
+
+                updateAxes();
+            });
+            yCheckBox.Current.BindValueChanged(_ =>
+            {
+                if (!xCheckBox.Current.Value && !yCheckBox.Current.Value)
+                {
+                    xCheckBox.Current.Value = true;
+                    return;
+                }
+
+                updateAxes();
+            });
 
             selectionCentreButton.Selected.Disabled = !(scaleHandler.CanScaleX.Value || scaleHandler.CanScaleY.Value);
             playfieldCentreButton.Selected.Disabled = scaleHandler.IsScalingSlider.Value && !selectionCentreButton.Selected.Disabled;
@@ -152,6 +170,12 @@ protected override void LoadComplete()
             });
         }
 
+        private void updateAxes()
+        {
+            scaleInfo.Value = scaleInfo.Value with { XAxis = xCheckBox.Current.Value, YAxis = yCheckBox.Current.Value };
+            updateMaxScale();
+        }
+
         private void updateAxisCheckBoxesEnabled()
         {
             if (scaleInfo.Value.Origin != ScaleOrigin.SelectionCentre)
@@ -234,12 +258,6 @@ private Axes getAdjustAxis(PreciseScaleInfo scale)
 
         private float getRotation(PreciseScaleInfo scale) => scale.Origin == ScaleOrigin.GridCentre ? gridToolbox.GridLinesRotation.Value : 0;
 
-        private void setAxis(bool x, bool y)
-        {
-            scaleInfo.Value = scaleInfo.Value with { XAxis = x, YAxis = y };
-            updateMaxScale();
-        }
-
         protected override void PopIn()
         {
             base.PopIn();

Although looking at this class really hurts my head. I'd probably want to lose all the with syntax ASAP.

As in, toggling off an axis if it is the only one enabled will enable
the other one in turn.

Co-authored-by: Dean Herbert <pe@ppy.sh>
@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 15, 2024
@bdach bdach changed the title Fix scale popover doing things when both scale axes are turned off Ensure at least one scale popover axis is active at any time Oct 15, 2024
@bdach
Copy link
Collaborator Author

bdach commented Oct 15, 2024

I propose this:

Applied verbatim, thanks.

@peppy peppy self-requested a review October 15, 2024 19:29
@peppy peppy merged commit 8e76dd5 into ppy:master Oct 15, 2024
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants