2019-10-09 15:05:55 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-05-24 15:15:24 +08:00
|
|
|
#nullable disable
|
2022-06-17 15:37:17 +08:00
|
|
|
|
2019-10-09 15:05:55 +08:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-08-17 23:47:32 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-05-24 15:15:24 +08:00
|
|
|
using osu.Game.Overlays;
|
2019-10-09 15:05:55 +08:00
|
|
|
using osu.Game.Screens.Edit.Compose.Components;
|
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit
|
|
|
|
{
|
|
|
|
public abstract class EditorScreenWithTimeline : EditorScreen
|
|
|
|
{
|
2022-05-24 15:32:44 +08:00
|
|
|
private const float padding = 10;
|
2019-10-09 15:05:55 +08:00
|
|
|
|
|
|
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
|
|
|
|
2020-01-21 16:37:05 +08:00
|
|
|
private Container timelineContainer;
|
2019-12-05 19:12:25 +08:00
|
|
|
|
2020-09-24 16:03:54 +08:00
|
|
|
protected EditorScreenWithTimeline(EditorScreenMode type)
|
|
|
|
: base(type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-05 12:27:45 +08:00
|
|
|
private Container mainContent;
|
|
|
|
|
|
|
|
private LoadingSpinner spinner;
|
|
|
|
|
2019-10-09 15:05:55 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
2022-05-24 15:15:24 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider, [CanBeNull] BindableBeatDivisor beatDivisor)
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
|
|
|
if (beatDivisor != null)
|
|
|
|
this.beatDivisor.BindTo(beatDivisor);
|
|
|
|
|
2021-04-14 15:00:49 +08:00
|
|
|
Child = new GridContainer
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
2020-02-07 17:23:59 +08:00
|
|
|
},
|
2021-04-14 15:00:49 +08:00
|
|
|
Content = new[]
|
2020-02-07 17:23:59 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
new Drawable[]
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2020-02-07 17:23:59 +08:00
|
|
|
new Container
|
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
Name = "Timeline",
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-05-24 15:15:24 +08:00
|
|
|
Colour = colourProvider.Background4
|
2021-04-14 15:00:49 +08:00
|
|
|
},
|
|
|
|
new Container
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
Name = "Timeline content",
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2022-05-24 15:32:44 +08:00
|
|
|
Padding = new MarginPadding { Horizontal = padding, Top = padding },
|
2021-04-14 15:00:49 +08:00
|
|
|
Child = new GridContainer
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Content = new[]
|
2019-10-09 15:05:55 +08:00
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
timelineContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Padding = new MarginPadding { Right = 5 },
|
|
|
|
},
|
|
|
|
new BeatDivisorControl(beatDivisor) { RelativeSizeAxes = Axes.Both }
|
|
|
|
},
|
2019-10-09 15:05:55 +08:00
|
|
|
},
|
2021-04-14 15:00:49 +08:00
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Absolute, 90),
|
|
|
|
}
|
2020-02-07 17:23:59 +08:00
|
|
|
},
|
2019-10-09 15:05:55 +08:00
|
|
|
}
|
2021-04-14 15:00:49 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
mainContent = new Container
|
|
|
|
{
|
|
|
|
Name = "Main content",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-04-14 17:15:11 +08:00
|
|
|
Depth = float.MaxValue,
|
2021-04-14 15:00:49 +08:00
|
|
|
Child = spinner = new LoadingSpinner(true)
|
|
|
|
{
|
|
|
|
State = { Value = Visibility.Visible },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2019-10-09 15:05:55 +08:00
|
|
|
};
|
2021-01-05 12:27:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2020-09-23 12:16:46 +08:00
|
|
|
|
2019-10-09 15:05:55 +08:00
|
|
|
LoadComponentAsync(CreateMainContent(), content =>
|
|
|
|
{
|
2020-08-17 23:47:32 +08:00
|
|
|
spinner.State.Value = Visibility.Hidden;
|
|
|
|
|
2019-10-09 15:05:55 +08:00
|
|
|
mainContent.Add(content);
|
|
|
|
content.FadeInFromZero(300, Easing.OutQuint);
|
2019-12-05 19:12:25 +08:00
|
|
|
|
2022-05-24 15:33:20 +08:00
|
|
|
LoadComponentAsync(new TimelineArea(CreateTimelineContent()), timelineContainer.Add);
|
2019-10-09 15:05:55 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract Drawable CreateMainContent();
|
|
|
|
|
2019-12-05 22:31:21 +08:00
|
|
|
protected virtual Drawable CreateTimelineContent() => new Container();
|
2019-10-09 15:05:55 +08:00
|
|
|
}
|
|
|
|
}
|