Update ScreenTitle with the new design

This commit is contained in:
Andrei Zavatski
2019-12-25 21:56:43 +03:00
parent 19ce3eba28
commit 3e34155114
4 changed files with 41 additions and 54 deletions

View File

@ -4,6 +4,7 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
@ -13,15 +14,12 @@ namespace osu.Game.Graphics.UserInterface
{ {
public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour public abstract class ScreenTitle : CompositeDrawable, IHasAccentColour
{ {
public const float ICON_WIDTH = ICON_SIZE + icon_spacing; public const float ICON_SIZE = 30;
private const int text_offset = 2;
public const float ICON_SIZE = 25;
private SpriteIcon iconSprite; private SpriteIcon iconSprite;
private readonly OsuSpriteText titleText, pageText; private readonly OsuSpriteText titleText, pageText;
private const float icon_spacing = 10;
protected IconUsage Icon protected IconUsage Icon
{ {
set set
@ -63,26 +61,40 @@ namespace osu.Game.Graphics.UserInterface
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Spacing = new Vector2(icon_spacing, 0), Spacing = new Vector2(6, 0),
Direction = FillDirection.Horizontal,
Children = new[] Children = new[]
{ {
CreateIcon(), CreateIcon().With(t =>
new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, t.Anchor = Anchor.Centre;
Direction = FillDirection.Horizontal, t.Origin = Anchor.Centre;
Spacing = new Vector2(6, 0), }),
Children = new[] titleText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
Margin = new MarginPadding { Bottom = text_offset }
},
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
Size = new Vector2(4),
Child = new Box
{ {
titleText = new OsuSpriteText RelativeSizeAxes = Axes.Both,
{ Colour = Color4.Gray,
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
},
pageText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
}
} }
},
pageText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 20),
Margin = new MarginPadding { Bottom = text_offset }
} }
} }
}, },

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osuTK; using osuTK;
@ -16,8 +15,6 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
public class ScreenTitleTextureIcon : CompositeDrawable public class ScreenTitleTextureIcon : CompositeDrawable
{ {
private const float circle_allowance = 0.8f;
private readonly string textureName; private readonly string textureName;
public ScreenTitleTextureIcon(string textureName) public ScreenTitleTextureIcon(string textureName)
@ -26,38 +23,16 @@ namespace osu.Game.Graphics.UserInterface
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures, OsuColour colours) private void load(TextureStore textures)
{ {
Size = new Vector2(ScreenTitle.ICON_SIZE / circle_allowance); Size = new Vector2(ScreenTitle.ICON_SIZE);
InternalChildren = new Drawable[] InternalChild = new Sprite
{ {
new CircularContainer RelativeSizeAxes = Axes.Both,
{ Texture = textures.Get(textureName),
Masking = true, Anchor = Anchor.Centre,
BorderColour = colours.Violet, Origin = Anchor.Centre,
BorderThickness = 3,
MaskingSmoothness = 1,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(textureName),
Size = new Vector2(circle_allowance),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Violet,
Alpha = 0,
AlwaysPresent = true,
},
}
},
}; };
} }
} }

View File

@ -39,7 +39,7 @@ namespace osu.Game.Overlays
Depth = -float.MaxValue, Depth = -float.MaxValue,
Children = new Drawable[] Children = new Drawable[]
{ {
CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH), CreateTitle().With(t => t.X = -ScreenTitle.ICON_SIZE),
TabControl = new OverlayHeaderTabControl TabControl = new OverlayHeaderTabControl
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,

View File

@ -42,7 +42,7 @@ namespace osu.Game.Screens.Multi
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
X = -ScreenTitle.ICON_WIDTH, X = -ScreenTitle.ICON_SIZE,
}, },
breadcrumbs = new HeaderBreadcrumbControl(stack) breadcrumbs = new HeaderBreadcrumbControl(stack)
{ {