mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 16:23:16 +08:00
Fade in sidebar buttons after the load has completed
This commit is contained in:
parent
c6bd8520a7
commit
230c4eb247
@ -22,6 +22,9 @@ namespace osu.Game.Overlays.Settings
|
||||
private readonly Box selectionIndicator;
|
||||
private readonly Container text;
|
||||
|
||||
// always consider as part of flow, even when not visible (for the sake of the initial animation).
|
||||
public override bool IsPresent => true;
|
||||
|
||||
private SettingsSection section;
|
||||
|
||||
public SettingsSection Section
|
||||
|
@ -135,54 +135,70 @@ namespace osu.Game.Overlays
|
||||
LoadComponentAsync(SectionsContainer, d =>
|
||||
{
|
||||
ContentContainer.Add(d);
|
||||
d.FadeInFromZero(500);
|
||||
d.FadeInFromZero(750, Easing.OutQuint);
|
||||
loading.Hide();
|
||||
|
||||
if (Sidebar != null)
|
||||
{
|
||||
SectionsContainer.SelectedSection.ValueChanged += section =>
|
||||
{
|
||||
selectedSidebarButton.Selected = false;
|
||||
selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section.NewValue);
|
||||
selectedSidebarButton.Selected = true;
|
||||
};
|
||||
}
|
||||
|
||||
searchTextBox.Current.BindValueChanged(term => SectionsContainer.SearchContainer.SearchTerm = term.NewValue, true);
|
||||
searchTextBox.TakeFocus();
|
||||
|
||||
if (Sidebar == null)
|
||||
return;
|
||||
|
||||
LoadComponentsAsync(createSidebarButtons(), buttons =>
|
||||
{
|
||||
float delay = 0;
|
||||
|
||||
foreach (var button in buttons)
|
||||
{
|
||||
Sidebar.Add(button);
|
||||
|
||||
button.FadeOut()
|
||||
.Delay(delay)
|
||||
.FadeInFromZero(1000, Easing.OutQuint);
|
||||
|
||||
delay += 30;
|
||||
}
|
||||
|
||||
SectionsContainer.SelectedSection.BindValueChanged(section =>
|
||||
{
|
||||
if (selectedSidebarButton != null)
|
||||
selectedSidebarButton.Selected = false;
|
||||
|
||||
selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section.NewValue);
|
||||
selectedSidebarButton.Selected = true;
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected void AddSection(SettingsSection section)
|
||||
private IEnumerable<SidebarButton> createSidebarButtons()
|
||||
{
|
||||
SectionsContainer.Add(section);
|
||||
|
||||
if (Sidebar != null)
|
||||
foreach (var section in SectionsContainer)
|
||||
{
|
||||
var button = new SidebarButton
|
||||
yield return new SidebarButton
|
||||
{
|
||||
Section = section,
|
||||
Action = () =>
|
||||
{
|
||||
// may not be loaded yet.
|
||||
if (SectionsContainer == null)
|
||||
if (!SectionsContainer.IsLoaded)
|
||||
return;
|
||||
|
||||
SectionsContainer.ScrollTo(section);
|
||||
Sidebar.State = ExpandedState.Contracted;
|
||||
},
|
||||
};
|
||||
|
||||
Sidebar.Add(button);
|
||||
|
||||
if (selectedSidebarButton == null)
|
||||
{
|
||||
selectedSidebarButton = Sidebar.Children.First();
|
||||
selectedSidebarButton.Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddSection(SettingsSection section)
|
||||
{
|
||||
if (IsLoaded)
|
||||
// just to keep things simple. can be accommodated for if we ever need it.
|
||||
throw new InvalidOperationException("All sections must be added before the panel is loaded.");
|
||||
|
||||
SectionsContainer.Add(section);
|
||||
}
|
||||
|
||||
protected virtual Drawable CreateHeader() => new Container();
|
||||
|
||||
protected virtual Drawable CreateFooter() => new Container();
|
||||
|
Loading…
Reference in New Issue
Block a user