From 6802e9ec109c34309529a10b950038e54cc62015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Oct 2021 20:20:40 +0200 Subject: [PATCH] Remove `FixedWidth` and add `AutoSizeAxes` specs to all usages --- .../TestSceneBeatmapSetOnlineStatusPill.cs | 9 +++++-- .../Drawables/BeatmapSetOnlineStatusPill.cs | 26 ------------------- .../BeatmapListing/Panels/GridBeatmapPanel.cs | 1 + .../BeatmapListing/Panels/ListBeatmapPanel.cs | 1 + .../BeatmapSet/BeatmapSetHeaderContent.cs | 1 + osu.Game/Screens/Select/BeatmapInfoWedge.cs | 1 + .../Select/Carousel/SetPanelContent.cs | 1 + 7 files changed, 12 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs index 2d61385269..c48b63ac89 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs @@ -28,6 +28,7 @@ namespace osu.Game.Tests.Visual.Beatmaps Spacing = new Vector2(0, 10), ChildrenEnumerable = Enum.GetValues(typeof(BeatmapSetOnlineStatus)).Cast().Select(status => new BeatmapSetOnlineStatusPill { + AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Status = status @@ -41,8 +42,12 @@ namespace osu.Game.Tests.Visual.Beatmaps { AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red)); - AddStep("set fixed width", () => statusPills.ForEach(pill => pill.FixedWidth = 90)); - AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.FixedWidth = null)); + AddStep("set fixed width", () => statusPills.ForEach(pill => + { + pill.AutoSizeAxes = Axes.Y; + pill.Width = 90; + })); + AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both)); } } } diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs index 848bab6394..ec098f4ca2 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs @@ -47,31 +47,6 @@ namespace osu.Game.Beatmaps.Drawables set => statusText.Padding = value; } - private float? fixedWidth; - - /// - /// When set to a non- value, the pill will be forcibly sized to the given width. - /// When set to a value, the pill will autosize to its contents. - /// - public float? FixedWidth - { - get => fixedWidth; - set - { - fixedWidth = value; - - if (fixedWidth == null) - { - AutoSizeAxes = Axes.Both; - } - else - { - AutoSizeAxes = Axes.Y; - Width = fixedWidth.Value; - } - } - } - private readonly OsuSpriteText statusText; private readonly Box background; @@ -83,7 +58,6 @@ namespace osu.Game.Beatmaps.Drawables public BeatmapSetOnlineStatusPill() { - AutoSizeAxes = Axes.Both; Masking = true; Children = new Drawable[] diff --git a/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs b/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs index c078127353..4a0fa59c31 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs @@ -243,6 +243,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels statusContainer.Add(new BeatmapSetOnlineStatusPill { + AutoSizeAxes = Axes.Both, TextSize = 12, TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 }, Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, diff --git a/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs b/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs index 5011749c5f..63d651f9de 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs @@ -257,6 +257,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels statusContainer.Add(new BeatmapSetOnlineStatusPill { + AutoSizeAxes = Axes.Both, TextSize = 12, TextPadding = new MarginPadding { Horizontal = 10, Vertical = 4 }, Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index df88b06879..6f85846720 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -198,6 +198,7 @@ namespace osu.Game.Overlays.BeatmapSet { onlineStatusPill = new BeatmapSetOnlineStatusPill { + AutoSizeAxes = Axes.Both, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, TextSize = 14, diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index ac191a38f2..2de72beaad 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -257,6 +257,7 @@ namespace osu.Game.Screens.Select }, StatusPill = new BeatmapSetOnlineStatusPill { + AutoSizeAxes = Axes.Both, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Shear = -wedged_container_shear, diff --git a/osu.Game/Screens/Select/Carousel/SetPanelContent.cs b/osu.Game/Screens/Select/Carousel/SetPanelContent.cs index 9fb640ba1a..f2054677b0 100644 --- a/osu.Game/Screens/Select/Carousel/SetPanelContent.cs +++ b/osu.Game/Screens/Select/Carousel/SetPanelContent.cs @@ -60,6 +60,7 @@ namespace osu.Game.Screens.Select.Carousel { new BeatmapSetOnlineStatusPill { + AutoSizeAxes = Axes.Both, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, Margin = new MarginPadding { Right = 5 },