mirror of
https://github.com/ppy/osu
synced 2025-01-20 04:50:50 +00:00
Merge pull request #19278 from Cwazywierdo/timeline-relative-zoom
Make editor timeline zoom relative to song length
This commit is contained in:
commit
1774a96455
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Height = 0.5f,
|
Height = 0.5f,
|
||||||
Icon = FontAwesome.Solid.SearchPlus,
|
Icon = FontAwesome.Solid.SearchPlus,
|
||||||
Action = () => changeZoom(1)
|
Action = () => Timeline.AdjustZoomRelatively(1)
|
||||||
},
|
},
|
||||||
new TimelineButton
|
new TimelineButton
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Height = 0.5f,
|
Height = 0.5f,
|
||||||
Icon = FontAwesome.Solid.SearchMinus,
|
Icon = FontAwesome.Solid.SearchMinus,
|
||||||
Action = () => changeZoom(-1)
|
Action = () => Timeline.AdjustZoomRelatively(-1)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +153,5 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
Timeline.ControlPointsVisible.BindTo(controlPointsCheckbox.Current);
|
Timeline.ControlPointsVisible.BindTo(controlPointsCheckbox.Current);
|
||||||
Timeline.TicksVisible.BindTo(ticksCheckbox.Current);
|
Timeline.TicksVisible.BindTo(ticksCheckbox.Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeZoom(float change) => Timeline.Zoom += change;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
if (e.AltPressed)
|
if (e.AltPressed)
|
||||||
{
|
{
|
||||||
// zoom when holding alt.
|
// zoom when holding alt.
|
||||||
setZoomTarget(zoomTarget + e.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.ScreenSpaceMousePosition).X);
|
AdjustZoomRelatively(e.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.ScreenSpaceMousePosition).X);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,12 +145,19 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
zoomedContentWidthCache.Validate();
|
zoomedContentWidthCache.Validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AdjustZoomRelatively(float change, float? focusPoint = null)
|
||||||
|
{
|
||||||
|
const float zoom_change_sensitivity = 0.02f;
|
||||||
|
|
||||||
|
setZoomTarget(zoomTarget + change * (MaxZoom - minZoom) * zoom_change_sensitivity, focusPoint);
|
||||||
|
}
|
||||||
|
|
||||||
private float zoomTarget = 1;
|
private float zoomTarget = 1;
|
||||||
|
|
||||||
private void setZoomTarget(float newZoom, float focusPoint)
|
private void setZoomTarget(float newZoom, float? focusPoint = null)
|
||||||
{
|
{
|
||||||
zoomTarget = Math.Clamp(newZoom, MinZoom, MaxZoom);
|
zoomTarget = Math.Clamp(newZoom, MinZoom, MaxZoom);
|
||||||
transformZoomTo(zoomTarget, focusPoint, ZoomDuration, ZoomEasing);
|
transformZoomTo(zoomTarget, focusPoint ?? DrawWidth / 2, ZoomDuration, ZoomEasing);
|
||||||
|
|
||||||
OnZoomChanged();
|
OnZoomChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user