From fe9e53e383e5f2d35e382daffad3f5ba1b253a53 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Thu, 30 May 2019 23:07:04 +0300 Subject: [PATCH] Add a testcase --- .../Visual/Online/TestSceneShowMoreButton.cs | 31 +++++++++ .../Graphics/Containers/OsuHoverContainer.cs | 6 +- .../Profile/Sections/PaginatedContainer.cs | 2 + .../Profile/Sections/ShowMoreButton.cs | 68 +++++++++---------- 4 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs new file mode 100644 index 0000000000..8289e4a09c --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs @@ -0,0 +1,31 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Overlays.Profile.Sections; +using System; +using System.Collections.Generic; +using osu.Framework.Graphics; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneShowMoreButton : OsuTestScene + { + private readonly ShowMoreButton button; + + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ShowMoreButton), + }; + + public TestSceneShowMoreButton() + { + Add(button = new ShowMoreButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + + AddStep("switch loading state", () => button.IsLoading = !button.IsLoading); + } + } +} diff --git a/osu.Game/Graphics/Containers/OsuHoverContainer.cs b/osu.Game/Graphics/Containers/OsuHoverContainer.cs index c4f85926ee..eb2d926424 100644 --- a/osu.Game/Graphics/Containers/OsuHoverContainer.cs +++ b/osu.Game/Graphics/Containers/OsuHoverContainer.cs @@ -24,7 +24,8 @@ namespace osu.Game.Graphics.Containers { Enabled.ValueChanged += e => { - if (!e.NewValue) unhover(); + if (!e.NewValue) + unhover(); }; } @@ -49,7 +50,8 @@ namespace osu.Game.Graphics.Containers private void unhover() { - if (!isHovered) return; + if (!isHovered) + return; isHovered = false; EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint)); diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 11803b0dc1..8639acfc94 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -54,6 +54,8 @@ namespace osu.Game.Overlays.Profile.Sections }, MoreButton = new ShowMoreButton { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Alpha = 0, Margin = new MarginPadding { Top = 10 }, Action = ShowMore, diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs index 5979c971d1..31c73aaa96 100644 --- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs +++ b/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs @@ -51,49 +51,47 @@ namespace osu.Game.Overlays.Profile.Sections public ShowMoreButton() { - Anchor = Anchor.TopCentre; - Origin = Anchor.TopCentre; AutoSizeAxes = Axes.Both; Children = new Drawable[] { - new CircularContainer + new CircularContainer + { + Masking = true, + Size = new Vector2(140, 30), + Children = new Drawable[] { - Masking = true, - Size = new Vector2(140, 30), - Children = new Drawable[] + background = new Box { - background = new Box + RelativeSizeAxes = Axes.Both, + }, + content = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(7), + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - content = new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(7), - Children = new Drawable[] + new ChevronIcon(), + new OsuSpriteText { - new ChevronIcon(), - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = "show more".ToUpper(), - }, - new ChevronIcon(), - } - }, - loading = new LoadingAnimation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(12) - }, - } + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = "show more".ToUpper(), + }, + new ChevronIcon(), + } + }, + loading = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(12) + }, } + } }; }