1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 15:23:14 +08:00

Expose currentZoom to fix selection box wiggle

This commit is contained in:
Leon Gebler 2020-10-27 12:39:50 +01:00
parent 704f8cc4f2
commit 064c50c3ac
2 changed files with 12 additions and 6 deletions

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
@ -139,6 +138,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private class TimelineDragBox : DragBox
{
private Vector2 lastMouseDown;
private float? lastZoom;
private float localMouseDown;
@ -166,13 +166,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
lastZoom = null;
}
//Zooming the timeline shifts the coordinate system this compensates for this shift
float zoomCorrection = lastZoom.HasValue ? (parent.timeline.Zoom / lastZoom.Value) : 1;
//Zooming the timeline shifts the coordinate system. zoomCorrection compensates for that
float zoomCorrection = lastZoom.HasValue ? (parent.timeline.CurrentZoom / lastZoom.Value) : 1;
localMouseDown *= zoomCorrection;
lastZoom = parent.timeline.Zoom;
lastZoom = parent.timeline.CurrentZoom;
float selection1 = localMouseDown;
float selection2 = e.MousePosition.X;
float selection2 = e.MousePosition.X * zoomCorrection;
Box.X = Math.Min(selection1, selection2);
Box.Width = Math.Abs(selection1 - selection2);

View File

@ -29,9 +29,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private readonly Container zoomedContent;
protected override Container<Drawable> Content => zoomedContent;
private float currentZoom = 1;
/// <summary>
/// The current zoom level of <see cref="ZoomableScrollContainer" />.
/// It may differ from <see cref="Zoom" /> during transitions.
/// </summary>
public float CurrentZoom => currentZoom;
[Resolved(canBeNull: true)]
private IFrameBasedClock editorClock { get; set; }