1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 00:07:24 +08:00
osu-lazer/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs
2017-02-23 21:38:10 +01:00

60 lines
1.7 KiB
C#

// Copyright (c) 2007-2017 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.Sprites;
using osu.Game.Graphics;
namespace osu.Game.Overlays.Toolbar
{
class ToolbarOverlayToggleButton : ToolbarButton
{
private Box stateBackground;
private OverlayContainer stateContainer;
public OverlayContainer StateContainer
{
get { return stateContainer; }
set
{
stateContainer = value;
stateContainer.StateChanged += stateChanged;
}
}
public ToolbarOverlayToggleButton()
{
Add(stateBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(150).Opacity(180),
BlendingMode = BlendingMode.Additive,
Depth = 2,
Alpha = 0,
});
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (stateContainer != null)
stateContainer.StateChanged -= stateChanged;
}
private void stateChanged(OverlayContainer c, Visibility state)
{
switch (state)
{
case Visibility.Hidden:
stateBackground.FadeOut(200);
break;
case Visibility.Visible:
stateBackground.FadeIn(200);
break;
}
}
}
}