1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

Removed GrowToFItContainer

This commit is contained in:
HiddenNode 2022-08-31 22:04:28 +01:00
parent cda7faecf7
commit eb02a9a144

View File

@ -24,27 +24,6 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public ScaleMode Scaling { get; set; } = ScaleMode.Vertical;
/// <summary>
/// If this is true, all wrapper containers will be set to grow with their content
/// and not shrink back, this is used to fix the position of children that change
/// in size when using AutoSizeAxes.
/// </summary>
public bool GrowToFitContent
{
get => growToFitContent;
set
{
if (growToFitContent != value)
{
foreach (GrowToFitContainer c in Children)
c.GrowToFitContentUpdated = true;
growToFitContent = value;
}
}
}
private bool growToFitContent = true;
private readonly LayoutValue layout = new LayoutValue(Invalidation.DrawInfo, InvalidationSource.Parent);
public UprightAspectMaintainingContainer()
@ -63,15 +42,6 @@ namespace osu.Game.Graphics.Containers
}
}
public override void Add(Drawable drawable)
{
var wrapper = new GrowToFitContainer();
wrapper.Wrap(drawable);
wrapper.AutoSizeAxes = Axes.None;
drawable.Origin = drawable.Anchor = Anchor.Centre;
base.Add(wrapper);
}
/// <summary>
/// Keeps the drawable upright and unstretched preventing it from being rotated, sheared, scaled or flipped with its Parent.
/// </summary>
@ -127,60 +97,6 @@ namespace osu.Game.Graphics.Containers
Scale = new Vector2(sx * usedScale, sy * usedScale);
}
public class GrowToFitContainer : Container
{
private readonly LayoutValue layout = new LayoutValue(Invalidation.RequiredParentSizeToFit, InvalidationSource.Child);
private Vector2 maxChildSize;
public bool GrowToFitContentUpdated { get; set; }
public GrowToFitContainer()
{
AddLayout(layout);
}
protected override void Update()
{
UprightAspectMaintainingContainer parent = (UprightAspectMaintainingContainer)Parent;
if (!layout.IsValid || GrowToFitContentUpdated)
{
if ((Child.RelativeSizeAxes & Axes.X) != 0)
RelativeSizeAxes |= Axes.X;
else
{
if (parent.GrowToFitContent)
Width = Math.Max(Child.Width * Child.Scale.X, maxChildSize.X);
else
Width = Child.Width * Child.Scale.X;
}
if ((Child.RelativeSizeAxes & Axes.Y) != 0)
RelativeSizeAxes |= Axes.Y;
else
{
if (parent.GrowToFitContent)
Height = Math.Max(Child.Height * Child.Scale.Y, maxChildSize.Y);
else
Height = Child.Height * Child.Scale.Y;
}
// reset max_child_size or update it
if (!parent.GrowToFitContent)
maxChildSize = Child.Size;
else
{
maxChildSize.X = MathF.Max(maxChildSize.X, Child.Size.X);
maxChildSize.Y = MathF.Max(maxChildSize.Y, Child.Size.Y);
}
GrowToFitContentUpdated = false;
layout.Validate();
}
}
}
}
public enum ScaleMode