From d3feb07bc1b6b861ac9db641226eee5c14344469 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 15 Jun 2022 07:57:16 +0300 Subject: [PATCH] Split zoom updating to named method with value as optional --- .../Timeline/ZoomableScrollContainer.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index d58cb27274..bc6c66625c 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -68,7 +68,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline // ensure zoom range is in valid state before updating zoom. 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. if (MaxZoom > MinZoom) - Zoom = Zoom; + updateZoom(); } } @@ -99,15 +99,17 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline public float Zoom { get => zoomTarget; - set - { - value = Math.Clamp(value, MinZoom, MaxZoom); + set => updateZoom(value); + } - if (IsLoaded) - setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X); - else - currentZoom = zoomTarget = value; - } + private void updateZoom(float? value = null) + { + float newZoom = Math.Clamp(value ?? Zoom, MinZoom, MaxZoom); + + if (IsLoaded) + setZoomTarget(newZoom, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X); + else + currentZoom = zoomTarget = newZoom; } protected override void Update()