From 4f17a4fe91fdf5f9e78acae54b555fc3c07617e7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 23 May 2017 14:34:34 -0300 Subject: [PATCH] Make result counts scroll with the panels --- .../Tests/TestCaseDirect.cs | 4 +- osu.Game/Overlays/Direct/FilterControl.cs | 58 --------------- osu.Game/Overlays/DirectOverlay.cs | 72 +++++++++++++++++-- 3 files changed, 69 insertions(+), 65 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index c68796a9ab..c1f2307f20 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -23,9 +23,9 @@ namespace osu.Desktop.VisualTests.Tests Add(direct = new DirectOverlay()); newBeatmaps(); - direct.ResultCounts = new ResultCounts(1, 432, 3); - AddStep(@"Toggle", direct.ToggleVisibility); + AddStep(@"toggle", direct.ToggleVisibility); + AddStep(@"result counts", () => direct.ResultCounts = new ResultCounts(1, 4, 13)); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 185ab7c321..7d8a4a6a85 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -12,7 +12,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using Container = osu.Framework.Graphics.Containers.Container; @@ -23,34 +22,16 @@ namespace osu.Game.Overlays.Direct { public static readonly float HEIGHT = 35 + 32 + 30 + padding * 2; // search + mode toggle buttons + sort tabs + padding - /// - /// The height of the content below the filter control (tab strip + result count text). - /// - public static readonly float LOWER_HEIGHT = 21; - private const float padding = 10; private readonly Box tabStrip; private readonly FillFlowContainer modeButtons; - 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 - { - get { return resultCounts; } - set - { - resultCounts = value; - updateResultCounts(); - } - } - protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || RankStatusDropdown.Contains(screenSpacePos); public FilterControl() @@ -127,41 +108,17 @@ namespace osu.Game.Overlays.Direct }, }, }, - resultCountsContainer = new FillFlowContainer - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Margin = new MarginPadding { Left = DirectOverlay.WIDTH_PADDING, Top = 6 }, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = @"Found ", - TextSize = 15, - }, - resultCountsText = new OsuSpriteText - { - TextSize = 15, - Font = @"Exo2.0-Bold", - }, - } - }, }; RankStatusDropdown.Current.Value = RankStatus.RankedApproved; SortTabs.Current.Value = SortCriteria.Title; SortTabs.Current.TriggerChange(); - - updateResultCounts(); } [BackgroundDependencyLoader(true)] private void load(OsuGame game, RulesetDatabase rulesets, OsuColour colours) { tabStrip.Colour = colours.Yellow; - resultCountsContainer.Colour = colours.Yellow; RankStatusDropdown.AccentColour = colours.BlueDark; var b = new Bindable(); //backup bindable incase the game is null @@ -171,21 +128,6 @@ namespace osu.Game.Overlays.Direct } } - private void updateResultCounts() - { - resultCountsContainer.FadeTo(ResultCounts == null ? 0 : 1, 200, EasingTypes.Out); - if (resultCounts == null) return; - - resultCountsText.Text = pluralize(@"Artist", ResultCounts?.Artists ?? 0) + ", " + - pluralize(@"Song", ResultCounts?.Songs ?? 0) + ", " + - pluralize(@"Tag", ResultCounts?.Tags ?? 0); - } - - private string pluralize(string prefix, int value) - { - return $@"{value} {prefix}" + (value == 1 ? string.Empty : @"s"); - } - private class DirectSearchTextBox : SearchTextBox { protected override Color4 BackgroundUnfocused => backgroundColour; diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 928ab3b300..368518fc6d 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using OpenTK; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -11,6 +12,7 @@ using osu.Framework.Input; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Direct; namespace osu.Game.Overlays @@ -21,6 +23,8 @@ namespace osu.Game.Overlays private const float panel_padding = 10f; private readonly FilterControl filter; + private readonly FillFlowContainer resultCountsContainer; + private readonly OsuSpriteText resultCountsText; private readonly FillFlowContainer panels; private IEnumerable beatmapSets; @@ -36,10 +40,17 @@ namespace osu.Game.Overlays } } + private ResultCounts resultCounts; public ResultCounts ResultCounts { - get { return filter.ResultCounts; } - set { filter.ResultCounts = value; } + get { return resultCounts; } + set + { + if (value == ResultCounts) return; + resultCounts = value; + + updateResultCounts(); + } } public DirectOverlay() @@ -88,12 +99,40 @@ namespace osu.Game.Overlays ScrollDraggerVisible = false, Children = new Drawable[] { - panels = new FillFlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Top = FilterControl.LOWER_HEIGHT + panel_padding, Bottom = panel_padding, Left = WIDTH_PADDING, Right = WIDTH_PADDING }, - Spacing = new Vector2(panel_padding), + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + resultCountsContainer = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Left = WIDTH_PADDING, Top = 6 }, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = @"Found ", + TextSize = 15, + }, + resultCountsText = new OsuSpriteText + { + TextSize = 15, + Font = @"Exo2.0-Bold", + }, + } + }, + panels = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Top = panel_padding, Bottom = panel_padding, Left = WIDTH_PADDING, Right = WIDTH_PADDING }, + Spacing = new Vector2(panel_padding), + }, + }, }, }, }, @@ -115,6 +154,29 @@ namespace osu.Game.Overlays filter.Search.Exit = Hide; filter.Search.Current.ValueChanged += text => { if (text != string.Empty) header.Tabs.Current.Value = DirectTab.Search; }; filter.DisplayStyle.ValueChanged += recreatePanels; + + updateResultCounts(); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + resultCountsContainer.Colour = colours.Yellow; + } + + private void updateResultCounts() + { + resultCountsContainer.FadeTo(ResultCounts == null ? 0f : 1f, 200, EasingTypes.Out); + if (ResultCounts == null) return; + + resultCountsText.Text = pluralize(@"Artist", ResultCounts?.Artists ?? 0) + ", " + + pluralize(@"Song", ResultCounts?.Songs ?? 0) + ", " + + pluralize(@"Tag", ResultCounts?.Tags ?? 0); + } + + private string pluralize(string prefix, int value) + { + return $@"{value} {prefix}" + (value == 1 ? string.Empty : @"s"); } private void recreatePanels(PanelDisplayStyle displayStyle)