1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 14:47:23 +08:00
osu-lazer/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineArea.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

177 lines
8.2 KiB
C#
Raw Normal View History

// 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;
2018-05-18 12:05:58 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
2018-05-18 12:05:58 +08:00
using osu.Game.Graphics.UserInterface;
2023-01-15 06:50:41 +08:00
using osu.Game.Localisation;
using osu.Game.Overlays;
2023-01-15 19:39:34 +08:00
using osu.Game.Resources.Localisation.Web;
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
{
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
private readonly Drawable userContent;
2023-07-14 13:04:12 +08:00
public TimelineArea(Drawable? content = null)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
2023-07-14 13:04:12 +08:00
userContent = content ?? Empty();
}
2019-12-05 19:12:25 +08:00
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, OsuColour colours)
2018-05-18 12:05:58 +08:00
{
OsuCheckbox waveformCheckbox;
OsuCheckbox controlPointsCheckbox;
2020-10-01 17:14:10 +08:00
OsuCheckbox ticksCheckbox;
const float padding = 10;
2018-05-18 12:05:58 +08:00
InternalChildren = new Drawable[]
{
new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
},
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, 135),
new Dimension(),
new Dimension(GridSizeMode.Absolute, 35),
new Dimension(GridSizeMode.Absolute, HitObjectComposer.TOOLBOX_CONTRACTED_SIZE_RIGHT - padding * 2),
},
2018-05-18 12:05:58 +08:00
Content = new[]
{
new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Name = @"Toggle controls",
2018-05-18 12:05:58 +08:00
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background2,
2018-05-18 12:05:58 +08:00
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(padding),
2018-05-18 12:05:58 +08:00
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 4),
Children = new[]
{
waveformCheckbox = new OsuCheckbox(nubSize: 30f)
{
2023-01-15 06:50:41 +08:00
LabelText = EditorStrings.TimelineWaveform,
Current = { Value = true },
},
ticksCheckbox = new OsuCheckbox(nubSize: 30f)
{
2023-01-15 06:50:41 +08:00
LabelText = EditorStrings.TimelineTicks,
Current = { Value = true },
2020-10-01 17:14:10 +08:00
},
controlPointsCheckbox = new OsuCheckbox(nubSize: 30f)
2020-10-01 17:14:10 +08:00
{
2023-01-15 19:39:34 +08:00
LabelText = BeatmapsetsStrings.ShowStatsBpm,
2020-10-01 17:14:10 +08:00
Current = { Value = true },
},
2018-05-18 12:05:58 +08:00
}
}
}
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
// the out-of-bounds portion of the centre marker.
new Box
{
Width = 24,
Height = EditorScreenWithTimeline.PADDING,
Depth = float.MaxValue,
Colour = colours.Red1,
Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
Colour = colourProvider.Background5
},
Timeline = new Timeline(userContent),
}
},
2018-05-18 12:05:58 +08:00
new Container
{
RelativeSizeAxes = Axes.Both,
Name = @"Zoom controls",
Padding = new MarginPadding { Right = padding },
2018-05-18 12:05:58 +08:00
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background2,
2018-05-18 12:05:58 +08:00
},
new Container<TimelineButton>
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Both,
2018-05-18 12:05:58 +08:00
Children = new[]
{
new TimelineButton
{
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,
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
},
}
}
}
},
new BeatDivisorControl { RelativeSizeAxes = Axes.Both }
2018-05-18 12:05:58 +08:00
},
},
}
};
Timeline.WaveformVisible.BindTo(waveformCheckbox.Current);
Timeline.ControlPointsVisible.BindTo(controlPointsCheckbox.Current);
2020-10-01 17:14:10 +08:00
Timeline.TicksVisible.BindTo(ticksCheckbox.Current);
2018-05-18 12:05:58 +08:00
}
}
}