From 0fa02718786a0eefa063cce18e9e5351f509ab59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 4 May 2019 11:01:12 +0900 Subject: [PATCH] Add animation when collapsing or expanding the profile details section --- .../Profile/Header/CentreHeaderContainer.cs | 6 ++-- .../Profile/Header/DetailHeaderContainer.cs | 33 +++++++++++++++++-- osu.Game/Overlays/Profile/ProfileHeader.cs | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs index 0642ef94df..b441775393 100644 --- a/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/CentreHeaderContainer.cs @@ -134,9 +134,9 @@ namespace osu.Game.Overlays.Profile.Header DetailsVisible.BindValueChanged(visible => { - hiddenDetailContainer.Alpha = visible.NewValue ? 0 : 1; - expandedDetailContainer.Alpha = visible.NewValue ? 1 : 0; - }, true); + hiddenDetailContainer.FadeTo(visible.NewValue ? 0 : 1, 200, Easing.OutQuint); + expandedDetailContainer.FadeTo(visible.NewValue ? 1 : 0, 200, Easing.OutQuint); + }); User.BindValueChanged(user => updateDisplay(user.NewValue)); } diff --git a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs index 8fcf2711dd..de710c5fcd 100644 --- a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs @@ -26,14 +26,40 @@ namespace osu.Game.Overlays.Profile.Header private OverlinedInfoContainer ppInfo; private OverlinedInfoContainer detailGlobalRank; private OverlinedInfoContainer detailCountryRank; + private FillFlowContainer fillFlow; private RankGraph rankGraph; public readonly Bindable User = new Bindable(); + private bool expanded = true; + + public bool Expanded + { + set + { + if (expanded == value) return; + + expanded = value; + + if (fillFlow == null) return; + + fillFlow.ClearTransforms(); + + if (expanded) + fillFlow.AutoSizeAxes = Axes.Y; + else + { + fillFlow.AutoSizeAxes = Axes.None; + fillFlow.ResizeHeightTo(0, 200, Easing.OutQuint); + } + } + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { AutoSizeAxes = Axes.Y; + User.ValueChanged += e => updateDisplay(e.NewValue); InternalChildren = new Drawable[] @@ -43,10 +69,13 @@ namespace osu.Game.Overlays.Profile.Header RelativeSizeAxes = Axes.Both, Colour = colours.CommunityUserGrayGreenDarkest, }, - new FillFlowContainer + fillFlow = new FillFlowContainer { RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + AutoSizeAxes = expanded ? Axes.Y : Axes.None, + AutoSizeDuration = 200, + AutoSizeEasing = Easing.OutQuint, + Masking = true, Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 }, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 20), diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index f5233cf70c..2d8c47b11a 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -117,7 +117,7 @@ namespace osu.Game.Overlays.Profile infoTabControl.AddItem("Info"); infoTabControl.AddItem("Modding"); - centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Alpha = visible.NewValue ? 1 : 0, true); + centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true); User.ValueChanged += e => updateDisplay(e.NewValue); }