mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge pull request #14560 from Joehuu/privatise-toolbar-offset
Fix overlays closing when clicking any empty area of the toolbar
This commit is contained in:
@ -323,6 +323,71 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddWaitStep("wait two frames", 2);
|
AddWaitStep("wait two frames", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOverlayClosing()
|
||||||
|
{
|
||||||
|
// use now playing overlay for "overlay -> background" drag case
|
||||||
|
// since most overlays use a scroll container that absorbs on mouse down
|
||||||
|
NowPlayingOverlay nowPlayingOverlay = null;
|
||||||
|
|
||||||
|
AddStep("enter menu", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
|
AddStep("get and press now playing hotkey", () =>
|
||||||
|
{
|
||||||
|
nowPlayingOverlay = Game.ChildrenOfType<NowPlayingOverlay>().Single();
|
||||||
|
InputManager.Key(Key.F6);
|
||||||
|
});
|
||||||
|
|
||||||
|
// drag tests
|
||||||
|
|
||||||
|
// background -> toolbar
|
||||||
|
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
|
||||||
|
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
|
||||||
|
AddStep("move cursor to toolbar", () => InputManager.MoveMouseTo(Game.Toolbar.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
|
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
|
||||||
|
|
||||||
|
AddStep("press now playing hotkey", () => InputManager.Key(Key.F6));
|
||||||
|
|
||||||
|
// toolbar -> background
|
||||||
|
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
|
||||||
|
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
|
||||||
|
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
|
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
// background -> overlay
|
||||||
|
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
|
||||||
|
AddStep("move cursor to now playing overlay", () => InputManager.MoveMouseTo(nowPlayingOverlay.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
|
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
// overlay -> background
|
||||||
|
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
|
||||||
|
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
|
||||||
|
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
|
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
// background -> background
|
||||||
|
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
|
||||||
|
AddStep("move cursor to left", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomLeft));
|
||||||
|
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
|
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
|
||||||
|
|
||||||
|
AddStep("press now playing hotkey", () => InputManager.Key(Key.F6));
|
||||||
|
|
||||||
|
// click tests
|
||||||
|
|
||||||
|
// toolbar
|
||||||
|
AddStep("move cursor to toolbar", () => InputManager.MoveMouseTo(Game.Toolbar.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddStep("click left mouse button", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
// background
|
||||||
|
AddStep("move cursor to background", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.BottomRight));
|
||||||
|
AddStep("click left mouse button", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
|
||||||
|
}
|
||||||
|
|
||||||
private void pushEscape() =>
|
private void pushEscape() =>
|
||||||
AddStep("Press escape", () => InputManager.Key(Key.Escape));
|
AddStep("Press escape", () => InputManager.Key(Key.Escape));
|
||||||
|
|
||||||
|
@ -104,6 +104,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected Container ScreenOffsetContainer { get; private set; }
|
protected Container ScreenOffsetContainer { get; private set; }
|
||||||
|
|
||||||
|
private Container overlayOffsetContainer;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private FrameworkConfigManager frameworkConfig { get; set; }
|
private FrameworkConfigManager frameworkConfig { get; set; }
|
||||||
|
|
||||||
@ -120,7 +122,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
public virtual StableStorage GetStorageForStableInstall() => null;
|
public virtual StableStorage GetStorageForStableInstall() => null;
|
||||||
|
|
||||||
public float ToolbarOffset => (Toolbar?.Position.Y ?? 0) + (Toolbar?.DrawHeight ?? 0);
|
private float toolbarOffset => (Toolbar?.Position.Y ?? 0) + (Toolbar?.DrawHeight ?? 0);
|
||||||
|
|
||||||
private IdleTracker idleTracker;
|
private IdleTracker idleTracker;
|
||||||
|
|
||||||
@ -158,7 +160,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
private readonly string[] args;
|
private readonly string[] args;
|
||||||
|
|
||||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
private readonly List<OsuFocusedOverlayContainer> focusedOverlays = new List<OsuFocusedOverlayContainer>();
|
||||||
|
|
||||||
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
|
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
|
||||||
|
|
||||||
@ -193,7 +195,7 @@ namespace osu.Game
|
|||||||
/// <param name="hideToolbar">Whether the toolbar should also be hidden.</param>
|
/// <param name="hideToolbar">Whether the toolbar should also be hidden.</param>
|
||||||
public void CloseAllOverlays(bool hideToolbar = true)
|
public void CloseAllOverlays(bool hideToolbar = true)
|
||||||
{
|
{
|
||||||
foreach (var overlay in overlays)
|
foreach (var overlay in focusedOverlays)
|
||||||
overlay.Hide();
|
overlay.Hide();
|
||||||
|
|
||||||
if (hideToolbar) Toolbar.Hide();
|
if (hideToolbar) Toolbar.Hide();
|
||||||
@ -692,9 +694,16 @@ namespace osu.Game
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
overlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
overlayOffsetContainer = new Container
|
||||||
rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
{
|
||||||
leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
overlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
}
|
||||||
|
},
|
||||||
topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
idleTracker,
|
idleTracker,
|
||||||
new ConfineMouseTracker()
|
new ConfineMouseTracker()
|
||||||
@ -731,7 +740,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
loadComponentSingleFile(Notifications.With(d =>
|
loadComponentSingleFile(Notifications.With(d =>
|
||||||
{
|
{
|
||||||
d.GetToolbarHeight = () => ToolbarOffset;
|
|
||||||
d.Anchor = Anchor.TopRight;
|
d.Anchor = Anchor.TopRight;
|
||||||
d.Origin = Anchor.TopRight;
|
d.Origin = Anchor.TopRight;
|
||||||
}), rightFloatingOverlayContent.Add, true);
|
}), rightFloatingOverlayContent.Add, true);
|
||||||
@ -757,7 +765,7 @@ namespace osu.Game
|
|||||||
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
|
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
|
||||||
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
|
loadComponentSingleFile(new MessageNotifier(), AddInternal, true);
|
||||||
loadComponentSingleFile(Settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true);
|
loadComponentSingleFile(Settings = new SettingsOverlay(), leftFloatingOverlayContent.Add, true);
|
||||||
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
|
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
|
||||||
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
|
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
|
||||||
@ -766,14 +774,12 @@ namespace osu.Game
|
|||||||
|
|
||||||
loadComponentSingleFile(new LoginOverlay
|
loadComponentSingleFile(new LoginOverlay
|
||||||
{
|
{
|
||||||
GetToolbarHeight = () => ToolbarOffset,
|
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}, rightFloatingOverlayContent.Add, true);
|
}, rightFloatingOverlayContent.Add, true);
|
||||||
|
|
||||||
loadComponentSingleFile(new NowPlayingOverlay
|
loadComponentSingleFile(new NowPlayingOverlay
|
||||||
{
|
{
|
||||||
GetToolbarHeight = () => ToolbarOffset,
|
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}, rightFloatingOverlayContent.Add, true);
|
}, rightFloatingOverlayContent.Add, true);
|
||||||
@ -904,8 +910,8 @@ namespace osu.Game
|
|||||||
if (cache)
|
if (cache)
|
||||||
dependencies.CacheAs(component);
|
dependencies.CacheAs(component);
|
||||||
|
|
||||||
if (component is OverlayContainer overlay)
|
if (component is OsuFocusedOverlayContainer overlay)
|
||||||
overlays.Add(overlay);
|
focusedOverlays.Add(overlay);
|
||||||
|
|
||||||
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
|
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
|
||||||
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
|
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
|
||||||
@ -1013,8 +1019,8 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
ScreenOffsetContainer.Padding = new MarginPadding { Top = ToolbarOffset };
|
ScreenOffsetContainer.Padding = new MarginPadding { Top = toolbarOffset };
|
||||||
overlayContent.Padding = new MarginPadding { Top = ToolbarOffset };
|
overlayOffsetContainer.Padding = new MarginPadding { Top = toolbarOffset };
|
||||||
|
|
||||||
var horizontalOffset = 0f;
|
var horizontalOffset = 0f;
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ using osuTK.Graphics;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -20,11 +19,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private const float transition_time = 400;
|
private const float transition_time = 400;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provide a source for the toolbar height.
|
|
||||||
/// </summary>
|
|
||||||
public Func<float> GetToolbarHeight;
|
|
||||||
|
|
||||||
public LoginOverlay()
|
public LoginOverlay()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
@ -94,12 +88,5 @@ namespace osu.Game.Overlays
|
|||||||
settingsSection.Bounding = false;
|
settingsSection.Bounding = false;
|
||||||
this.FadeOut(transition_time);
|
this.FadeOut(transition_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -30,11 +29,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private FlowContainer<NotificationSection> sections;
|
private FlowContainer<NotificationSection> sections;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provide a source for the toolbar height.
|
|
||||||
/// </summary>
|
|
||||||
public Func<float> GetToolbarHeight;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -168,12 +162,5 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
updateCounts();
|
updateCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,6 @@ namespace osu.Game.Overlays
|
|||||||
protected override string PopInSampleName => "UI/now-playing-pop-in";
|
protected override string PopInSampleName => "UI/now-playing-pop-in";
|
||||||
protected override string PopOutSampleName => "UI/now-playing-pop-out";
|
protected override string PopOutSampleName => "UI/now-playing-pop-out";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provide a source for the toolbar height.
|
|
||||||
/// </summary>
|
|
||||||
public Func<float> GetToolbarHeight;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController musicController { get; set; }
|
private MusicController musicController { get; set; }
|
||||||
|
|
||||||
@ -246,7 +241,6 @@ namespace osu.Game.Overlays
|
|||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
Height = dragContainer.Height;
|
Height = dragContainer.Height;
|
||||||
dragContainer.Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -54,11 +54,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
protected override string PopInSampleName => "UI/settings-pop-in";
|
protected override string PopInSampleName => "UI/settings-pop-in";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provide a source for the toolbar height.
|
|
||||||
/// </summary>
|
|
||||||
public Func<float> GetToolbarHeight;
|
|
||||||
|
|
||||||
private readonly bool showSidebar;
|
private readonly bool showSidebar;
|
||||||
|
|
||||||
private LoadingLayer loading;
|
private LoadingLayer loading;
|
||||||
@ -193,7 +188,6 @@ namespace osu.Game.Overlays
|
|||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 };
|
ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 };
|
||||||
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const double fade_in_duration = 1000;
|
private const double fade_in_duration = 1000;
|
||||||
|
@ -18,7 +18,7 @@ using osu.Game.Input.Bindings;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Toolbar
|
namespace osu.Game.Overlays.Toolbar
|
||||||
{
|
{
|
||||||
public class Toolbar : VisibilityContainer, IKeyBindingHandler<GlobalAction>
|
public class Toolbar : OverlayContainer, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
public const float HEIGHT = 40;
|
public const float HEIGHT = 40;
|
||||||
public const float TOOLTIP_HEIGHT = 30;
|
public const float TOOLTIP_HEIGHT = 30;
|
||||||
@ -41,6 +41,8 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
// Toolbar and its components need keyboard input even when hidden.
|
// Toolbar and its components need keyboard input even when hidden.
|
||||||
public override bool PropagateNonPositionalInputSubTree => true;
|
public override bool PropagateNonPositionalInputSubTree => true;
|
||||||
|
|
||||||
|
protected override bool BlockScrollInput => false;
|
||||||
|
|
||||||
public Toolbar()
|
public Toolbar()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Reference in New Issue
Block a user