1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Give ZoomableScrollContainer an initial width

This commit is contained in:
David Zhao 2019-05-08 13:37:03 +09:00
parent f05471aa18
commit ff3c226596
2 changed files with 44 additions and 24 deletions

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Framework.Testing;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
@ -18,10 +19,13 @@ namespace osu.Game.Tests.Visual.Editor
{
public class TestCaseZoomableScrollContainer : ManualInputManagerTestCase
{
private readonly ZoomableScrollContainer scrollContainer;
private readonly Drawable innerBox;
private ZoomableScrollContainer scrollContainer;
private Drawable innerBox;
public TestCaseZoomableScrollContainer()
[SetUpSteps]
public void SetUpSteps()
{
AddStep("Add new scroll container", () =>
{
Children = new Drawable[]
{
@ -50,6 +54,14 @@ namespace osu.Game.Tests.Visual.Editor
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(new Color4(0.8f, 0.6f, 0.4f, 1f), new Color4(0.4f, 0.6f, 0.8f, 1f))
});
});
AddUntilStep("Scroll container is loaded", () => scrollContainer.LoadState >= LoadState.Loaded);
}
[Test]
public void TestWidthInitialization()
{
AddAssert("Inner container width was initialized", () => innerBox.DrawWidth > 0);
}
[Test]

View File

@ -102,6 +102,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
return true;
}
protected override void LoadComplete()
{
base.LoadComplete();
// This width only gets updated on the application of a transform, so this needs to be initialized here.
zoomedContent.Width = DrawWidth * currentZoom;
}
private float zoomTarget = 1;
private void setZoomTarget(float newZoom, float focusPoint)