Fix ScrollToSelected being called in too many cases

This commit is contained in:
Dean Herbert 2017-12-16 16:44:42 +09:00
parent df7e795aa3
commit 59dbca2612

View File

@ -149,7 +149,7 @@ namespace osu.Game.Screens.Select
root.AddChild(newSet); root.AddChild(newSet);
applyActiveCriteria(false); applyActiveCriteria(false, false);
//check if we can/need to maintain our current selection. //check if we can/need to maintain our current selection.
if (hadSelection) if (hadSelection)
@ -276,7 +276,7 @@ namespace osu.Game.Screens.Select
public void FlushPendingFilterOperations() public void FlushPendingFilterOperations()
{ {
if (FilterTask?.Completed == false) if (FilterTask?.Completed == false)
applyActiveCriteria(false); applyActiveCriteria(false, false);
} }
public void Filter(FilterCriteria newCriteria, bool debounce = true) public void Filter(FilterCriteria newCriteria, bool debounce = true)
@ -284,10 +284,10 @@ namespace osu.Game.Screens.Select
if (newCriteria != null) if (newCriteria != null)
activeCriteria = newCriteria; activeCriteria = newCriteria;
applyActiveCriteria(debounce); applyActiveCriteria(debounce, true);
} }
private void applyActiveCriteria(bool debounce) private void applyActiveCriteria(bool debounce, bool scroll)
{ {
Action perform = delegate Action perform = delegate
{ {
@ -296,7 +296,7 @@ namespace osu.Game.Screens.Select
root.Filter(activeCriteria); root.Filter(activeCriteria);
updateItems(); updateItems();
ScrollToSelected(false); if (scroll) ScrollToSelected(false);
}; };
FilterTask?.Cancel(); FilterTask?.Cancel();
@ -446,7 +446,7 @@ namespace osu.Game.Screens.Select
computeYPositions(); computeYPositions();
// Remove all items that should no longer be on-screen // Remove all items that should no longer be on-screen
scrollableContent.RemoveAll(delegate(DrawableCarouselItem p) scrollableContent.RemoveAll(delegate (DrawableCarouselItem p)
{ {
float itemPosY = p.Position.Y; float itemPosY = p.Position.Y;
bool remove = itemPosY < Current - p.DrawHeight || itemPosY > Current + drawHeight || !p.IsPresent; bool remove = itemPosY < Current - p.DrawHeight || itemPosY > Current + drawHeight || !p.IsPresent;