2019-01-24 16:43:03 +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.
|
2018-05-18 12:05:58 +08:00
|
|
|
|
2019-12-05 19:12:25 +08:00
|
|
|
using osu.Framework.Allocation;
|
2024-06-17 18:11:19 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-05-18 12:05:58 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-27 18:29:27 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2023-07-14 14:58:53 +08:00
|
|
|
using osu.Game.Graphics;
|
2022-05-24 15:32:44 +08:00
|
|
|
using osu.Game.Overlays;
|
2023-07-21 13:39:15 +08:00
|
|
|
using osu.Game.Rulesets.Edit;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
2018-05-18 12:05:58 +08:00
|
|
|
|
2018-11-06 17:28:22 +08:00
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
2018-05-18 12:05:58 +08:00
|
|
|
{
|
2021-04-14 19:55:12 +08:00
|
|
|
public partial class TimelineArea : CompositeDrawable
|
2018-05-18 12:05:58 +08:00
|
|
|
{
|
2023-07-14 13:04:12 +08:00
|
|
|
public Timeline Timeline = null!;
|
2018-05-18 12:05:58 +08:00
|
|
|
|
2021-04-14 19:55:12 +08:00
|
|
|
private readonly Drawable userContent;
|
|
|
|
|
2024-06-17 18:11:19 +08:00
|
|
|
private Box timelineBackground = null!;
|
|
|
|
private readonly Bindable<bool> composerFocusMode = new Bindable<bool>();
|
|
|
|
|
2023-07-14 13:04:12 +08:00
|
|
|
public TimelineArea(Drawable? content = null)
|
2021-04-14 19:55:12 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
2023-07-14 13:04:12 +08:00
|
|
|
userContent = content ?? Empty();
|
2021-04-14 19:55:12 +08:00
|
|
|
}
|
2019-12-05 19:12:25 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2024-06-17 18:11:19 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider, OsuColour colours, Editor? editor)
|
2018-05-18 12:05:58 +08:00
|
|
|
{
|
2023-07-21 13:39:15 +08:00
|
|
|
const float padding = 10;
|
|
|
|
|
2018-05-18 12:05:58 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2024-06-17 18:11:19 +08:00
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Width = 35 + HitObjectComposer.TOOLBOX_CONTRACTED_SIZE_RIGHT,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Colour = colourProvider.Background4
|
|
|
|
},
|
2018-05-18 12:05:58 +08:00
|
|
|
new GridContainer
|
|
|
|
{
|
2021-04-14 15:00:49 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2023-07-14 13:19:04 +08:00
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(),
|
2023-07-14 14:58:53 +08:00
|
|
|
new Dimension(GridSizeMode.Absolute, 35),
|
2024-06-17 17:47:37 +08:00
|
|
|
new Dimension(GridSizeMode.Absolute, HitObjectComposer.TOOLBOX_CONTRACTED_SIZE_RIGHT),
|
2023-07-14 13:19:04 +08:00
|
|
|
},
|
2018-05-18 12:05:58 +08:00
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
2023-07-14 13:24:40 +08:00
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2024-06-17 18:11:19 +08:00
|
|
|
timelineBackground = new Box
|
2023-07-14 13:24:40 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
Colour = colourProvider.Background5
|
|
|
|
},
|
|
|
|
Timeline = new Timeline(userContent),
|
|
|
|
}
|
|
|
|
},
|
2018-05-18 12:05:58 +08:00
|
|
|
new Container
|
|
|
|
{
|
2023-07-14 13:19:04 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-05-24 15:32:44 +08:00
|
|
|
Name = @"Zoom controls",
|
2023-07-21 13:39:15 +08:00
|
|
|
Padding = new MarginPadding { Right = padding },
|
2018-05-18 12:05:58 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2023-07-14 13:19:04 +08:00
|
|
|
Colour = colourProvider.Background2,
|
2018-05-18 12:05:58 +08:00
|
|
|
},
|
|
|
|
new Container<TimelineButton>
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2023-07-14 13:19:04 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-05-18 12:05:58 +08:00
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
new TimelineButton
|
|
|
|
{
|
2023-07-14 13:19:04 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(1, 0.5f),
|
2019-04-02 18:55:24 +08:00
|
|
|
Icon = FontAwesome.Solid.SearchPlus,
|
2022-07-22 13:44:48 +08:00
|
|
|
Action = () => Timeline.AdjustZoomRelatively(1)
|
2018-05-18 12:05:58 +08:00
|
|
|
},
|
|
|
|
new TimelineButton
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2023-07-14 13:19:04 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Size = new Vector2(1, 0.5f),
|
2019-04-02 18:55:24 +08:00
|
|
|
Icon = FontAwesome.Solid.SearchMinus,
|
2022-07-22 13:44:48 +08:00
|
|
|
Action = () => Timeline.AdjustZoomRelatively(-1)
|
2018-05-18 12:05:58 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-07-14 13:19:04 +08:00
|
|
|
new BeatDivisorControl { RelativeSizeAxes = Axes.Both }
|
2018-05-18 12:05:58 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
2024-06-17 18:11:19 +08:00
|
|
|
|
|
|
|
if (editor != null)
|
|
|
|
composerFocusMode.BindTo(editor.ComposerFocusMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
composerFocusMode.BindValueChanged(_ => timelineBackground.FadeTo(composerFocusMode.Value ? 0.5f : 1, 400, Easing.OutQuint), true);
|
2018-05-18 12:05:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|