From a1c91af0956fb710ad313b61243ead16e3250bf0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 26 Dec 2019 22:09:06 +0300 Subject: [PATCH] Update layout of every overlay using OverlayHeader --- .../Overlays/Changelog/ChangelogHeader.cs | 2 + osu.Game/Overlays/News/NewsHeader.cs | 7 +- osu.Game/Overlays/OverlayHeader.cs | 109 ++++++++++++------ osu.Game/Overlays/Profile/ProfileHeader.cs | 5 + 4 files changed, 84 insertions(+), 39 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index c6fedc0032..0cddeabdaa 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -47,6 +47,8 @@ namespace osu.Game.Overlays.Changelog private void load(OsuColour colours) { TabControl.AccentColour = colours.Violet; + TitleBackgroundColour = colours.GreyVioletDarker; + ControlBackgroundColour = colours.GreyVioletDark; } private ChangelogHeaderTitle title; diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index 6e17303a9d..e3cf58ed0a 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; @@ -37,9 +36,11 @@ namespace osu.Game.Overlays.News } [BackgroundDependencyLoader] - private void load(OsuColour colour) + private void load(OsuColour colours) { - TabControl.AccentColour = colour.Violet; + TabControl.AccentColour = colours.Violet; + TitleBackgroundColour = colours.GreyVioletDarker; + ControlBackgroundColour = colours.GreyVioletDark; } private void showPost(ValueChangedEvent e) diff --git a/osu.Game/Overlays/OverlayHeader.cs b/osu.Game/Overlays/OverlayHeader.cs index ed27bf7048..47d7a30b0b 100644 --- a/osu.Game/Overlays/OverlayHeader.cs +++ b/osu.Game/Overlays/OverlayHeader.cs @@ -3,7 +3,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.UserInterface; +using osuTK.Graphics; namespace osu.Game.Overlays { @@ -11,58 +13,93 @@ namespace osu.Game.Overlays { protected readonly OverlayHeaderTabControl TabControl; - private const float cover_height = 150; - private const float cover_info_height = 75; + private readonly Box titleBackground; + private readonly Box controlBackground; + private readonly Container background; + + protected Color4 TitleBackgroundColour + { + set => titleBackground.Colour = value; + } + + protected Color4 ControlBackgroundColour + { + set => controlBackground.Colour = value; + } + + protected float BackgroundHeight + { + set => background.Height = value; + } protected OverlayHeader() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - AddRange(new[] + FillFlowContainer flow; + + Add(flow = new FillFlowContainer { - new Container + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] { - RelativeSizeAxes = Axes.X, - Height = cover_height, - Masking = true, - Child = CreateBackground() - }, - new Container - { - Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, - Y = cover_height, - Height = cover_info_height, - RelativeSizeAxes = Axes.X, - Anchor = Anchor.TopLeft, - Origin = Anchor.BottomLeft, - Depth = -float.MaxValue, - Children = new Drawable[] + background = new Container { - CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH), - TabControl = new OverlayHeaderTabControl + RelativeSizeAxes = Axes.X, + Height = 80, + Masking = true, + Child = CreateBackground() + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = cover_info_height - 30, - Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN }, - Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN } + titleBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Gray, + }, + CreateTitle().With(title => + { + title.Margin = new MarginPadding + { + Vertical = 5, + Left = UserProfileOverlay.CONTENT_X_MARGIN + }; + }) + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + controlBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Gray, + }, + TabControl = new OverlayHeaderTabControl + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 30, + Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, + } } } } }); if (CreateContent != null) - { - Add(new Container - { - Margin = new MarginPadding { Top = cover_height }, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Child = CreateContent - }); - }; + flow.Add(CreateContent); } protected abstract Drawable CreateBackground(); diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 454ac72a7b..f9c7062c69 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Profile public ProfileHeader() { + BackgroundHeight = 150; + User.ValueChanged += e => updateDisplay(e.NewValue); TabControl.AddItem("Info"); @@ -38,6 +40,8 @@ namespace osu.Game.Overlays.Profile private void load(OsuColour colours) { TabControl.AccentColour = colours.Seafoam; + TitleBackgroundColour = colours.GreySeafoamDarker; + ControlBackgroundColour = colours.GreySeafoam; } protected override Drawable CreateBackground() => @@ -103,6 +107,7 @@ namespace osu.Game.Overlays.Profile { Title = "Player"; Section = "Info"; + X = -ICON_WIDTH; } [BackgroundDependencyLoader]