Remove FixedWidth and add AutoSizeAxes specs to all usages

This commit is contained in:
Bartłomiej Dach
2021-10-25 20:20:40 +02:00
parent feedd53a53
commit 6802e9ec10
7 changed files with 12 additions and 28 deletions

View File

@ -28,6 +28,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
Spacing = new Vector2(0, 10), Spacing = new Vector2(0, 10),
ChildrenEnumerable = Enum.GetValues(typeof(BeatmapSetOnlineStatus)).Cast<BeatmapSetOnlineStatus>().Select(status => new BeatmapSetOnlineStatusPill ChildrenEnumerable = Enum.GetValues(typeof(BeatmapSetOnlineStatus)).Cast<BeatmapSetOnlineStatus>().Select(status => new BeatmapSetOnlineStatusPill
{ {
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Status = status Status = status
@ -41,8 +42,12 @@ namespace osu.Game.Tests.Visual.Beatmaps
{ {
AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red)); AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red));
AddStep("set fixed width", () => statusPills.ForEach(pill => pill.FixedWidth = 90)); AddStep("set fixed width", () => statusPills.ForEach(pill =>
AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.FixedWidth = null)); {
pill.AutoSizeAxes = Axes.Y;
pill.Width = 90;
}));
AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both));
} }
} }
} }

View File

@ -47,31 +47,6 @@ namespace osu.Game.Beatmaps.Drawables
set => statusText.Padding = value; set => statusText.Padding = value;
} }
private float? fixedWidth;
/// <summary>
/// When set to a non-<see langword="null"/> value, the pill will be forcibly sized to the given width.
/// When set to a <see langword="null"/> value, the pill will autosize to its contents.
/// </summary>
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 OsuSpriteText statusText;
private readonly Box background; private readonly Box background;
@ -83,7 +58,6 @@ namespace osu.Game.Beatmaps.Drawables
public BeatmapSetOnlineStatusPill() public BeatmapSetOnlineStatusPill()
{ {
AutoSizeAxes = Axes.Both;
Masking = true; Masking = true;
Children = new Drawable[] Children = new Drawable[]

View File

@ -243,6 +243,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
statusContainer.Add(new BeatmapSetOnlineStatusPill statusContainer.Add(new BeatmapSetOnlineStatusPill
{ {
AutoSizeAxes = Axes.Both,
TextSize = 12, TextSize = 12,
TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 }, TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 },
Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None,

View File

@ -257,6 +257,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
statusContainer.Add(new BeatmapSetOnlineStatusPill statusContainer.Add(new BeatmapSetOnlineStatusPill
{ {
AutoSizeAxes = Axes.Both,
TextSize = 12, TextSize = 12,
TextPadding = new MarginPadding { Horizontal = 10, Vertical = 4 }, TextPadding = new MarginPadding { Horizontal = 10, Vertical = 4 },
Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None,

View File

@ -198,6 +198,7 @@ namespace osu.Game.Overlays.BeatmapSet
{ {
onlineStatusPill = new BeatmapSetOnlineStatusPill onlineStatusPill = new BeatmapSetOnlineStatusPill
{ {
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
TextSize = 14, TextSize = 14,

View File

@ -257,6 +257,7 @@ namespace osu.Game.Screens.Select
}, },
StatusPill = new BeatmapSetOnlineStatusPill StatusPill = new BeatmapSetOnlineStatusPill
{ {
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Shear = -wedged_container_shear, Shear = -wedged_container_shear,

View File

@ -60,6 +60,7 @@ namespace osu.Game.Screens.Select.Carousel
{ {
new BeatmapSetOnlineStatusPill new BeatmapSetOnlineStatusPill
{ {
AutoSizeAxes = Axes.Both,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Margin = new MarginPadding { Right = 5 }, Margin = new MarginPadding { Right = 5 },