mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 19:04:06 +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.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
@ -35,17 +36,22 @@ namespace osu.Game.Overlays
|
|||||||
protected OverlayTabControl()
|
protected OverlayTabControl()
|
||||||
{
|
{
|
||||||
TabContainer.Masking = false;
|
TabContainer.Masking = false;
|
||||||
TabContainer.Spacing = new Vector2(15, 0);
|
TabContainer.Spacing = new Vector2(20, 0);
|
||||||
|
|
||||||
AddInternal(bar = new Box
|
AddInternal(bar = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 2,
|
|
||||||
Anchor = Anchor.BottomLeft,
|
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 Dropdown<T> CreateDropdown() => null;
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new OverlayTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new OverlayTabItem(value);
|
||||||
@ -90,7 +96,7 @@ namespace osu.Game.Overlays
|
|||||||
Bar = new ExpandingBar
|
Bar = new ExpandingBar
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
ExpandedSize = 7.5f,
|
ExpandedSize = 5f,
|
||||||
CollapsedSize = 0
|
CollapsedSize = 0
|
||||||
},
|
},
|
||||||
new HoverClickSounds()
|
new HoverClickSounds()
|
||||||
@ -119,6 +125,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
HoverAction();
|
HoverAction();
|
||||||
Text.Font = Text.Font.With(weight: FontWeight.Bold);
|
Text.Font = Text.Font.With(weight: FontWeight.Bold);
|
||||||
|
Text.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDeactivated()
|
protected override void OnDeactivated()
|
||||||
@ -135,11 +142,7 @@ namespace osu.Game.Overlays
|
|||||||
OnDeactivated();
|
OnDeactivated();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void HoverAction()
|
protected virtual void HoverAction() => Bar.Expand();
|
||||||
{
|
|
||||||
Bar.Expand();
|
|
||||||
Text.FadeColour(Color4.White, 120, Easing.InQuad);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void UnhoverAction()
|
protected virtual void UnhoverAction()
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
protected OsuTabControl<T> TabControl;
|
protected OsuTabControl<T> TabControl;
|
||||||
|
|
||||||
|
private readonly Box controlBackground;
|
||||||
private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
|
private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
|
||||||
|
|
||||||
public Bindable<T> Current
|
public Bindable<T> Current
|
||||||
@ -30,8 +31,6 @@ namespace osu.Game.Overlays
|
|||||||
set => current.Current = value;
|
set => current.Current = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Box controlBackground;
|
|
||||||
|
|
||||||
protected TabControlOverlayHeader()
|
protected TabControlOverlayHeader()
|
||||||
{
|
{
|
||||||
HeaderInfo.Add(new Container
|
HeaderInfo.Add(new Container
|
||||||
@ -56,7 +55,6 @@ namespace osu.Game.Overlays
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
TabControl.AccentColour = colourProvider.Highlight1;
|
|
||||||
controlBackground.Colour = colourProvider.Dark4;
|
controlBackground.Colour = colourProvider.Dark4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +63,16 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public class OverlayHeaderTabControl : OverlayTabControl<T>
|
public class OverlayHeaderTabControl : OverlayTabControl<T>
|
||||||
{
|
{
|
||||||
|
private const float bar_height = 1;
|
||||||
|
|
||||||
public OverlayHeaderTabControl()
|
public OverlayHeaderTabControl()
|
||||||
{
|
{
|
||||||
BarHeight = 1;
|
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
Anchor = Anchor.BottomLeft;
|
Anchor = Anchor.BottomLeft;
|
||||||
Origin = Anchor.BottomLeft;
|
Origin = Anchor.BottomLeft;
|
||||||
Height = 35;
|
Height = 47;
|
||||||
|
BarHeight = bar_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new OverlayHeaderTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new OverlayHeaderTabItem(value);
|
||||||
@ -82,7 +82,6 @@ namespace osu.Game.Overlays
|
|||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(5, 0),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private class OverlayHeaderTabItem : OverlayTabItem
|
private class OverlayHeaderTabItem : OverlayTabItem
|
||||||
@ -92,7 +91,8 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Text.Text = value.ToString().ToLower();
|
Text.Text = value.ToString().ToLower();
|
||||||
Text.Font = OsuFont.GetFont(size: 14);
|
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