1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-16 04:32:57 +08:00

Merge pull request #18161 from Joehuu/column-flow-cq

Improve code quality of mod column flow container
This commit is contained in:
Bartłomiej Dach 2022-05-09 19:44:54 +02:00 committed by GitHub
commit c52b6d9e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Layout;
using osu.Framework.Lists; using osu.Framework.Lists;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Audio; using osu.Game.Audio;
@ -125,11 +124,14 @@ namespace osu.Game.Overlays.Mods
ScrollbarOverlapsContent = false, ScrollbarOverlapsContent = false,
Child = columnFlow = new ColumnFlowContainer Child = columnFlow = new ColumnFlowContainer
{ {
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Shear = new Vector2(SHEAR, 0), Shear = new Vector2(SHEAR, 0),
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Margin = new MarginPadding { Horizontal = 70 }, Margin = new MarginPadding { Horizontal = 70 },
Padding = new MarginPadding { Bottom = 10 },
Children = new[] Children = new[]
{ {
createModColumnContent(ModType.DifficultyReduction, new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P }), createModColumnContent(ModType.DifficultyReduction, new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P }),
@ -521,19 +523,12 @@ namespace osu.Game.Overlays.Mods
} }
/// <summary> /// <summary>
/// Manages padding and layout of mod columns. /// Manages layout of mod columns.
/// </summary> /// </summary>
internal class ColumnFlowContainer : FillFlowContainer<ColumnDimContainer> internal class ColumnFlowContainer : FillFlowContainer<ColumnDimContainer>
{ {
public IEnumerable<ModColumn> Columns => Children.Select(dimWrapper => dimWrapper.Column); public IEnumerable<ModColumn> Columns => Children.Select(dimWrapper => dimWrapper.Column);
private readonly LayoutValue drawSizeLayout = new LayoutValue(Invalidation.DrawSize);
public ColumnFlowContainer()
{
AddLayout(drawSizeLayout);
}
public override void Add(ColumnDimContainer dimContainer) public override void Add(ColumnDimContainer dimContainer)
{ {
base.Add(dimContainer); base.Add(dimContainer);
@ -541,22 +536,6 @@ namespace osu.Game.Overlays.Mods
Debug.Assert(dimContainer != null); Debug.Assert(dimContainer != null);
dimContainer.Column.Shear = Vector2.Zero; dimContainer.Column.Shear = Vector2.Zero;
} }
protected override void Update()
{
base.Update();
if (!drawSizeLayout.IsValid)
{
Padding = new MarginPadding
{
Left = DrawHeight * SHEAR,
Bottom = 10
};
drawSizeLayout.Validate();
}
}
} }
/// <summary> /// <summary>