mirror of
https://github.com/ppy/osu
synced 2025-01-05 21:59:46 +00:00
Split value change callbacks out to separate methods
This commit is contained in:
parent
555e3e2db3
commit
7befcf74ff
@ -153,28 +153,30 @@ namespace osu.Game.Overlays.News.Sidebar
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
IsOpen.BindValueChanged(open =>
|
||||
{
|
||||
ClearTransforms(true);
|
||||
|
||||
if (open.NewValue)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
content.FadeIn(animation_duration, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoSizeAxes = Axes.None;
|
||||
this.ResizeHeightTo(0, animation_duration, Easing.OutQuint);
|
||||
|
||||
content.FadeOut(animation_duration, Easing.OutQuint);
|
||||
}
|
||||
}, true);
|
||||
IsOpen.BindValueChanged(_ => updateState(), true);
|
||||
|
||||
// First state change should be instant.
|
||||
FinishTransforms(true);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
ClearTransforms(true);
|
||||
|
||||
if (IsOpen.Value)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
content.FadeIn(animation_duration, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoSizeAxes = Axes.None;
|
||||
this.ResizeHeightTo(0, animation_duration, Easing.OutQuint);
|
||||
|
||||
content.FadeOut(animation_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private bool shouldUpdateAutosize = true;
|
||||
|
||||
// Workaround to allow the dropdown to be opened immediately since FinishTransforms doesn't work for AutosizeDuration.
|
||||
|
@ -56,23 +56,25 @@ namespace osu.Game.Overlays.News.Sidebar
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
metadata.BindValueChanged(m =>
|
||||
metadata.BindValueChanged(_ => recreateDrawables(), true);
|
||||
}
|
||||
|
||||
private void recreateDrawables()
|
||||
{
|
||||
yearsFlow.Clear();
|
||||
|
||||
if (metadata.Value == null)
|
||||
{
|
||||
yearsFlow.Clear();
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.NewValue == null)
|
||||
{
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
var currentYear = metadata.Value.CurrentYear;
|
||||
|
||||
var currentYear = m.NewValue.CurrentYear;
|
||||
foreach (var y in metadata.Value.Years)
|
||||
yearsFlow.Add(new YearButton(y, y == currentYear));
|
||||
|
||||
foreach (var y in m.NewValue.Years)
|
||||
yearsFlow.Add(new YearButton(y, y == currentYear));
|
||||
|
||||
Show();
|
||||
}, true);
|
||||
Show();
|
||||
}
|
||||
|
||||
public class YearButton : OsuHoverContainer
|
||||
|
Loading…
Reference in New Issue
Block a user