Skip to content

Commit

Permalink
Merge pull request #5772 from Cootz/add-search-method-for-search-cont…
Browse files Browse the repository at this point in the history
…ainer

Allow `SearchContainer` implementations to manually trigger a `Filter` operation
  • Loading branch information
peppy committed May 26, 2023
2 parents 0ec0f47 + 7e0ecb5 commit 9206408
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions osu.Framework/Graphics/Containers/SearchContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,30 @@ protected override void Update()
base.Update();

if (!filterValid.IsValid)
{
canBeShownBindables.Clear();
performFilter();
filterValid.Validate();
FilterCompleted?.Invoke();
}
Filter();
}

/// <summary>
/// Immediately filter <see cref="IFilterable"/> children based on the current <see cref="SearchTerm"/>.
/// </summary>
/// <remarks>
/// Filtering is done automatically after a change to <see cref="SearchTerm"/>, on new drawables being added, and on certain changes to
/// searchable children (like <see cref="IConditionalFilterable.CanBeShown"/> changing).
///
/// However, if <see cref="SearchContainer{T}"/> or any of its parents are hidden this will not be run.
/// If an implementation relies on filtering to become present / visible, this method can be used to force a filter.
///
/// Note that this will only run if the current filter is not in an already valid state.
/// </remarks>
protected void Filter()
{
if (filterValid.IsValid)
return;

canBeShownBindables.Clear();
performFilter();
filterValid.Validate();
FilterCompleted?.Invoke();
}

private void performFilter()
Expand Down

0 comments on commit 9206408

Please sign in to comment.