From 1bab2236fe40c4b87f39ebac16bbfafda370b898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 3 Oct 2024 15:01:23 +0200 Subject: [PATCH] Ensure columns collapse into one correctly if no space --- osu.Game.Rulesets.Catch/CatchRuleset.cs | 2 +- osu.Game.Rulesets.Osu/OsuRuleset.cs | 2 +- osu.Game/Screens/Edit/Setup/SetupScreen.cs | 50 ++++++++++++++-------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index 9f48da599e..5bd7a0ff00 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -233,7 +233,7 @@ public override IEnumerable CreateEditorSetupSections() => { AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Spacing = new Vector2(25), + Spacing = new Vector2(SetupScreen.SPACING), Children = new Drawable[] { new ResourcesSection diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 9f2a5b2066..2f928aaefa 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -346,7 +346,7 @@ public override IEnumerable CreateEditorSetupSections() => { AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Spacing = new Vector2(25), + Spacing = new Vector2(SetupScreen.SPACING), Children = new Drawable[] { new ResourcesSection diff --git a/osu.Game/Screens/Edit/Setup/SetupScreen.cs b/osu.Game/Screens/Edit/Setup/SetupScreen.cs index 1af54d55d6..38720f6333 100644 --- a/osu.Game/Screens/Edit/Setup/SetupScreen.cs +++ b/osu.Game/Screens/Edit/Setup/SetupScreen.cs @@ -15,6 +15,10 @@ namespace osu.Game.Screens.Edit.Setup { public partial class SetupScreen : EditorScreen { + public const float COLUMN_WIDTH = 450; + public const float SPACING = 28; + public const float MAX_WIDTH = 2 * COLUMN_WIDTH + SPACING; + public SetupScreen() : base(EditorScreenMode.SongSetup) { @@ -23,6 +27,9 @@ public SetupScreen() [Cached] private SetupScreenHeaderBackground background = new SetupScreenHeaderBackground { RelativeSizeAxes = Axes.Both, }; + private OsuScrollContainer scroll = null!; + private FillFlowContainer flow = null!; + [BackgroundDependencyLoader] private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider) { @@ -51,31 +58,24 @@ private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider) }, new Drawable[] { - new OsuScrollContainer + scroll = new OsuScrollContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(15), - Child = new FillFlowContainer + Child = flow = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Full, - Spacing = new Vector2(28), - Children = new Drawable[] + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Spacing = new Vector2(25), + ChildrenEnumerable = ruleset.CreateEditorSetupSections().Select(section => section.With(s => { - new FillFlowContainer - { - Width = 925, - AutoSizeAxes = Axes.Y, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Spacing = new Vector2(25), - ChildrenEnumerable = ruleset.CreateEditorSetupSections().Select(section => section.With(s => - { - s.Width = 450; - })), - }, - } + s.Width = 450; + s.Anchor = Anchor.TopCentre; + s.Origin = Anchor.TopCentre; + })), } } } @@ -84,6 +84,22 @@ private void load(EditorBeatmap beatmap, OverlayColourProvider colourProvider) }; } + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + if (scroll.DrawWidth > MAX_WIDTH) + { + flow.RelativeSizeAxes = Axes.None; + flow.Width = MAX_WIDTH; + } + else + { + flow.RelativeSizeAxes = Axes.X; + flow.Width = 1; + } + } + public override void OnExiting(ScreenExitEvent e) { base.OnExiting(e);