mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Make content side padding adjustable for OverlayHeader
This commit is contained in:
parent
557daadd4a
commit
e96f8f1cb6
@ -36,11 +36,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
});
|
||||
|
||||
addHeader("Orange OverlayHeader (no background)", new TestNoBackgroundHeader(), OverlayColourScheme.Orange);
|
||||
addHeader("Blue OverlayHeader", new TestNoControlHeader(), OverlayColourScheme.Blue);
|
||||
addHeader("Orange OverlayHeader (no background, 100 padding)", new TestNoBackgroundHeader(), OverlayColourScheme.Orange);
|
||||
addHeader("Blue OverlayHeader (default 70 padding)", new TestNoControlHeader(), OverlayColourScheme.Blue);
|
||||
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);
|
||||
addHeader("Pink TabControlOverlayHeader (enum, 30 padding)", new TestEnumTabControlHeader(), OverlayColourScheme.Pink);
|
||||
addHeader("Red BreadcrumbControlOverlayHeader (no background, 10 padding)", new TestBreadcrumbControlHeader(), OverlayColourScheme.Red);
|
||||
}
|
||||
|
||||
private void addHeader(string name, OverlayHeader header, OverlayColourScheme colourScheme)
|
||||
@ -86,6 +86,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
private class TestNoBackgroundHeader : OverlayHeader
|
||||
{
|
||||
protected override OverlayTitle CreateTitle() => new TestTitle();
|
||||
|
||||
public TestNoBackgroundHeader()
|
||||
{
|
||||
ContentSidePadding = 100;
|
||||
}
|
||||
}
|
||||
|
||||
private class TestNoControlHeader : OverlayHeader
|
||||
@ -112,6 +117,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private class TestEnumTabControlHeader : TabControlOverlayHeader<TestEnum>
|
||||
{
|
||||
public TestEnumTabControlHeader()
|
||||
{
|
||||
ContentSidePadding = 30;
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings");
|
||||
|
||||
protected override OverlayTitle CreateTitle() => new TestTitle();
|
||||
@ -130,6 +140,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
public TestBreadcrumbControlHeader()
|
||||
{
|
||||
ContentSidePadding = 10;
|
||||
|
||||
TabControl.AddItem("tab1");
|
||||
TabControl.AddItem("tab2");
|
||||
TabControl.Current.Value = "tab2";
|
||||
|
@ -12,9 +12,26 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
public abstract class OverlayHeader : Container
|
||||
{
|
||||
public const int CONTENT_X_MARGIN = 50;
|
||||
private float contentSidePadding;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal padding of the header content.
|
||||
/// </summary>
|
||||
protected float ContentSidePadding
|
||||
{
|
||||
get => contentSidePadding;
|
||||
set
|
||||
{
|
||||
contentSidePadding = value;
|
||||
content.Padding = new MarginPadding
|
||||
{
|
||||
Horizontal = value
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Box titleBackground;
|
||||
private readonly Container content;
|
||||
|
||||
protected readonly FillFlowContainer HeaderInfo;
|
||||
|
||||
@ -50,14 +67,10 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
new Container
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Horizontal = CONTENT_X_MARGIN,
|
||||
},
|
||||
Children = new[]
|
||||
{
|
||||
CreateTitle().With(title =>
|
||||
@ -79,6 +92,8 @@ namespace osu.Game.Overlays
|
||||
CreateContent()
|
||||
}
|
||||
});
|
||||
|
||||
ContentSidePadding = 70;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -22,6 +22,7 @@ namespace osu.Game.Overlays
|
||||
protected OsuTabControl<T> TabControl;
|
||||
|
||||
private readonly Box controlBackground;
|
||||
private readonly Container tabControlContainer;
|
||||
private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
|
||||
|
||||
public Bindable<T> Current
|
||||
@ -30,6 +31,16 @@ namespace osu.Game.Overlays
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
protected new float ContentSidePadding
|
||||
{
|
||||
get => base.ContentSidePadding;
|
||||
set
|
||||
{
|
||||
base.ContentSidePadding = value;
|
||||
tabControlContainer.Padding = new MarginPadding { Horizontal = value };
|
||||
}
|
||||
}
|
||||
|
||||
protected TabControlOverlayHeader()
|
||||
{
|
||||
HeaderInfo.Add(new Container
|
||||
@ -42,11 +53,16 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
TabControl = CreateTabControl().With(control =>
|
||||
tabControlContainer = new Container
|
||||
{
|
||||
control.Margin = new MarginPadding { Left = CONTENT_X_MARGIN };
|
||||
control.Current = Current;
|
||||
})
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Horizontal = ContentSidePadding },
|
||||
Child = TabControl = CreateTabControl().With(control =>
|
||||
{
|
||||
control.Current = Current;
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user