mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Dim all but the current section
This commit is contained in:
parent
e87accafc8
commit
6637c64501
@ -4,9 +4,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -19,6 +21,10 @@ namespace osu.Game.Overlays.Settings
|
||||
protected FillFlowContainer FlowContent;
|
||||
protected override Container<Drawable> Content => FlowContent;
|
||||
|
||||
private IBindable<SettingsSection> selectedSection;
|
||||
|
||||
private Container content;
|
||||
|
||||
public abstract Drawable CreateIcon();
|
||||
public abstract LocalisableString Header { get; }
|
||||
|
||||
@ -36,6 +42,9 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public bool FilteringActive { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private SettingsPanel settingsPanel { get; set; }
|
||||
|
||||
protected SettingsSection()
|
||||
{
|
||||
Margin = new MarginPadding { Top = margin };
|
||||
@ -65,7 +74,7 @@ namespace osu.Game.Overlays.Settings
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = border_size,
|
||||
},
|
||||
new Container
|
||||
content = new Container
|
||||
{
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
@ -91,6 +100,44 @@ namespace osu.Game.Overlays.Settings
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
selectedSection = settingsPanel.CurrentSection.GetBoundCopy();
|
||||
selectedSection.BindValueChanged(selected =>
|
||||
{
|
||||
if (selected.NewValue == this)
|
||||
content.FadeIn(500, Easing.OutQuint);
|
||||
else
|
||||
content.FadeTo(0.25f, 500, Easing.OutQuint);
|
||||
}, true);
|
||||
}
|
||||
|
||||
private bool isCurrentSection => selectedSection.Value == this;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (!isCurrentSection)
|
||||
content.FadeTo(0.6f, 500, Easing.OutQuint);
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
if (!isCurrentSection)
|
||||
content.FadeTo(0.25f, 500, Easing.OutQuint);
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (!isCurrentSection)
|
||||
settingsPanel.SectionsContainer.ScrollTo(this);
|
||||
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child)
|
||||
{
|
||||
return isCurrentSection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -21,6 +22,7 @@ using osu.Game.Overlays.Settings;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
[Cached]
|
||||
public abstract class SettingsPanel : OsuFocusedOverlayContainer
|
||||
{
|
||||
public const float CONTENT_MARGINS = 15;
|
||||
@ -46,7 +48,7 @@ namespace osu.Game.Overlays
|
||||
protected Sidebar Sidebar;
|
||||
private SidebarButton selectedSidebarButton;
|
||||
|
||||
protected SettingsSectionsContainer SectionsContainer;
|
||||
public SettingsSectionsContainer SectionsContainer { get; private set; }
|
||||
|
||||
private SeekLimitedSearchTextBox searchTextBox;
|
||||
|
||||
@ -65,6 +67,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
private Task sectionsLoadingTask;
|
||||
|
||||
public IBindable<SettingsSection> CurrentSection = new Bindable<SettingsSection>();
|
||||
|
||||
protected SettingsPanel(bool showSidebar)
|
||||
{
|
||||
this.showSidebar = showSidebar;
|
||||
@ -105,6 +109,7 @@ namespace osu.Game.Overlays
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ExpandableHeader = CreateHeader(),
|
||||
SelectedSection = { BindTarget = CurrentSection },
|
||||
FixedHeader = searchTextBox = new SeekLimitedSearchTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -238,8 +243,10 @@ namespace osu.Game.Overlays
|
||||
if (selectedSidebarButton != null)
|
||||
selectedSidebarButton.Selected = false;
|
||||
|
||||
selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section.NewValue);
|
||||
selectedSidebarButton.Selected = true;
|
||||
selectedSidebarButton = Sidebar.Children.FirstOrDefault(b => b.Section == section.NewValue);
|
||||
|
||||
if (selectedSidebarButton != null)
|
||||
selectedSidebarButton.Selected = true;
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user