mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 01:33:12 +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 Box selectionIndicator;
|
||||||
private readonly Container text;
|
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;
|
private SettingsSection section;
|
||||||
|
|
||||||
public SettingsSection Section
|
public SettingsSection Section
|
||||||
|
@ -135,54 +135,70 @@ namespace osu.Game.Overlays
|
|||||||
LoadComponentAsync(SectionsContainer, d =>
|
LoadComponentAsync(SectionsContainer, d =>
|
||||||
{
|
{
|
||||||
ContentContainer.Add(d);
|
ContentContainer.Add(d);
|
||||||
d.FadeInFromZero(500);
|
d.FadeInFromZero(750, Easing.OutQuint);
|
||||||
loading.Hide();
|
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.Current.BindValueChanged(term => SectionsContainer.SearchContainer.SearchTerm = term.NewValue, true);
|
||||||
searchTextBox.TakeFocus();
|
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);
|
foreach (var section in SectionsContainer)
|
||||||
|
|
||||||
if (Sidebar != null)
|
|
||||||
{
|
{
|
||||||
var button = new SidebarButton
|
yield return new SidebarButton
|
||||||
{
|
{
|
||||||
Section = section,
|
Section = section,
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
// may not be loaded yet.
|
if (!SectionsContainer.IsLoaded)
|
||||||
if (SectionsContainer == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SectionsContainer.ScrollTo(section);
|
SectionsContainer.ScrollTo(section);
|
||||||
Sidebar.State = ExpandedState.Contracted;
|
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 CreateHeader() => new Container();
|
||||||
|
|
||||||
protected virtual Drawable CreateFooter() => new Container();
|
protected virtual Drawable CreateFooter() => new Container();
|
||||||
|
Loading…
Reference in New Issue
Block a user