mirror of
https://github.com/osukey/osukey.git
synced 2025-06-04 04:17:21 +09:00
Add support for reading/saving timeline zoom in editor
This commit is contained in:
parent
5a9524a74e
commit
d1cbdf63f0
@ -24,7 +24,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
[Cached]
|
||||
public class Timeline : ZoomableScrollContainer, IPositionSnapProvider
|
||||
{
|
||||
private const float timeline_height = 72;
|
||||
private const float timeline_expanded_height = 94;
|
||||
|
||||
private readonly Drawable userContent;
|
||||
|
||||
public readonly Bindable<bool> WaveformVisible = new Bindable<bool>();
|
||||
|
||||
public readonly Bindable<bool> ControlPointsVisible = new Bindable<bool>();
|
||||
@ -58,8 +62,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private Track track;
|
||||
|
||||
private const float timeline_height = 72;
|
||||
private const float timeline_expanded_height = 94;
|
||||
/// <summary>
|
||||
/// The timeline zoom level at a 1x zoom scale.
|
||||
/// </summary>
|
||||
private float defaultTimelineZoom;
|
||||
|
||||
private readonly Bindable<double> timelineZoomScale = new BindableDouble(1.0);
|
||||
|
||||
public Timeline(Drawable userContent)
|
||||
{
|
||||
@ -84,7 +92,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private Bindable<float> waveformOpacity;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config)
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, EditorBeatmap editorBeatmap, OsuColour colours, OsuConfigManager config)
|
||||
{
|
||||
CentreMarker centreMarker;
|
||||
|
||||
@ -141,9 +149,16 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||
MinZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||
Zoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||
}
|
||||
}, true);
|
||||
|
||||
timelineZoomScale.Value = editorBeatmap.BeatmapInfo.TimelineZoom;
|
||||
timelineZoomScale.BindValueChanged(scale =>
|
||||
{
|
||||
Zoom = (float)(defaultTimelineZoom * scale.NewValue);
|
||||
editorBeatmap.BeatmapInfo.TimelineZoom = scale.NewValue;
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -201,6 +216,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
return base.OnScroll(e);
|
||||
}
|
||||
|
||||
protected override void OnZoomChange()
|
||||
{
|
||||
base.OnZoomChange();
|
||||
timelineZoomScale.Value = Zoom / defaultTimelineZoom;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
@ -136,11 +136,20 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
zoomTarget = Math.Clamp(newZoom, MinZoom, MaxZoom);
|
||||
transformZoomTo(zoomTarget, focusPoint, ZoomDuration, ZoomEasing);
|
||||
|
||||
OnZoomChange();
|
||||
}
|
||||
|
||||
private void transformZoomTo(float newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
|
||||
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the zoom target has changed.
|
||||
/// </summary>
|
||||
protected virtual void OnZoomChange()
|
||||
{
|
||||
}
|
||||
|
||||
private class TransformZoom : Transform<float, ZoomableScrollContainer>
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user