Ensure toolbar is hidden even when the active screen is changed while the editor is open

This commit is contained in:
Dean Herbert 2022-03-16 19:11:17 +09:00
parent 86960c791f
commit c807ad7e4e

View File

@ -4,7 +4,6 @@
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
@ -84,7 +83,7 @@ namespace osu.Game.Skinning.Editor
}
var editor = new SkinEditor();
editor.State.BindValueChanged(editorVisibilityChanged);
editor.State.BindValueChanged(visibility => updateComponentVisibility());
skinEditor = editor;
@ -107,13 +106,13 @@ namespace osu.Game.Skinning.Editor
});
}
private void editorVisibilityChanged(ValueChangedEvent<Visibility> visibility)
private void updateComponentVisibility()
{
Debug.Assert(skinEditor != null);
const float toolbar_padding_requirement = 0.18f;
if (visibility.NewValue == Visibility.Visible)
if (skinEditor.State.Value == Visibility.Visible)
{
scalingContainer.SetCustomRect(new RectangleF(toolbar_padding_requirement, 0.1f, 0.8f - toolbar_padding_requirement, 0.7f), true);
@ -144,6 +143,9 @@ namespace osu.Game.Skinning.Editor
skinEditor.Save();
// ensure the toolbar is re-hidden even if a new screen decides to try and show it.
updateComponentVisibility();
// AddOnce with parameter will ensure the newest target is loaded if there is any overlap.
Scheduler.AddOnce(setTarget, screen);
}