From 05b8fc5126a0617475f055114c01ee6bb2b6bc9a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 19 May 2017 17:52:34 -0300 Subject: [PATCH] Added switching between grid/list and little transitions for the panels --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 17 ++++- osu.Game/Overlays/Direct/DirectListPanel.cs | 7 ++ osu.Game/Overlays/Direct/FilterControl.cs | 85 +++++++++++++++++++-- osu.Game/Overlays/DirectOverlay.cs | 22 ++++-- 4 files changed, 116 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 24d4e77490..65967915d6 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -22,11 +22,14 @@ namespace osu.Game.Overlays.Direct private readonly float horizontal_padding = 10; private readonly float vertical_padding = 5; + private FillFlowContainer bottomPanel; + public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap) { Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) CornerRadius = 4; Masking = true; + EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Shadow, @@ -36,6 +39,16 @@ namespace osu.Game.Overlays.Direct }; } + protected override void LoadComplete() + { + base.LoadComplete(); + + FadeInFromZero(200, EasingTypes.Out); + bottomPanel.LayoutDuration = 200; + bottomPanel.LayoutEasing = EasingTypes.Out; + bottomPanel.Origin = Anchor.BottomLeft; + } + [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation, TextureStore textures) { @@ -52,10 +65,10 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black.Opacity(0.5f), }, - new FillFlowContainer + bottomPanel = new FillFlowContainer { Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, + Origin = Anchor.TopLeft, Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 0dfd80051d..e107561388 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -39,6 +39,13 @@ namespace osu.Game.Overlays.Direct }; } + protected override void LoadComplete() + { + base.LoadComplete(); + + FadeInFromZero(200, EasingTypes.Out); + } + [BackgroundDependencyLoader] private void load(LocalisationEngine localisation, TextureStore textures) { diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 9f792d07ac..8a874e3fd0 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -31,15 +31,16 @@ namespace osu.Game.Overlays.Direct private readonly Box tabStrip; private readonly FillFlowContainer modeButtons; - private FillFlowContainer resultCountsContainer; - private OsuSpriteText resultCountsText; + private readonly FillFlowContainer resultCountsContainer; + private readonly OsuSpriteText resultCountsText; public readonly SearchTextBox Search; public readonly SortTabControl SortTabs; public readonly OsuEnumDropdown RankStatusDropdown; + public readonly Bindable DisplayStyle = new Bindable(); private ResultCounts resultCounts; - public ResultCounts ResultCounts + public ResultCounts ResultCounts { get { return resultCounts; } set { resultCounts = value; updateResultCounts(); } @@ -49,6 +50,7 @@ namespace osu.Game.Overlays.Direct { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + DisplayStyle.Value = PanelDisplayStyle.Grid; Children = new Drawable[] { @@ -90,13 +92,33 @@ namespace osu.Game.Overlays.Direct }, }, }, - RankStatusDropdown = new SlimEnumDropdown + new FillFlowContainer { + AutoSizeAxes = Axes.Both, Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - RelativeSizeAxes = Axes.None, + Spacing = new Vector2(10f, 0f), + Direction = FillDirection.Horizontal, Margin = new MarginPadding { Bottom = 5, Right = DirectOverlay.WIDTH_PADDING }, - Width = 160f, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5f, 0f), + Direction = FillDirection.Horizontal, + Children = new[] + { + new DisplayModeToggleButton(FontAwesome.fa_th_large, PanelDisplayStyle.Grid, DisplayStyle), + new DisplayModeToggleButton(FontAwesome.fa_list_ul, PanelDisplayStyle.List, DisplayStyle), + }, + }, + RankStatusDropdown = new SlimEnumDropdown + { + RelativeSizeAxes = Axes.None, + Width = 160f, + }, + }, }, resultCountsContainer = new FillFlowContainer { @@ -117,7 +139,7 @@ namespace osu.Game.Overlays.Direct TextSize = 15, Font = @"Exo2.0-Bold", }, - } + } }, }; @@ -221,6 +243,47 @@ namespace osu.Game.Overlays.Direct } } + private class DisplayModeToggleButton : ClickableContainer + { + private readonly TextAwesome icon; + private readonly PanelDisplayStyle mode; + private readonly Bindable bindable; + + public DisplayModeToggleButton(FontAwesome icon, PanelDisplayStyle mode, Bindable bindable) + { + this.bindable = bindable; + this.mode = mode; + Size = new Vector2(25f); + + Children = new Drawable[] + { + this.icon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = icon, + TextSize = 18, + UseFullGlyphHeight = false, + Alpha = 0.5f, + }, + }; + + bindable.ValueChanged += Bindable_ValueChanged; + Bindable_ValueChanged(bindable.Value); + Action = () => bindable.Value = this.mode; + } + + private void Bindable_ValueChanged(PanelDisplayStyle mode) + { + icon.FadeTo(mode == this.mode ? 1.0f : 0.5f, 100); + } + + protected override void Dispose(bool isDisposing) + { + bindable.ValueChanged -= Bindable_ValueChanged; + } + } + private class SlimEnumDropdown : OsuEnumDropdown { protected override DropdownHeader CreateHeader() => new SlimDropdownHeader { AccentColour = AccentColour }; @@ -257,7 +320,7 @@ namespace osu.Game.Overlays.Direct public readonly int Artists; public readonly int Songs; public readonly int Tags; - + public ResultCounts(int artists, int songs, int tags) { Artists = artists; @@ -281,4 +344,10 @@ namespace osu.Game.Overlays.Direct [Description("My Maps")] MyMaps, } + + public enum PanelDisplayStyle + { + Grid, + List, + } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index b4f57f1df9..02ea4694c1 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -22,16 +22,16 @@ namespace osu.Game.Overlays private readonly FilterControl filter; private readonly FillFlowContainer panels; + private IEnumerable beatmapSets; public IEnumerable BeatmapSets { + get { return beatmapSets; } set { - var p = new List(); + if (beatmapSets == value) return; + beatmapSets = value; - foreach (BeatmapSetInfo b in value) - p.Add(new DirectListPanel(b)); //todo: proper switching between grid/list - - panels.Children = p; + recreatePanels(filter.DisplayStyle.Value); } } @@ -110,6 +110,18 @@ namespace osu.Game.Overlays }; filter.Search.Exit = Hide; + filter.DisplayStyle.ValueChanged += recreatePanels; + } + + private void recreatePanels(PanelDisplayStyle displayStyle) + { + var p = new List(); + + foreach (BeatmapSetInfo b in BeatmapSets) + p.Add(displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)(new DirectGridPanel(b) { Width = 400}) : + (DirectPanel)(new DirectListPanel(b))); + + panels.Children = p; } protected override void PopIn()