// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Edit.Timing { public class ControlPointSettings : CompositeDrawable { [BackgroundDependencyLoader] private void load(OsuColour colours) { RelativeSizeAxes = Axes.Both; InternalChildren = new Drawable[] { new Box { Colour = colours.Gray3, RelativeSizeAxes = Axes.Both, }, new OsuScrollContainer { RelativeSizeAxes = Axes.Both, Child = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Spacing = new Vector2(30), Children = createSections() }, } }; } private IReadOnlyList createSections() => new Drawable[] { new TimingSection(), new DifficultySection(), new SampleSection(), new EffectSection(), }; private class TimingSection : Section { } private class DifficultySection : Section { } private class SampleSection : Section { } private class EffectSection : Section { } private class Section : Container where T : ControlPoint { private const float header_height = 20; protected override Container Content { get; } [Resolved] private Bindable> selectedPoints { get; set; } protected Section() { RelativeSizeAxes = Axes.X; AutoSizeDuration = 200; AutoSizeEasing = Easing.OutQuint; AutoSizeAxes = Axes.Y; Masking = true; InternalChildren = new Drawable[] { new Box { Colour = Color4.Gray, RelativeSizeAxes = Axes.Both, }, new Container { RelativeSizeAxes = Axes.X, Height = header_height, Children = new Drawable[] { new OsuSpriteText { Text = typeof(T).Name.Replace(typeof(ControlPoint).Name, string.Empty) }, } }, Content = new Container() { Y = header_height, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] { new Box { Colour = Color4.DarkGray, RelativeSizeAxes = Axes.X, Height = 100, }, } } }; } protected override void LoadComplete() { base.LoadComplete(); selectedPoints.BindValueChanged(points => { var matching = points.NewValue?.OfType().Where(p => !p.AutoGenerated).FirstOrDefault(); if (matching != null) { Content.BypassAutoSizeAxes = Axes.None; } else { Content.BypassAutoSizeAxes = Axes.Y; } }, true); } } } }