1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 16:47:26 +08:00
osu-lazer/osu.Game/Beatmaps/Drawable/Panel.cs

117 lines
2.9 KiB
C#
Raw Normal View History

//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
2016-11-05 19:00:14 +08:00
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Beatmaps.Drawable
{
class Panel : Container, IStateful<PanelSelectedState>
{
public const float MAX_HEIGHT = 80;
public bool Hidden = true;
private Container nestedContainer;
protected override Container<Framework.Graphics.Drawable> Content => nestedContainer;
public Panel()
{
Height = MAX_HEIGHT;
Masking = true;
CornerRadius = 10;
BorderColour = new Color4(221, 255, 255, 255);
RelativeSizeAxes = Axes.X;
AddInternal(nestedContainer = new Container
{
RelativeSizeAxes = Axes.Both,
});
}
public void SetMultiplicativeAlpha(float alpha)
{
nestedContainer.Alpha = alpha;
}
protected override void LoadComplete()
{
base.LoadComplete();
applyState();
FadeInFromZero(250);
}
private void applyState()
{
switch (state)
{
case PanelSelectedState.NotSelected:
Deselected();
break;
case PanelSelectedState.Selected:
Selected();
break;
}
}
private PanelSelectedState state = PanelSelectedState.NotSelected;
public PanelSelectedState State
{
get { return state; }
set
{
if (state == value) return;
state = value;
applyState();
}
}
protected virtual void Selected()
{
BorderThickness = 2.5f;
2016-11-02 05:57:11 +08:00
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Glow,
2016-11-02 09:22:46 +08:00
Colour = new Color4(130, 204, 255, 150),
2016-11-02 05:57:11 +08:00
Radius = 20,
Roundness = 10,
};
}
protected virtual void Deselected()
{
BorderThickness = 0;
2016-11-02 05:57:11 +08:00
2016-11-05 19:00:14 +08:00
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(1),
Radius = 10,
Colour = new Color4(0, 0, 0, 100),
};
}
2016-11-02 05:57:11 +08:00
protected override bool OnClick(InputState state)
{
State = PanelSelectedState.Selected;
return true;
}
}
enum PanelSelectedState
{
NotSelected,
Selected
}
}