// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps.Timing; using osu.Game.Graphics; namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts { /// /// The part of the timeline that displays breaks in the song. /// public partial class BreakPart : TimelinePart { private readonly BindableList breaks = new BindableList(); private DrawablePool pool = null!; [BackgroundDependencyLoader] private void load() { AddInternal(pool = new DrawablePool(10)); } protected override void LoadBeatmap(EditorBeatmap beatmap) { base.LoadBeatmap(beatmap); breaks.UnbindAll(); breaks.BindTo(beatmap.Breaks); } protected override void LoadComplete() { base.LoadComplete(); breaks.BindCollectionChanged((_, _) => { Clear(disposeChildren: false); foreach (var breakPeriod in breaks) Add(pool.Get(v => v.BreakPeriod = breakPeriod)); }, true); } private partial class BreakVisualisation : PoolableDrawable { public BreakPeriod BreakPeriod { set { X = (float)value.StartTime; Width = (float)value.Duration; } } [BackgroundDependencyLoader] private void load(OsuColour colours) { RelativePositionAxes = Axes.X; RelativeSizeAxes = Axes.Both; InternalChild = new Circle { RelativeSizeAxes = Axes.Both }; Colour = colours.Gray7; } } } }