From c2ba16f977ba8e3fb04d72f56bb81cd647def6d2 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 11 May 2021 16:51:59 +0300 Subject: [PATCH] Use relative sizing for MonthDropdown --- .../Online/TestSceneNewsMonthDropdown.cs | 55 ++++++++----------- .../Overlays/News/Sidebar/MonthDropdown.cs | 2 +- osu.Game/Overlays/News/Sidebar/NewsSideBar.cs | 8 +-- 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsMonthDropdown.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsMonthDropdown.cs index c51e299f78..f03b7d3f58 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneNewsMonthDropdown.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneNewsMonthDropdown.cs @@ -22,46 +22,35 @@ namespace osu.Game.Tests.Visual.Online [Test] public void CreateClosedMonthPanel() { - AddStep("Create", () => Child = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background2, - }, - new MonthDropdown(posts), - } - }); + create(false); } [Test] public void CreateOpenMonthPanel() { - AddStep("Create", () => Child = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background2, - }, - new MonthDropdown(posts) - { - IsOpen = { Value = true } - }, - } - }); + create(true); } + private void create(bool isOpen) => AddStep("Create", () => Child = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Y, + Width = 160, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background2, + }, + new MonthDropdown(posts) + { + IsOpen = { Value = isOpen } + } + } + }); + private static List posts => new List { new APINewsPost diff --git a/osu.Game/Overlays/News/Sidebar/MonthDropdown.cs b/osu.Game/Overlays/News/Sidebar/MonthDropdown.cs index cc06f48544..11c0ce863f 100644 --- a/osu.Game/Overlays/News/Sidebar/MonthDropdown.cs +++ b/osu.Game/Overlays/News/Sidebar/MonthDropdown.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.News.Sidebar public MonthDropdown(IEnumerable posts) { - Width = 160; + RelativeSizeAxes = Axes.X; Masking = true; InternalChild = new FillFlowContainer { diff --git a/osu.Game/Overlays/News/Sidebar/NewsSideBar.cs b/osu.Game/Overlays/News/Sidebar/NewsSideBar.cs index 1518d61d59..7de7e4dd71 100644 --- a/osu.Game/Overlays/News/Sidebar/NewsSideBar.cs +++ b/osu.Game/Overlays/News/Sidebar/NewsSideBar.cs @@ -42,17 +42,17 @@ namespace osu.Game.Overlays.News.Sidebar }, Child = new FillFlowContainer { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, Direction = FillDirection.Vertical, - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Spacing = new Vector2(0, 20), Children = new Drawable[] { new YearsPanel(), monthsFlow = new FillFlowContainer { - AutoSizeAxes = Axes.Both, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10) }