Bind UpdateVisibility() directly to source of truth

This commit is contained in:
Bartłomiej Dach 2020-10-31 12:21:07 +01:00
parent ea007af572
commit 003994ab75
2 changed files with 7 additions and 14 deletions

View File

@ -210,10 +210,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
if (DragBox.State == Visibility.Visible)
{
DragBox.Hide();
SelectionHandler.UpdateVisibility();
}
}
protected override bool OnKeyDown(KeyDownEvent e)
@ -352,11 +349,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary>
/// Selects all <see cref="SelectionBlueprint"/>s.
/// </summary>
private void selectAll()
{
SelectionBlueprints.ToList().ForEach(m => m.Select());
SelectionHandler.UpdateVisibility();
}
private void selectAll() => SelectionBlueprints.ToList().ForEach(m => m.Select());
/// <summary>
/// Deselects all selected <see cref="SelectionBlueprint"/>s.

View File

@ -201,8 +201,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
// there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once.
if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject))
EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
UpdateVisibility();
}
/// <summary>
@ -214,8 +212,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
selectedBlueprints.Remove(blueprint);
EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject);
UpdateVisibility();
}
/// <summary>
@ -254,7 +250,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary>
/// Updates whether this <see cref="SelectionHandler"/> is visible.
/// </summary>
internal void UpdateVisibility()
private void updateVisibility()
{
int count = selectedBlueprints.Count;
@ -421,7 +417,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
// bring in updates from selection changes
EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates();
EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) => UpdateTernaryStates();
EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) =>
{
updateVisibility();
UpdateTernaryStates();
};
}
/// <summary>