1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:33:21 +08:00

Split zoom updating to named method with value as optional

This commit is contained in:
Salman Ahmed 2022-06-15 07:57:16 +03:00
parent 268a7e1334
commit d3feb07bc1

View File

@ -68,7 +68,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
// ensure zoom range is in valid state before updating zoom. // ensure zoom range is in valid state before updating zoom.
if (MinZoom < MaxZoom) if (MinZoom < MaxZoom)
Zoom = Zoom; updateZoom();
} }
} }
@ -89,7 +89,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
// ensure zoom range is in valid state before updating zoom. // ensure zoom range is in valid state before updating zoom.
if (MaxZoom > MinZoom) if (MaxZoom > MinZoom)
Zoom = Zoom; updateZoom();
} }
} }
@ -99,15 +99,17 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
public float Zoom public float Zoom
{ {
get => zoomTarget; get => zoomTarget;
set set => updateZoom(value);
}
private void updateZoom(float? value = null)
{ {
value = Math.Clamp(value, MinZoom, MaxZoom); float newZoom = Math.Clamp(value ?? Zoom, MinZoom, MaxZoom);
if (IsLoaded) if (IsLoaded)
setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X); setZoomTarget(newZoom, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
else else
currentZoom = zoomTarget = value; currentZoom = zoomTarget = newZoom;
}
} }
protected override void Update() protected override void Update()