mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Update header tab control
This commit is contained in:
parent
e33055e2c4
commit
816418742e
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
@ -35,17 +36,22 @@ namespace osu.Game.Overlays
|
||||
protected OverlayTabControl()
|
||||
{
|
||||
TabContainer.Masking = false;
|
||||
TabContainer.Spacing = new Vector2(15, 0);
|
||||
TabContainer.Spacing = new Vector2(20, 0);
|
||||
|
||||
AddInternal(bar = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 2,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
Origin = Anchor.BottomLeft
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
AccentColour = colourProvider.Highlight1;
|
||||
}
|
||||
|
||||
protected override Dropdown<T> CreateDropdown() => null;
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OverlayTabItem(value);
|
||||
@ -90,7 +96,7 @@ namespace osu.Game.Overlays
|
||||
Bar = new ExpandingBar
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
ExpandedSize = 7.5f,
|
||||
ExpandedSize = 5f,
|
||||
CollapsedSize = 0
|
||||
},
|
||||
new HoverClickSounds()
|
||||
@ -119,6 +125,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
HoverAction();
|
||||
Text.Font = Text.Font.With(weight: FontWeight.Bold);
|
||||
Text.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated()
|
||||
@ -135,11 +142,7 @@ namespace osu.Game.Overlays
|
||||
OnDeactivated();
|
||||
}
|
||||
|
||||
protected virtual void HoverAction()
|
||||
{
|
||||
Bar.Expand();
|
||||
Text.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||
}
|
||||
protected virtual void HoverAction() => Bar.Expand();
|
||||
|
||||
protected virtual void UnhoverAction()
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
protected OsuTabControl<T> TabControl;
|
||||
|
||||
private readonly Box controlBackground;
|
||||
private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
|
||||
|
||||
public Bindable<T> Current
|
||||
@ -30,8 +31,6 @@ namespace osu.Game.Overlays
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private readonly Box controlBackground;
|
||||
|
||||
protected TabControlOverlayHeader()
|
||||
{
|
||||
HeaderInfo.Add(new Container
|
||||
@ -56,7 +55,6 @@ namespace osu.Game.Overlays
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
TabControl.AccentColour = colourProvider.Highlight1;
|
||||
controlBackground.Colour = colourProvider.Dark4;
|
||||
}
|
||||
|
||||
@ -65,14 +63,16 @@ namespace osu.Game.Overlays
|
||||
|
||||
public class OverlayHeaderTabControl : OverlayTabControl<T>
|
||||
{
|
||||
private const float bar_height = 1;
|
||||
|
||||
public OverlayHeaderTabControl()
|
||||
{
|
||||
BarHeight = 1;
|
||||
RelativeSizeAxes = Axes.None;
|
||||
AutoSizeAxes = Axes.X;
|
||||
Anchor = Anchor.BottomLeft;
|
||||
Origin = Anchor.BottomLeft;
|
||||
Height = 35;
|
||||
Height = 47;
|
||||
BarHeight = bar_height;
|
||||
}
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OverlayHeaderTabItem(value);
|
||||
@ -82,7 +82,6 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
};
|
||||
|
||||
private class OverlayHeaderTabItem : OverlayTabItem
|
||||
@ -92,7 +91,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
Text.Text = value.ToString().ToLower();
|
||||
Text.Font = OsuFont.GetFont(size: 14);
|
||||
Bar.ExpandedSize = 5;
|
||||
Text.Margin = new MarginPadding { Vertical = 16.5f }; // 15px padding + 1.5px line-height difference compensation
|
||||
Bar.Margin = new MarginPadding { Bottom = bar_height };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user