1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 11:42:55 +08:00

Merge pull request #17823 from peppy/settings-filter-fixes

Fix incorrect settings state if searching too quickly (during load process)
This commit is contained in:
Dan Balasescu 2022-04-22 16:38:41 +09:00 committed by GitHub
commit b1cf917b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 19 deletions

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections; using osu.Game.Overlays.Settings.Sections;
using osu.Game.Overlays.Settings.Sections.Input; using osu.Game.Overlays.Settings.Sections.Input;
using osuTK.Input; using osuTK.Input;
@ -34,6 +35,29 @@ namespace osu.Game.Tests.Visual.Settings
}); });
} }
[Test]
public void TestQuickFiltering()
{
AddStep("set filter", () =>
{
settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling";
});
AddUntilStep("wait for items to load", () => settings.SectionsContainer.ChildrenOfType<IFilterable>().Any());
AddAssert("ensure all items match filter", () => settings.SectionsContainer
.ChildrenOfType<SettingsSection>().Where(f => f.IsPresent)
.All(section =>
section.Children.Where(f => f.IsPresent)
.OfType<ISettingsItem>()
.OfType<IFilterable>()
.Where(f => !(f is IHasFilterableChildren))
.All(f => f.FilterTerms.Any(t => t.Contains("scaling")))
));
AddAssert("ensure section is current", () => settings.CurrentSection.Value is GraphicsSection);
}
[Test] [Test]
public void ToggleVisibility() public void ToggleVisibility()
{ {

View File

@ -195,11 +195,8 @@ namespace osu.Game.Graphics.Containers
protected void InvalidateScrollPosition() protected void InvalidateScrollPosition()
{ {
Schedule(() => lastKnownScroll = null;
{ lastClickedSection = null;
lastKnownScroll = null;
lastClickedSection = null;
});
} }
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()

View File

@ -100,10 +100,9 @@ namespace osu.Game.Overlays.Settings
public IEnumerable<string> Keywords { get; set; } public IEnumerable<string> Keywords { get; set; }
public bool MatchingFilter public override bool IsPresent => base.IsPresent && MatchingFilter;
{
set => Alpha = value ? 1 : 0; public bool MatchingFilter { get; set; } = true;
}
public bool FilteringActive { get; set; } public bool FilteringActive { get; set; }

View File

@ -21,6 +21,8 @@ namespace osu.Game.Overlays.Settings
protected FillFlowContainer FlowContent; protected FillFlowContainer FlowContent;
protected override Container<Drawable> Content => FlowContent; protected override Container<Drawable> Content => FlowContent;
public override bool IsPresent => base.IsPresent && MatchingFilter;
private IBindable<SettingsSection> selectedSection; private IBindable<SettingsSection> selectedSection;
private Box dim; private Box dim;
@ -38,10 +40,7 @@ namespace osu.Game.Overlays.Settings
private const int header_size = 24; private const int header_size = 24;
private const int border_size = 4; private const int border_size = 4;
public bool MatchingFilter public bool MatchingFilter { get; set; } = true;
{
set => this.FadeTo(value ? 1 : 0);
}
public bool FilteringActive { get; set; } public bool FilteringActive { get; set; }

View File

@ -163,6 +163,7 @@ namespace osu.Game.Overlays
Sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint); Sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint); this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
searchTextBox.TakeFocus();
searchTextBox.HoldFocus = true; searchTextBox.HoldFocus = true;
} }
@ -213,7 +214,6 @@ namespace osu.Game.Overlays
loading.Hide(); loading.Hide();
searchTextBox.Current.BindValueChanged(term => SectionsContainer.SearchTerm = term.NewValue, true); searchTextBox.Current.BindValueChanged(term => SectionsContainer.SearchTerm = term.NewValue, true);
searchTextBox.TakeFocus();
loadSidebarButtons(); loadSidebarButtons();
}); });
@ -284,11 +284,7 @@ namespace osu.Game.Overlays
public string SearchTerm public string SearchTerm
{ {
get => SearchContainer.SearchTerm; get => SearchContainer.SearchTerm;
set set => SearchContainer.SearchTerm = value;
{
SearchContainer.SearchTerm = value;
InvalidateScrollPosition();
}
} }
protected override FlowContainer<SettingsSection> CreateScrollContentContainer() protected override FlowContainer<SettingsSection> CreateScrollContentContainer()
@ -307,6 +303,8 @@ namespace osu.Game.Overlays
Colour = colourProvider.Background4, Colour = colourProvider.Background4,
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}; };
SearchContainer.FilterCompleted += InvalidateScrollPosition;
} }
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()