1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 03:42:57 +08:00

Enable scale buttons at the correct times

This commit is contained in:
OliBomby 2024-05-25 20:35:06 +02:00
parent 4eeebdf60c
commit 37530eebcc
4 changed files with 17 additions and 5 deletions

View File

@ -53,6 +53,8 @@ namespace osu.Game.Rulesets.Osu.Edit
CanScaleX.Value = quad.Width > 0;
CanScaleY.Value = quad.Height > 0;
CanScaleDiagonally.Value = CanScaleX.Value && CanScaleY.Value;
CanScaleSelectionOrigin.Value = CanScaleX.Value || CanScaleY.Value;
CanScalePlayfieldOrigin.Value = selectedMovableObjects.Any();
}
private Dictionary<OsuHitObject, OriginalHitObjectState>? objectsInScale;

View File

@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Edit
scaleInput.Current.BindValueChanged(scale => scaleInfo.Value = scaleInfo.Value with { Scale = scale.NewValue });
scaleOrigin.Items.First().Select();
scaleHandler.CanScaleX.BindValueChanged(e =>
scaleHandler.CanScaleSelectionOrigin.BindValueChanged(e =>
{
selectionCentreButton.Selected.Disabled = !e.NewValue;
}, true);

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Edit
private Bindable<bool> canScaleX = null!;
private Bindable<bool> canScaleY = null!;
private Bindable<bool> canScaleDiagonally = null!;
private Bindable<bool> canScalePlayfieldOrigin = null!;
public SelectionRotationHandler RotationHandler { get; init; } = null!;
public SelectionScaleHandler ScaleHandler { get; init; } = null!;
@ -82,12 +82,12 @@ namespace osu.Game.Rulesets.Osu.Edit
canScaleY = ScaleHandler.CanScaleY.GetBoundCopy();
canScaleY.BindValueChanged(_ => updateCanScaleAggregate());
canScaleDiagonally = ScaleHandler.CanScaleDiagonally.GetBoundCopy();
canScaleDiagonally.BindValueChanged(_ => updateCanScaleAggregate());
canScalePlayfieldOrigin = ScaleHandler.CanScalePlayfieldOrigin.GetBoundCopy();
canScalePlayfieldOrigin.BindValueChanged(_ => updateCanScaleAggregate());
void updateCanScaleAggregate()
{
canScale.Value = ScaleHandler.CanScaleX.Value || ScaleHandler.CanScaleY.Value || ScaleHandler.CanScaleDiagonally.Value;
canScale.Value = ScaleHandler.CanScaleX.Value || ScaleHandler.CanScaleY.Value || ScaleHandler.CanScalePlayfieldOrigin.Value;
}
// bindings to `Enabled` on the buttons are decoupled on purpose

View File

@ -32,6 +32,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </remarks>
public Bindable<bool> CanScaleDiagonally { get; private set; } = new BindableBool();
/// <summary>
/// Whether scaling anchored by the selection origin can currently be performed.
/// </summary>
public Bindable<bool> CanScaleSelectionOrigin { get; private set; } = new BindableBool();
/// <summary>
/// Whether scaling anchored by the center of the playfield can currently be performed.
/// </summary>
public Bindable<bool> CanScalePlayfieldOrigin { get; private set; } = new BindableBool();
public Quad? OriginalSurroundingQuad { get; protected set; }
/// <summary>