diff --git a/osu.Game/Graphics/UserInterface/LoadingButton.cs b/osu.Game/Graphics/UserInterface/LoadingButton.cs index c177431c78..49ec18ce8e 100644 --- a/osu.Game/Graphics/UserInterface/LoadingButton.cs +++ b/osu.Game/Graphics/UserInterface/LoadingButton.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Game.Graphics.Containers; using osuTK; @@ -11,8 +10,6 @@ namespace osu.Game.Graphics.UserInterface { public abstract class LoadingButton : OsuHoverContainer { - private const float fade_duration = 200; - private bool isLoading; public bool IsLoading @@ -27,14 +24,12 @@ namespace osu.Game.Graphics.UserInterface if (value) { loading.Show(); - text.FadeOut(fade_duration, Easing.OutQuint); - OnLoadingStart(); + OnLoadStarted(); } else { loading.Hide(); - text.FadeIn(fade_duration, Easing.OutQuint); - OnLoadingFinished(); + OnLoadFinished(); } } } @@ -46,17 +41,12 @@ namespace osu.Game.Graphics.UserInterface } private readonly LoadingAnimation loading; - private readonly Drawable text; protected LoadingButton() { - Container content; - - Child = content = CreateContent(); - - content.AddRange(new[] + AddRange(new[] { - text = CreateText(), + CreateContent(), loading = new LoadingAnimation { Anchor = Anchor.Centre, @@ -82,16 +72,14 @@ namespace osu.Game.Graphics.UserInterface } } - protected virtual void OnLoadingStart() + protected virtual void OnLoadStarted() { } - protected virtual void OnLoadingFinished() + protected virtual void OnLoadFinished() { } - protected abstract Container CreateContent(); - - protected abstract Drawable CreateText(); + protected abstract Drawable CreateContent(); } } diff --git a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs index 407e102ca5..4931a6aed6 100644 --- a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs +++ b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs @@ -14,6 +14,8 @@ namespace osu.Game.Graphics.UserInterface { public class ShowMoreButton : LoadingButton { + private const int duration = 200; + private Color4 chevronIconColour; protected Color4 ChevronIconColour @@ -34,43 +36,50 @@ namespace osu.Game.Graphics.UserInterface private ChevronIcon rightChevron; private SpriteText text; private Box background; + private FillFlowContainer textContainer; public ShowMoreButton() { AutoSizeAxes = Axes.Both; } - protected override Container CreateContent() => new CircularContainer + protected override Drawable CreateContent() => new CircularContainer { Masking = true, Size = new Vector2(140, 30), - Child = background = new Box - { - RelativeSizeAxes = Axes.Both, - } - }; - - protected override Drawable CreateText() => new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(7), Children = new Drawable[] { - leftChevron = new ChevronIcon(), - text = new OsuSpriteText + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + textContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = "show more".ToUpper(), - }, - rightChevron = new ChevronIcon(), + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(7), + Children = new Drawable[] + { + leftChevron = new ChevronIcon(), + text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = "show more".ToUpper(), + }, + rightChevron = new ChevronIcon(), + } + } } }; + protected override void OnLoadStarted() => textContainer.FadeOut(duration, Easing.OutQuint); + + protected override void OnLoadFinished() => textContainer.FadeIn(duration, Easing.OutQuint); + private class ChevronIcon : SpriteIcon { private const int icon_size = 8; diff --git a/osu.Game/Overlays/Comments/VotePill.cs b/osu.Game/Overlays/Comments/VotePill.cs index 532fd8d905..e8d9013fd9 100644 --- a/osu.Game/Overlays/Comments/VotePill.cs +++ b/osu.Game/Overlays/Comments/VotePill.cs @@ -24,6 +24,8 @@ namespace osu.Game.Overlays.Comments { public class VotePill : LoadingButton, IHasAccentColour { + private const int duration = 200; + public Color4 AccentColour { get; set; } protected override IEnumerable EffectTargets => null; @@ -84,7 +86,7 @@ namespace osu.Game.Overlays.Comments IsLoading = false; } - protected override Container CreateContent() => new Container + protected override Drawable CreateContent() => new Container { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, @@ -116,22 +118,27 @@ namespace osu.Game.Overlays.Comments Margin = new MarginPadding { Right = 3 }, Alpha = 0, }, + votesCounter = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Margin = new MarginPadding { Horizontal = 10 }, + Font = OsuFont.GetFont(size: 14), + AlwaysPresent = true, + } }, }; - protected override Drawable CreateText() => votesCounter = new OsuSpriteText + protected override void OnLoadStarted() { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Margin = new MarginPadding { Horizontal = 10 }, - Font = OsuFont.GetFont(size: 14), - AlwaysPresent = true, - }; + votesCounter.FadeOut(duration, Easing.OutQuint); + updateDisplay(); + } - protected override void OnLoadingStart() => updateDisplay(); - - protected override void OnLoadingFinished() + protected override void OnLoadFinished() { + votesCounter.FadeIn(duration, Easing.OutQuint); + if (IsHovered) onHoverAction(); }