mirror of
https://github.com/ppy/osu
synced 2024-12-24 15:53:37 +00:00
Merge pull request #7624 from EVAST9919/breadcrumb-fix
Fix visual inconsistency in BreadcrumbControl
This commit is contained in:
commit
962449a5fa
@ -1,9 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<BreadcrumbTab> breadcrumbs;
|
||||
private readonly TestBreadcrumbControl breadcrumbs;
|
||||
|
||||
public TestSceneBreadcrumbControl()
|
||||
{
|
||||
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
|
||||
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<BreadcrumbTab>
|
||||
{
|
||||
public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ 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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||
public class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||
{
|
||||
protected virtual float ChevronSize => 10;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user