mirror of
https://github.com/osukey/osukey.git
synced 2025-04-29 02:37:25 +09:00
Merge pull request #67 from Gyoshi/beat-divisor-mouse-drag-cherry-picked
Beat divisor mouse drag fix and tests
This commit is contained in:
commit
6526688ddb
@ -65,17 +65,24 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
InputManager.MoveMouseTo(tickMarkerHead.ScreenSpaceDrawQuad.Centre);
|
InputManager.MoveMouseTo(tickMarkerHead.ScreenSpaceDrawQuad.Centre);
|
||||||
InputManager.PressButton(MouseButton.Left);
|
InputManager.PressButton(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddStep("move to 8 and release", () =>
|
AddStep("move to 1", () => InputManager.MoveMouseTo(getPositionForDivisor(1)));
|
||||||
|
AddStep("move to 16 and release", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(tickSliderBar.ScreenSpaceDrawQuad.Centre);
|
InputManager.MoveMouseTo(getPositionForDivisor(16));
|
||||||
InputManager.ReleaseButton(MouseButton.Left);
|
InputManager.ReleaseButton(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddAssert("divisor is 8", () => bindableBeatDivisor.Value == 8);
|
AddAssert("divisor is 16", () => bindableBeatDivisor.Value == 16);
|
||||||
AddStep("hold marker", () => InputManager.PressButton(MouseButton.Left));
|
AddStep("hold marker", () => InputManager.PressButton(MouseButton.Left));
|
||||||
AddStep("move to 16", () => InputManager.MoveMouseTo(getPositionForDivisor(16)));
|
AddStep("move to ~6 and release", () =>
|
||||||
AddStep("move to ~10 and release", () =>
|
{
|
||||||
|
InputManager.MoveMouseTo(getPositionForDivisor(6));
|
||||||
|
InputManager.ReleaseButton(MouseButton.Left);
|
||||||
|
});
|
||||||
|
AddAssert("divisor clamped to 8", () => bindableBeatDivisor.Value == 8);
|
||||||
|
AddStep("move to ~10 and click", () =>
|
||||||
{
|
{
|
||||||
InputManager.MoveMouseTo(getPositionForDivisor(10));
|
InputManager.MoveMouseTo(getPositionForDivisor(10));
|
||||||
|
InputManager.PressButton(MouseButton.Left);
|
||||||
InputManager.ReleaseButton(MouseButton.Left);
|
InputManager.ReleaseButton(MouseButton.Left);
|
||||||
});
|
});
|
||||||
AddAssert("divisor clamped to 8", () => bindableBeatDivisor.Value == 8);
|
AddAssert("divisor clamped to 8", () => bindableBeatDivisor.Value == 8);
|
||||||
@ -83,12 +90,11 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
private Vector2 getPositionForDivisor(int divisor)
|
private Vector2 getPositionForDivisor(int divisor)
|
||||||
{
|
{
|
||||||
float relativePosition = (float)Math.Clamp(divisor, 0, 16) / 16;
|
float localX = (1 - 1 / (float)divisor) * tickSliderBar.UsableWidth + tickSliderBar.RangePadding;
|
||||||
var sliderDrawQuad = tickSliderBar.ScreenSpaceDrawQuad;
|
return tickSliderBar.ToScreenSpace(new Vector2(
|
||||||
return new Vector2(
|
localX,
|
||||||
sliderDrawQuad.TopLeft.X + sliderDrawQuad.Width * relativePosition,
|
tickSliderBar.DrawHeight / 2
|
||||||
sliderDrawQuad.Centre.Y
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -383,7 +383,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
CurrentNumber.BindTo(this.beatDivisor = beatDivisor);
|
CurrentNumber.BindTo(this.beatDivisor = beatDivisor);
|
||||||
|
|
||||||
Padding = new MarginPadding { Horizontal = 5 };
|
RangePadding = 5;
|
||||||
|
Padding = new MarginPadding { Horizontal = RangePadding };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user