Fix tab strip in BreadcrumbControl, allow strip height to be overriden.

This commit is contained in:
DrabWeb
2018-03-29 15:41:27 -03:00
parent 3d05798d80
commit e3218250d5
3 changed files with 19 additions and 6 deletions

View File

@ -2,7 +2,9 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -10,10 +12,12 @@ namespace osu.Game.Tests.Visual
[TestFixture] [TestFixture]
public class TestCaseBreadcrumbs : OsuTestCase public class TestCaseBreadcrumbs : OsuTestCase
{ {
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
public TestCaseBreadcrumbs() public TestCaseBreadcrumbs()
{ {
BreadcrumbControl<BreadcrumbTab> c;
Add(c = new BreadcrumbControl<BreadcrumbTab> Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -21,9 +25,15 @@ namespace osu.Game.Tests.Visual
Width = 0.5f, Width = 0.5f,
}); });
AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click); AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The); AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles); AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
breadcrumbs.StripColour = colours.Blue;
} }
private enum BreadcrumbTab private enum BreadcrumbTab

View File

@ -17,6 +17,8 @@ namespace osu.Game.Graphics.UserInterface
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value); protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value);
protected override float StripWidth() => base.StripWidth() - (padding + 8);
public BreadcrumbControl() public BreadcrumbControl()
{ {
Height = 26; Height = 26;

View File

@ -27,6 +27,7 @@ namespace osu.Game.Graphics.UserInterface
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value); 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 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; private static bool isEnumType => typeof(T).IsEnum;
@ -38,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Height = 1, Height = StripHeight(),
Colour = Color4.White.Opacity(0), Colour = Color4.White.Opacity(0),
}); });