From 140c74cd2afdcba4ddeb8505cb74817231155706 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 16:01:16 +0800 Subject: [PATCH] Use PageTabControl. --- .../Graphics/UserInterface/PageTabControl.cs | 8 +++--- osu.Game/Users/UserProfile.cs | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/PageTabControl.cs b/osu.Game/Graphics/UserInterface/PageTabControl.cs index 8bf455b099..e17281cdc4 100644 --- a/osu.Game/Graphics/UserInterface/PageTabControl.cs +++ b/osu.Game/Graphics/UserInterface/PageTabControl.cs @@ -23,12 +23,14 @@ namespace osu.Game.Graphics.UserInterface Height = 30; } - private class PageTabItem : TabItem + public class PageTabItem : TabItem { private const float transition_duration = 100; private readonly Box box; + protected readonly SpriteText Text; + public override bool Active { get { return base.Active; } @@ -51,12 +53,12 @@ namespace osu.Game.Graphics.UserInterface Children = new Drawable[] { - new OsuSpriteText + Text = new OsuSpriteText { Margin = new MarginPadding { Top = 8, Bottom = 8 }, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Text = (value as Enum).GetDescription() ?? value.ToString(), + Text = (value as Enum)?.GetDescription() ?? value.ToString(), TextSize = 14, Font = @"Exo2.0-Bold", }, diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 3c567e9089..6bf46e5725 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; @@ -83,31 +84,41 @@ namespace osu.Game.Users }; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private class ProfileTabControl : PageTabControl { - tabs.AccentColour = colours.Yellow; - } + private readonly Box bottom; - private class ProfileTabControl : OsuTabControl - { public ProfileTabControl() { TabContainer.RelativeSizeAxes &= ~Axes.X; TabContainer.AutoSizeAxes |= Axes.X; TabContainer.Anchor |= Anchor.x1; TabContainer.Origin |= Anchor.x1; + Add(bottom = new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + EdgeSmoothness = new Vector2(1) + }); } protected override TabItem CreateTabItem(ProfileSection value) => new ProfileTabItem(value); - private class ProfileTabItem : OsuTabItem + private class ProfileTabItem : PageTabItem { public ProfileTabItem(ProfileSection value) : base(value) { Text.Text = value.Title; } } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + bottom.Colour = colours.Yellow; + } } } }