From 852e622f02056bf296f0b3ae5721c659df0b1d7c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 26 Jan 2020 13:12:35 +0300 Subject: [PATCH 1/2] Fix broken BreadcrumbControl --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index e2438cc4cd..4dfb2769dc 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -34,8 +34,8 @@ namespace osu.Game.Graphics.UserInterface var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]); - t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; - t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint); + t.State = tIndex > tabIndex ? Visibility.Hidden : Visibility.Visible; + t.Chevron.FadeTo(tIndex >= tabIndex ? 0f : 1f, 500, Easing.OutQuint); } }; } From 431b1489b9e859fcb79ea6dfd0709c33fb3d7478 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 27 Jan 2020 13:16:36 +0900 Subject: [PATCH 2/2] Add test --- .../TestSceneBreadcrumbControl.cs | 27 +++++++++++++++++-- .../UserInterface/BreadcrumbControl.cs | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs index 19eebc89b6..3967b62c95 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs @@ -1,9 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -12,11 +14,11 @@ namespace osu.Game.Tests.Visual.UserInterface [TestFixture] public class TestSceneBreadcrumbControl : OsuTestScene { - private readonly BreadcrumbControl breadcrumbs; + private readonly TestBreadcrumbControl breadcrumbs; public TestSceneBreadcrumbControl() { - Add(breadcrumbs = new BreadcrumbControl + Add(breadcrumbs = new TestBreadcrumbControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -25,8 +27,13 @@ namespace osu.Game.Tests.Visual.UserInterface }); AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click); + assertVisible(1); + AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The); + assertVisible(2); + AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles); + assertVisible(3); } [BackgroundDependencyLoader] @@ -35,11 +42,27 @@ namespace osu.Game.Tests.Visual.UserInterface breadcrumbs.StripColour = colours.Blue; } + private void assertVisible(int count) => AddAssert($"first {count} item(s) visible", () => + { + for (int i = 0; i < count; i++) + { + if (breadcrumbs.GetDrawable((BreadcrumbTab)i).State != Visibility.Visible) + return false; + } + + return true; + }); + private enum BreadcrumbTab { Click, The, Circles, } + + private class TestBreadcrumbControl : BreadcrumbControl + { + public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab); + } } } diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 4dfb2769dc..84429bf5bd 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -40,7 +40,7 @@ namespace osu.Game.Graphics.UserInterface }; } - protected class BreadcrumbTabItem : OsuTabItem, IStateful + public class BreadcrumbTabItem : OsuTabItem, IStateful { protected virtual float ChevronSize => 10;