2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-12-02 17:43:01 +08:00
|
|
|
|
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-12-02 17:43:01 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-01-11 02:44:40 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2016-12-02 17:43:01 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
|
|
|
|
{
|
2017-11-21 10:49:42 +08:00
|
|
|
|
public class ToolbarOverlayToggleButton : ToolbarButton
|
2016-12-02 17:43:01 +08:00
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Box stateBackground;
|
2016-12-02 17:43:01 +08:00
|
|
|
|
|
|
|
|
|
private OverlayContainer stateContainer;
|
|
|
|
|
|
|
|
|
|
public OverlayContainer StateContainer
|
|
|
|
|
{
|
|
|
|
|
get { return stateContainer; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
stateContainer = value;
|
2017-05-08 19:37:41 +08:00
|
|
|
|
Action = stateContainer.ToggleVisibility;
|
2016-12-02 17:43:01 +08:00
|
|
|
|
stateContainer.StateChanged += stateChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 20:28:23 +08:00
|
|
|
|
public ToolbarOverlayToggleButton()
|
2016-12-02 17:43:01 +08:00
|
|
|
|
{
|
2017-02-07 15:15:45 +08:00
|
|
|
|
Add(stateBackground = new Box
|
2016-12-02 17:43:01 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-13 05:38:27 +08:00
|
|
|
|
Colour = OsuColour.Gray(150).Opacity(180),
|
2017-09-07 21:46:21 +08:00
|
|
|
|
Blending = BlendingMode.Additive,
|
2016-12-02 17:43:01 +08:00
|
|
|
|
Depth = 2,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
if (stateContainer != null)
|
|
|
|
|
stateContainer.StateChanged -= stateChanged;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-04 08:10:04 +08:00
|
|
|
|
private void stateChanged(Visibility state)
|
2016-12-02 17:43:01 +08:00
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case Visibility.Hidden:
|
2017-02-07 15:15:45 +08:00
|
|
|
|
stateBackground.FadeOut(200);
|
2016-12-02 17:43:01 +08:00
|
|
|
|
break;
|
|
|
|
|
case Visibility.Visible:
|
2017-02-07 15:15:45 +08:00
|
|
|
|
stateBackground.FadeIn(200);
|
2016-12-02 17:43:01 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|