Make LoginOverlay mask better.

This commit is contained in:
Dean Herbert
2017-01-31 16:59:38 +09:00
parent 3476abc38b
commit 22ef576c64
6 changed files with 52 additions and 30 deletions

View File

@ -63,14 +63,14 @@ namespace osu.Game.Overlays.Toolbar
Direction = FlowDirection.HorizontalOnly, Direction = FlowDirection.HorizontalOnly,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Children = new [] Children = new Drawable[]
{ {
new ToolbarMusicButton(), new ToolbarMusicButton(),
new ToolbarButton new ToolbarButton
{ {
Icon = FontAwesome.fa_search Icon = FontAwesome.fa_search
}, },
new ToolbarUserButton(), new ToolbarUserArea(),
new ToolbarButton new ToolbarButton
{ {
Icon = FontAwesome.fa_bars Icon = FontAwesome.fa_bars

View File

@ -122,6 +122,7 @@ namespace osu.Game.Overlays.Toolbar
}; };
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -0,0 +1,46 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using OpenTK;
namespace osu.Game.Overlays.Toolbar
{
class ToolbarUserArea : Container
{
private LoginOverlay loginOverlay;
private ToolbarUserButton button;
public override RectangleF BoundingBox => button.BoundingBox;
public override bool Contains(Vector2 screenSpacePos) => true;
public override Vector2 Size => button.Size;
public ToolbarUserArea()
{
RelativeSizeAxes = Axes.Y;
Children = new Drawable[] {
button = new ToolbarUserButton
{
Action = toggle,
},
loginOverlay = new LoginOverlay
{
Position = new Vector2(0, 1),
RelativePositionAxes = Axes.Y,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
}
};
}
private void toggle()
{
loginOverlay.ToggleVisibility();
}
}
}

View File

@ -1,12 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>. //Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -16,14 +11,12 @@ using osu.Game.Online.API;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Input;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
class ToolbarUserButton : ToolbarButton, IOnlineComponent class ToolbarUserButton : ToolbarButton, IOnlineComponent
{ {
private Avatar avatar; private Avatar avatar;
private LoginOverlay loginOverlay;
public ToolbarUserButton() public ToolbarUserButton()
{ {
@ -34,29 +27,10 @@ namespace osu.Game.Overlays.Toolbar
Flow.Add(avatar = new Avatar()); Flow.Add(avatar = new Avatar());
} }
public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || (loginOverlay.IsVisible && loginOverlay.Contains(screenSpacePos));
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(APIAccess api, OsuGameBase game) private void load(APIAccess api)
{ {
api.Register(this); api.Register(this);
(loginOverlay = new LoginOverlay
{
Position = new Vector2(0, 1),
RelativePositionAxes = Axes.Y,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
}).Preload(game, Add);
}
protected override bool OnClick(InputState state)
{
if (!base.Contains(state.Mouse.NativeState.Position)) return false;
loginOverlay.ToggleVisibility();
return base.OnClick(state);
} }
public void APIStateChanged(APIAccess api, APIState state) public void APIStateChanged(APIAccess api, APIState state)

View File

@ -98,6 +98,7 @@
<Compile Include="Overlays\Toolbar\ToolbarMusicButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarMusicButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarSettingsButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarSettingsButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarOverlayToggleButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarOverlayToggleButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarUserArea.cs" />
<Compile Include="Overlays\Toolbar\ToolbarUserButton.cs" /> <Compile Include="Overlays\Toolbar\ToolbarUserButton.cs" />
<Compile Include="Screens\BackgroundMode.cs" /> <Compile Include="Screens\BackgroundMode.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeBeatmap.cs" /> <Compile Include="Screens\Backgrounds\BackgroundModeBeatmap.cs" />