-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18462 from frenzibyte/fix-timeline-zooming
Fix timeline objects disappearing prematurely on wide-screens
- Loading branch information
Showing
3 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using NUnit.Framework; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Utils; | ||
|
||
namespace osu.Game.Tests.Visual.Editing | ||
{ | ||
public class TestSceneTimelineZoom : TimelineTestScene | ||
{ | ||
public override Drawable CreateTestComponent() => Empty(); | ||
|
||
[Test] | ||
public void TestVisibleRangeUpdatesOnZoomChange() | ||
{ | ||
double initialVisibleRange = 0; | ||
|
||
AddStep("reset zoom", () => TimelineArea.Timeline.Zoom = 100); | ||
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange); | ||
|
||
AddStep("scale zoom", () => TimelineArea.Timeline.Zoom = 200); | ||
AddAssert("range halved", () => Precision.AlmostEquals(TimelineArea.Timeline.VisibleRange, initialVisibleRange / 2, 1)); | ||
AddStep("descale zoom", () => TimelineArea.Timeline.Zoom = 50); | ||
AddAssert("range doubled", () => Precision.AlmostEquals(TimelineArea.Timeline.VisibleRange, initialVisibleRange * 2, 1)); | ||
|
||
AddStep("restore zoom", () => TimelineArea.Timeline.Zoom = 100); | ||
AddAssert("range restored", () => Precision.AlmostEquals(TimelineArea.Timeline.VisibleRange, initialVisibleRange, 1)); | ||
} | ||
|
||
[Test] | ||
public void TestVisibleRangeConstantOnSizeChange() | ||
{ | ||
double initialVisibleRange = 0; | ||
|
||
AddStep("reset timeline size", () => TimelineArea.Timeline.Width = 1); | ||
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange); | ||
|
||
AddStep("scale timeline size", () => TimelineArea.Timeline.Width = 2); | ||
AddAssert("same range", () => TimelineArea.Timeline.VisibleRange == initialVisibleRange); | ||
AddStep("descale timeline size", () => TimelineArea.Timeline.Width = 0.5f); | ||
AddAssert("same range", () => TimelineArea.Timeline.VisibleRange == initialVisibleRange); | ||
|
||
AddStep("restore timeline size", () => TimelineArea.Timeline.Width = 1); | ||
AddAssert("same range", () => TimelineArea.Timeline.VisibleRange == initialVisibleRange); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters