2017-02-07 13:59:30 +09: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 18:43:01 +09:00
|
|
|
|
|
2017-03-04 19:42:37 +01:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-12-02 18:43:01 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 15:54:23 +10:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-01-10 13:44:40 -05:00
|
|
|
|
using osu.Game.Graphics;
|
2016-12-02 18:43:01 +09:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
|
|
|
|
{
|
2017-11-21 11:49:42 +09:00
|
|
|
|
public class ToolbarOverlayToggleButton : ToolbarButton
|
2016-12-02 18:43:01 +09:00
|
|
|
|
{
|
2017-03-23 13:41:50 +09:00
|
|
|
|
private readonly Box stateBackground;
|
2016-12-02 18:43:01 +09: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 18:43:01 +09:00
|
|
|
|
stateContainer.StateChanged += stateChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 21:28:23 +09:00
|
|
|
|
public ToolbarOverlayToggleButton()
|
2016-12-02 18:43:01 +09:00
|
|
|
|
{
|
2017-02-07 16:15:45 +09:00
|
|
|
|
Add(stateBackground = new Box
|
2016-12-02 18:43:01 +09:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-12 16:38:27 -05:00
|
|
|
|
Colour = OsuColour.Gray(150).Opacity(180),
|
2017-09-07 22:46:21 +09:00
|
|
|
|
Blending = BlendingMode.Additive,
|
2016-12-02 18:43:01 +09:00
|
|
|
|
Depth = 2,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
if (stateContainer != null)
|
|
|
|
|
stateContainer.StateChanged -= stateChanged;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-04 09:10:04 +09:00
|
|
|
|
private void stateChanged(Visibility state)
|
2016-12-02 18:43:01 +09:00
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case Visibility.Hidden:
|
2017-02-07 16:15:45 +09:00
|
|
|
|
stateBackground.FadeOut(200);
|
2016-12-02 18:43:01 +09:00
|
|
|
|
break;
|
|
|
|
|
case Visibility.Visible:
|
2017-02-07 16:15:45 +09:00
|
|
|
|
stateBackground.FadeIn(200);
|
2016-12-02 18:43:01 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|