// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osuTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts { public class TimelinePart : TimelinePart { } /// /// Represents a part of the summary timeline.. /// public class TimelinePart : Container where T : Drawable { protected readonly IBindable Beatmap = new Bindable(); private readonly Container content; protected override Container Content => content; public TimelinePart(Container content = null) { AddInternal(this.content = content ?? new Container { RelativeSizeAxes = Axes.Both }); Beatmap.ValueChanged += b => { updateRelativeChildSize(); LoadBeatmap(b.NewValue); }; } [BackgroundDependencyLoader] private void load(IBindable beatmap) { Beatmap.BindTo(beatmap); } private void updateRelativeChildSize() { // the track may not be loaded completely (only has a length once it is). if (!Beatmap.Value.Track.IsLoaded) { content.RelativeChildSize = Vector2.One; Schedule(updateRelativeChildSize); return; } content.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1); } protected virtual void LoadBeatmap(WorkingBeatmap beatmap) { content.Clear(); } } }