Convert `SkinEditorOverlay` to an `OverlayContainer` to allow it to block input

This commit is contained in:
Dean Herbert 2022-03-21 16:52:06 +09:00
parent 3643f879e4
commit 2f18c512cd
3 changed files with 15 additions and 21 deletions

View File

@ -1046,6 +1046,10 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
switch (e.Action)
{
case GlobalAction.ToggleSkinEditor:
skinEditor.ToggleVisibility();
return true;
case GlobalAction.ResetInputSettings:
Host.ResetInputHandlers();
frameworkConfig.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode).SetDefault();

View File

@ -64,7 +64,7 @@ private void load(OsuConfigManager config, [CanBeNull] SkinEditorOverlay skinEdi
new SettingsButton
{
Text = SkinSettingsStrings.SkinLayoutEditor,
Action = () => skinEditor?.Toggle(),
Action = () => skinEditor?.ToggleVisibility(),
},
new ExportSkinButton(),
};

View File

@ -19,10 +19,12 @@ namespace osu.Game.Skinning.Editor
/// A container which handles loading a skin editor on user request for a specified target.
/// This also handles the scaling / positioning adjustment of the target.
/// </summary>
public class SkinEditorOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
public class SkinEditorOverlay : OverlayContainer, IKeyBindingHandler<GlobalAction>
{
private readonly ScalingContainer scalingContainer;
protected override bool BlockNonPositionalInput => true;
[CanBeNull]
private SkinEditor skinEditor;
@ -49,30 +51,12 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
Hide();
return true;
case GlobalAction.ToggleSkinEditor:
Toggle();
return true;
}
return false;
}
public void Toggle()
{
if (skinEditor == null)
Show();
else
skinEditor.ToggleVisibility();
}
public override void Hide()
{
// base call intentionally omitted.
skinEditor?.Hide();
}
public override void Show()
protected override void PopIn()
{
// base call intentionally omitted as we have custom behaviour.
@ -106,6 +90,12 @@ public override void Show()
});
}
protected override void PopOut()
{
// base call intentionally omitted.
skinEditor?.Hide();
}
private void updateComponentVisibility()
{
Debug.Assert(skinEditor != null);