Ensure ZoomableScrollContainer content isn't shown until zoom is set

This commit is contained in:
Dean Herbert 2022-09-27 17:05:10 +09:00
parent 9dc0eb7fd0
commit ccae721af2

View File

@ -56,7 +56,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected ZoomableScrollContainer() protected ZoomableScrollContainer()
: base(Direction.Horizontal) : base(Direction.Horizontal)
{ {
base.Content.Add(zoomedContent = new Container { RelativeSizeAxes = Axes.Y }); base.Content.Add(zoomedContent = new Container
{
RelativeSizeAxes = Axes.Y,
// We must hide content until SetupZoom is called.
// If not, a child component that relies on its DrawWidth (via RelativeSizeAxes) may see a very incorrect value
// momentarily, as noticed in the TimelineTickDisplay, which would render thousands of ticks incorrectly.
Alpha = 0,
});
AddLayout(zoomedContentWidthCache); AddLayout(zoomedContentWidthCache);
} }
@ -94,6 +101,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
maxZoom = maximum; maxZoom = maximum;
CurrentZoom = zoomTarget = initial; CurrentZoom = zoomTarget = initial;
isZoomSetUp = true; isZoomSetUp = true;
zoomedContent.Show();
} }
/// <summary> /// <summary>
@ -118,9 +127,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
CurrentZoom = zoomTarget = newZoom; CurrentZoom = zoomTarget = newZoom;
} }
protected override void Update() protected override void UpdateAfterChildren()
{ {
base.Update(); base.UpdateAfterChildren();
if (!zoomedContentWidthCache.IsValid) if (!zoomedContentWidthCache.IsValid)
updateZoomedContentWidth(); updateZoomedContentWidth();