mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:23:22 +08:00
Merge pull request #16613 from frenzibyte/improve-timeline-zoom
Decrease default timeline zoom and add saving support
This commit is contained in:
commit
cdd63e428c
@ -47,25 +47,25 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
}));
|
||||
|
||||
AddStep("select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(addedObjects));
|
||||
|
||||
AddStep("nudge forwards", () => InputManager.Key(Key.K));
|
||||
AddAssert("objects moved forwards in time", () => addedObjects[0].StartTime > 100);
|
||||
AddAssert("objects moved forwards in time", () => addedObjects[0].StartTime > 500);
|
||||
|
||||
AddStep("nudge backwards", () => InputManager.Key(Key.J));
|
||||
AddAssert("objects reverted to original position", () => addedObjects[0].StartTime == 100);
|
||||
AddAssert("objects reverted to original position", () => addedObjects[0].StartTime == 500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicSelect()
|
||||
{
|
||||
var addedObject = new HitCircle { StartTime = 100 };
|
||||
var addedObject = new HitCircle { StartTime = 500 };
|
||||
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||
|
||||
moveMouseToObject(() => addedObject);
|
||||
@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
var addedObject2 = new HitCircle
|
||||
{
|
||||
StartTime = 200,
|
||||
StartTime = 1000,
|
||||
Position = new Vector2(100),
|
||||
};
|
||||
|
||||
@ -92,10 +92,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Test]
|
||||
public void TestBasicDeselect()
|
||||
{
|
||||
var addedObject = new HitCircle { StartTime = 100 };
|
||||
var addedObject = new HitCircle { StartTime = 500 };
|
||||
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||
|
||||
moveMouseToObject(() => addedObject);
|
||||
@ -166,11 +166,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500, Position = new Vector2(400) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 2500, Position = new Vector2(400) },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
@ -236,10 +236,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
|
@ -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(2000);
|
||||
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 OnZoomChanged()
|
||||
{
|
||||
base.OnZoomChanged();
|
||||
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);
|
||||
|
||||
OnZoomChanged();
|
||||
}
|
||||
|
||||
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 <see cref="Zoom"/> has changed.
|
||||
/// </summary>
|
||||
protected virtual void OnZoomChanged()
|
||||
{
|
||||
}
|
||||
|
||||
private class TransformZoom : Transform<float, ZoomableScrollContainer>
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user