mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Merge pull request #18697 from frenzibyte/timeline-track-change-crash
Fix `ZoomableScrollContainer` attempting to update zoom with invalid range
This commit is contained in:
@ -78,6 +78,21 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("Inner container width matches scroll container", () => innerBox.DrawWidth == scrollContainer.DrawWidth);
|
AddAssert("Inner container width matches scroll container", () => innerBox.DrawWidth == scrollContainer.DrawWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestZoomRangeUpdate()
|
||||||
|
{
|
||||||
|
AddStep("set zoom to 2", () => scrollContainer.Zoom = 2);
|
||||||
|
AddStep("set min zoom to 5", () => scrollContainer.MinZoom = 5);
|
||||||
|
AddAssert("zoom = 5", () => scrollContainer.Zoom == 5);
|
||||||
|
|
||||||
|
AddStep("set max zoom to 10", () => scrollContainer.MaxZoom = 10);
|
||||||
|
AddAssert("zoom = 5", () => scrollContainer.Zoom == 5);
|
||||||
|
|
||||||
|
AddStep("set min zoom to 20", () => scrollContainer.MinZoom = 20);
|
||||||
|
AddStep("set max zoom to 40", () => scrollContainer.MaxZoom = 40);
|
||||||
|
AddAssert("zoom = 20", () => scrollContainer.Zoom == 20);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestZoom0()
|
public void TestZoom0()
|
||||||
{
|
{
|
||||||
|
@ -66,8 +66,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
minZoom = value;
|
minZoom = value;
|
||||||
|
|
||||||
if (Zoom < value)
|
// ensure zoom range is in valid state before updating zoom.
|
||||||
Zoom = value;
|
if (MinZoom < MaxZoom)
|
||||||
|
updateZoom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +87,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
maxZoom = value;
|
maxZoom = value;
|
||||||
|
|
||||||
if (Zoom > value)
|
// ensure zoom range is in valid state before updating zoom.
|
||||||
Zoom = value;
|
if (MaxZoom > MinZoom)
|
||||||
|
updateZoom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,15 +99,17 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
public float Zoom
|
public float Zoom
|
||||||
{
|
{
|
||||||
get => zoomTarget;
|
get => zoomTarget;
|
||||||
set
|
set => updateZoom(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateZoom(float? value = null)
|
||||||
{
|
{
|
||||||
value = Math.Clamp(value, MinZoom, MaxZoom);
|
float newZoom = Math.Clamp(value ?? Zoom, MinZoom, MaxZoom);
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
|
setZoomTarget(newZoom, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
|
||||||
else
|
else
|
||||||
currentZoom = zoomTarget = value;
|
currentZoom = zoomTarget = newZoom;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
Reference in New Issue
Block a user