1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Add ability to create ruleset selector in OverlayHeader

This commit is contained in:
Andrei Zavatski 2020-02-03 11:09:46 +03:00
parent 9650a4fb47
commit 81ab6d43b6
2 changed files with 31 additions and 8 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.UserInterface
addHeader("Orange OverlayHeader (no background)", new TestNoBackgroundHeader(), OverlayColourScheme.Orange);
addHeader("Blue OverlayHeader", new TestNoControlHeader(), OverlayColourScheme.Blue);
addHeader("Green TabControlOverlayHeader (string)", new TestStringTabControlHeader(), OverlayColourScheme.Green);
addHeader("Green TabControlOverlayHeader (string) with ruleset selector", new TestStringTabControlHeader(), OverlayColourScheme.Green);
addHeader("Pink TabControlOverlayHeader (enum)", new TestEnumTabControlHeader(), OverlayColourScheme.Pink);
addHeader("Red BreadcrumbControlOverlayHeader (no background)", new TestBreadcrumbControlHeader(), OverlayColourScheme.Red);
}
@ -116,6 +116,8 @@ namespace osu.Game.Tests.Visual.UserInterface
protected override ScreenTitle CreateTitle() => new TestTitle();
protected override Drawable CreateTitleContent() => new OverlayRulesetSelector();
public TestStringTabControlHeader()
{
TabControl.AddItem("tab1");

View File

@ -50,14 +50,29 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Colour = Color4.Gray,
},
title = CreateTitle().With(title =>
new Container
{
title.Margin = new MarginPadding
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding
{
Horizontal = UserProfileOverlay.CONTENT_X_MARGIN,
Vertical = 10,
Left = UserProfileOverlay.CONTENT_X_MARGIN
};
})
},
Children = new[]
{
title = CreateTitle().With(title =>
{
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
}),
CreateTitleContent().With(content =>
{
content.Anchor = Anchor.CentreRight;
content.Origin = Anchor.CentreRight;
})
}
}
}
},
}
@ -75,10 +90,16 @@ namespace osu.Game.Overlays
}
[NotNull]
protected virtual Drawable CreateContent() => Drawable.Empty();
protected virtual Drawable CreateContent() => Empty();
[NotNull]
protected virtual Drawable CreateBackground() => Drawable.Empty();
protected virtual Drawable CreateBackground() => Empty();
/// <summary>
/// Creates a <see cref="Drawable"/> on the opposite side of the <see cref="ScreenTitle"/>. Used mostly to create <see cref="OverlayRulesetSelector"/>.
/// </summary>
[NotNull]
protected virtual Drawable CreateTitleContent() => Empty();
protected abstract ScreenTitle CreateTitle();
}