1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 02:13:22 +08:00

Tidy up ordering of SettingsToolboxGroup

This commit is contained in:
Dean Herbert 2022-05-06 19:39:09 +09:00
parent 59add66632
commit b432885e5f

View File

@ -117,32 +117,17 @@ namespace osu.Game.Overlays
}; };
} }
protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source) [BackgroundDependencyLoader]
private void load(OsuColour colours)
{ {
if (invalidation.HasFlagFast(Invalidation.DrawSize)) expandedColour = colours.Yellow;
headerTextVisibilityCache.Invalidate();
return base.OnInvalidate(invalidation, source);
}
protected override void Update()
{
base.Update();
if (!headerTextVisibilityCache.IsValid)
// These toolbox grouped may be contracted to only show icons.
// For now, let's hide the header to avoid text truncation weirdness in such cases.
headerText.FadeTo(headerText.DrawWidth < DrawWidth ? 1 : 0, 150, Easing.OutQuint);
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
Expanded.BindValueChanged(v => Expanded.BindValueChanged(updateExpandedState, true);
{
Scheduler.AddOnce(updateExpandedState);
}, true);
this.Delay(600).Schedule(updateFadeState); this.Delay(600).Schedule(updateFadeState);
} }
@ -159,15 +144,27 @@ namespace osu.Game.Overlays
base.OnHoverLost(e); base.OnHoverLost(e);
} }
[BackgroundDependencyLoader] protected override void Update()
private void load(OsuColour colours)
{ {
expandedColour = colours.Yellow; base.Update();
if (!headerTextVisibilityCache.IsValid)
// These toolbox grouped may be contracted to only show icons.
// For now, let's hide the header to avoid text truncation weirdness in such cases.
headerText.FadeTo(headerText.DrawWidth < DrawWidth ? 1 : 0, 150, Easing.OutQuint);
} }
private void updateExpandedState() protected override bool OnInvalidate(Invalidation invalidation, InvalidationSource source)
{ {
if (Expanded.Value) if (invalidation.HasFlagFast(Invalidation.DrawSize))
headerTextVisibilityCache.Invalidate();
return base.OnInvalidate(invalidation, source);
}
private void updateExpandedState(ValueChangedEvent<bool> expanded)
{
if (expanded.NewValue)
content.AutoSizeAxes = Axes.Y; content.AutoSizeAxes = Axes.Y;
else else
{ {
@ -175,7 +172,7 @@ namespace osu.Game.Overlays
content.ResizeHeightTo(0, transition_duration, Easing.OutQuint); content.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
} }
button.FadeColour(Expanded.Value ? expandedColour : Color4.White, 200, Easing.InOutQuint); button.FadeColour(expanded.NewValue ? expandedColour : Color4.White, 200, Easing.InOutQuint);
} }
private void updateFadeState() private void updateFadeState()