This commit is contained in:
HoutarouOreki
2018-07-18 15:17:20 +02:00
parent 6baa761b9c
commit 837747e35f
6 changed files with 56 additions and 28 deletions

View File

@ -133,7 +133,9 @@ namespace osu.Game.Overlays.Changelog
{
Top = 10,
Left = 7,
Right = 9,
// + chevron size, and account for gained space on left by
// listing's font draw width being smaller
Right = 18,
Bottom = 15,
},
Children = new Drawable[]

View File

@ -37,18 +37,10 @@ namespace osu.Game.Overlays.Changelog.Header
public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic)
{
if (!string.IsNullOrEmpty(displayText))
{
text.Text = displayText;
}
lineBadge.IsCollapsed = false;
if (!string.IsNullOrEmpty(displayText)) text.Text = displayText;
text.MoveToY(0, duration, easing)
.FadeIn(duration, easing)
.Finally(d => {
// waiting until text is drawn to use its DrawWidth
UpdateBadgeWidth();
lineBadge.IsCollapsed = false;
});
.FadeIn(duration, easing);
}
/// <param name="duration">
@ -61,19 +53,15 @@ namespace osu.Game.Overlays.Changelog.Header
.FadeOut(duration, easing)
.Then()
.MoveToY(0, duration, easing)
.FadeIn(duration, easing)
.OnComplete(dd => {
UpdateBadgeWidth();
lineBadge.IsCollapsed = false;
});
.FadeIn(duration, easing);
// since using .finally/.oncomplete after first fadeout made the badge
// not hide sometimes in visual tests(because FinishTransforms()/CancelTransforms()
// didn't apply to transforms that come after the .finally), I'm using a scheduler here
Scheduler.AddDelayed(() =>
{
//lineBadge.ResizeWidthTo(0); // resizes when not visible
if (!string.IsNullOrEmpty(displayText)) text.Text = displayText;
lineBadge.IsCollapsed = false;
}, duration);
}
@ -93,13 +81,13 @@ namespace osu.Game.Overlays.Changelog.Header
{
Top = 5,
Bottom = 15,
Left = 10,
Right = 10,
}
},
lineBadge = new LineBadge(startCollapsed)
{
Width = 1,
Colour = badgeColour,
RelativeSizeAxes = Axes.X,
}
};
}
@ -115,7 +103,5 @@ namespace osu.Game.Overlays.Changelog.Header
lineBadge.IsCollapsed = false;
text.Font = "Exo2.0-Bold";
}
public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth);
}
}

View File

@ -19,6 +19,11 @@ namespace osu.Game.Overlays.Changelog.Header
text.Anchor = Anchor.TopCentre;
text.Origin = Anchor.TopCentre;
// I'm using this for constant badge width here, so that the whole
// thing doesn't jump left/right when listing's size changes
// due to different font weight (and thus width)
lineBadge.RelativeSizeAxes = Axes.None;
// this doesn't work without the scheduler
// (because the text isn't yet fully drawn when it's loaded?)
text.OnLoadComplete = d => Scheduler.Add(UpdateBadgeWidth);
@ -57,5 +62,7 @@ namespace osu.Game.Overlays.Changelog.Header
if (lineBadge.IsCollapsed) lineBadge.ResizeHeightTo(1, lineBadge.TransitionDuration);
base.OnHoverLost(state);
}
public void UpdateBadgeWidth() => lineBadge.ResizeWidthTo(text.DrawWidth);
}
}

View File

@ -12,7 +12,6 @@ namespace osu.Game.Overlays.Changelog.Header
public TextBadgePairRelease(ColourInfo badgeColour, string displayText) : base(badgeColour, displayText)
{
this.listingBadge = listingBadge;
text.Font = "Exo2.0-Bold";
text.Y = 20;
text.Alpha = 0;