mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 01:33:10 +08:00
expand and contract settings from hover
This commit is contained in:
parent
7d4062d2ad
commit
3713bb48b7
@ -1,37 +1,34 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||||
{
|
{
|
||||||
public partial class MultiSpectatorSettings : CompositeDrawable
|
public partial class MultiSpectatorSettings : ExpandingContainer
|
||||||
{
|
{
|
||||||
private const double slide_duration = 200;
|
public const float CONTRACTED_WIDTH = 30;
|
||||||
|
public const int EXPANDED_WIDTH = 300;
|
||||||
private readonly PlayerSettingsOverlay playerSettingsOverlay;
|
|
||||||
private readonly Container slidingContainer;
|
|
||||||
|
|
||||||
private readonly BindableBool opened = new BindableBool();
|
|
||||||
|
|
||||||
public MultiSpectatorSettings()
|
public MultiSpectatorSettings()
|
||||||
|
: base(CONTRACTED_WIDTH, EXPANDED_WIDTH)
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopLeft;
|
Origin = Anchor.TopRight;
|
||||||
Anchor = Anchor.TopRight;
|
Anchor = Anchor.TopRight;
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
PlayerSettingsOverlay playerSettingsOverlay;
|
||||||
{
|
|
||||||
slidingContainer = new Container
|
InternalChild = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -40,41 +37,24 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
Icon = FontAwesome.Solid.Cog,
|
Icon = FontAwesome.Solid.Cog,
|
||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
Anchor = Anchor.TopLeft,
|
Anchor = Anchor.TopLeft,
|
||||||
Position = new Vector2(-30, 0),
|
Action = () => Expanded.Toggle()
|
||||||
Action = () => opened.Toggle()
|
|
||||||
},
|
},
|
||||||
playerSettingsOverlay = new PlayerSettingsOverlay()
|
playerSettingsOverlay = new PlayerSettingsOverlay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopLeft,
|
||||||
|
Origin = Anchor.TopLeft
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
playerSettingsOverlay.Show();
|
playerSettingsOverlay.Show();
|
||||||
|
|
||||||
opened.BindValueChanged(value =>
|
|
||||||
{
|
|
||||||
if (value.NewValue)
|
|
||||||
open();
|
|
||||||
else
|
|
||||||
close();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void open()
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
slidingContainer.MoveToOffset(new Vector2(-playerSettingsOverlay.Width, 0), slide_duration, Easing.Out).Then().OnComplete(c =>
|
// Prevent unexpanding when hovering player settings
|
||||||
{
|
if (!Contains(e.ScreenSpaceMousePosition))
|
||||||
c.Origin = Anchor.TopRight;
|
base.OnHoverLost(e);
|
||||||
c.Position = Vector2.Zero;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void close()
|
|
||||||
{
|
|
||||||
slidingContainer.MoveToOffset(new Vector2(playerSettingsOverlay.Width, 0), slide_duration, Easing.Out).Then().OnComplete(c =>
|
|
||||||
{
|
|
||||||
c.Origin = Anchor.TopLeft;
|
|
||||||
c.Position = Vector2.Zero;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user