2017-02-07 04:59:30 +00: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 09:43:01 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using osu.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-01-10 18:44:40 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2016-12-02 09:43:01 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
|
|
|
|
{
|
2016-12-02 12:28:23 +00:00
|
|
|
|
class ToolbarOverlayToggleButton : ToolbarButton
|
2016-12-02 09:43:01 +00:00
|
|
|
|
{
|
2017-02-07 07:15:45 +00:00
|
|
|
|
private Box stateBackground;
|
2016-12-02 09:43:01 +00:00
|
|
|
|
|
|
|
|
|
private OverlayContainer stateContainer;
|
|
|
|
|
|
|
|
|
|
public OverlayContainer StateContainer
|
|
|
|
|
{
|
|
|
|
|
get { return stateContainer; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
stateContainer = value;
|
|
|
|
|
stateContainer.StateChanged += stateChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 12:28:23 +00:00
|
|
|
|
public ToolbarOverlayToggleButton()
|
2016-12-02 09:43:01 +00:00
|
|
|
|
{
|
2017-02-07 07:15:45 +00:00
|
|
|
|
Add(stateBackground = new Box
|
2016-12-02 09:43:01 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-12 21:38:27 +00:00
|
|
|
|
Colour = OsuColour.Gray(150).Opacity(180),
|
2016-12-02 09:43:01 +00:00
|
|
|
|
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:
|
2017-02-07 07:15:45 +00:00
|
|
|
|
stateBackground.FadeOut(200);
|
2016-12-02 09:43:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case Visibility.Visible:
|
2017-02-07 07:15:45 +00:00
|
|
|
|
stateBackground.FadeIn(200);
|
2016-12-02 09:43:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|