1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Merge pull request #7716 from EVAST9919/overlay-header-ruleset-selector

Add ability to create ruleset selector in OverlayHeader
This commit is contained in:
Dan Balasescu 2020-02-03 19:00:12 +09:00 committed by GitHub
commit 76ba0b833e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 =>
{
title.Anchor = Anchor.CentreLeft;
title.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();
}