// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; namespace osu.Game.Rulesets.Osu.UI { public class PlayfieldAdjustmentContainer : Container { protected override Container Content => content; private readonly Container content; public PlayfieldAdjustmentContainer() { InternalChild = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fit, FillAspectRatio = 4f / 3, Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both } }; } /// /// A which scales its content relative to a target width. /// private class ScalingContainer : Container { protected override void Update() { base.Update(); Scale = new Vector2(Parent.ChildSize.X / OsuPlayfield.BASE_SIZE.X); Size = Vector2.Divide(Vector2.One, Scale); } } } }