mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Fix tab strip in BreadcrumbControl, allow strip height to be overriden.
This commit is contained in:
parent
3d05798d80
commit
e3218250d5
@ -2,7 +2,9 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
@ -10,10 +12,12 @@ namespace osu.Game.Tests.Visual
|
||||
[TestFixture]
|
||||
public class TestCaseBreadcrumbs : OsuTestCase
|
||||
{
|
||||
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
|
||||
|
||||
public TestCaseBreadcrumbs()
|
||||
{
|
||||
BreadcrumbControl<BreadcrumbTab> c;
|
||||
Add(c = new BreadcrumbControl<BreadcrumbTab>
|
||||
|
||||
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -21,9 +25,15 @@ namespace osu.Game.Tests.Visual
|
||||
Width = 0.5f,
|
||||
});
|
||||
|
||||
AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click);
|
||||
AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The);
|
||||
AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles);
|
||||
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
|
||||
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
|
||||
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
breadcrumbs.StripColour = colours.Blue;
|
||||
}
|
||||
|
||||
private enum BreadcrumbTab
|
||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value);
|
||||
|
||||
protected override float StripWidth() => base.StripWidth() - (padding + 8);
|
||||
|
||||
public BreadcrumbControl()
|
||||
{
|
||||
Height = 26;
|
||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
||||
|
||||
protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
|
||||
protected virtual float StripHeight() => 1;
|
||||
|
||||
private static bool isEnumType => typeof(T).IsEnum;
|
||||
|
||||
@ -38,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Height = 1,
|
||||
Height = StripHeight(),
|
||||
Colour = Color4.White.Opacity(0),
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user