mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 12:02:54 +08:00
Fix delay in value retrieval causing offsetting when zooming
This commit is contained in:
parent
d9e795fb9f
commit
9b060b1bdf
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void transformZoomTo(int newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
|
private void transformZoomTo(int newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
|
||||||
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth), newZoom, duration, easing));
|
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));
|
||||||
|
|
||||||
private class TransformZoom : Transform<float, ZoomableScrollContainer>
|
private class TransformZoom : Transform<float, ZoomableScrollContainer>
|
||||||
{
|
{
|
||||||
@ -71,19 +71,21 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|||||||
private readonly float waveformSize;
|
private readonly float waveformSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The scroll offset at the start time of the transform/
|
/// The scroll offset at the start of the transform.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private float startScrollOffset;
|
private readonly float scrollOffset;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transforms <see cref="TimeTimelinem"/> to a new value.
|
/// Transforms <see cref="TimeTimelinem"/> to a new value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="focusPoint">The focus point in the waveform, in absolute coordinates local to the waveform.</param>
|
/// <param name="focusPoint">The focus point in the waveform, in absolute coordinates local to the waveform.</param>
|
||||||
/// <param name="waveformSize">The size of the waveform.</param>
|
/// <param name="waveformSize">The size of the waveform.</param>
|
||||||
public TransformZoom(float focusPoint, float waveformSize)
|
/// <param name="scrollOffset">The scroll offset at the start of the transform.</param>
|
||||||
|
public TransformZoom(float focusPoint, float waveformSize, float scrollOffset)
|
||||||
{
|
{
|
||||||
this.focusPoint = focusPoint;
|
this.focusPoint = focusPoint;
|
||||||
this.waveformSize = waveformSize;
|
this.waveformSize = waveformSize;
|
||||||
|
this.scrollOffset = scrollOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string TargetMember => nameof(currentZoom);
|
public override string TargetMember => nameof(currentZoom);
|
||||||
@ -100,7 +102,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|||||||
{
|
{
|
||||||
float newZoom = valueAt(time);
|
float newZoom = valueAt(time);
|
||||||
|
|
||||||
float focusOffset = focusPoint - startScrollOffset;
|
float focusOffset = focusPoint - scrollOffset;
|
||||||
float expectedWidth = d.DrawWidth * newZoom;
|
float expectedWidth = d.DrawWidth * newZoom;
|
||||||
float targetOffset = expectedWidth * (focusPoint / waveformSize) - focusOffset;
|
float targetOffset = expectedWidth * (focusPoint / waveformSize) - focusOffset;
|
||||||
|
|
||||||
@ -108,11 +110,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|||||||
d.ScrollTo(targetOffset, false);
|
d.ScrollTo(targetOffset, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ReadIntoStartValue(ZoomableScrollContainer d)
|
protected override void ReadIntoStartValue(ZoomableScrollContainer d) => StartValue = d.currentZoom;
|
||||||
{
|
|
||||||
startScrollOffset = d.Current;
|
|
||||||
StartValue = d.currentZoom;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user