2016-10-27 18:52:48 +08:00
|
|
|
|
//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;
|
2016-11-25 11:47:58 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
using osu.Framework.Input;
|
2016-11-05 19:00:14 +08:00
|
|
|
|
using OpenTK;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2016-10-27 18:52:48 +08:00
|
|
|
|
{
|
|
|
|
|
class Panel : Container, IStateful<PanelSelectedState>
|
|
|
|
|
{
|
2016-11-23 04:40:47 +08:00
|
|
|
|
public const float MAX_HEIGHT = 80;
|
|
|
|
|
|
2016-11-25 17:14:56 +08:00
|
|
|
|
public override bool RemoveWhenNotAlive => false;
|
|
|
|
|
|
|
|
|
|
public bool OnScreen;
|
|
|
|
|
|
|
|
|
|
public override bool IsAlive => OnScreen;
|
2016-11-25 11:47:58 +08:00
|
|
|
|
|
2016-11-23 04:40:47 +08:00
|
|
|
|
private Container nestedContainer;
|
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
protected override Container<Drawable> Content => nestedContainer;
|
2016-11-23 04:40:47 +08:00
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
protected Panel()
|
2016-10-27 18:52:48 +08:00
|
|
|
|
{
|
2016-11-23 04:40:47 +08:00
|
|
|
|
Height = MAX_HEIGHT;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2016-11-23 04:40:47 +08:00
|
|
|
|
|
|
|
|
|
AddInternal(nestedContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-11-23 04:58:46 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 10,
|
|
|
|
|
BorderColour = new Color4(221, 255, 255, 255),
|
2016-11-23 04:40:47 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMultiplicativeAlpha(float alpha)
|
|
|
|
|
{
|
|
|
|
|
nestedContainer.Alpha = alpha;
|
2016-11-21 03:34:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
applyState();
|
|
|
|
|
}
|
2016-11-05 19:24:15 +08:00
|
|
|
|
|
2016-11-21 03:34:16 +08:00
|
|
|
|
private void applyState()
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case PanelSelectedState.NotSelected:
|
|
|
|
|
Deselected();
|
|
|
|
|
break;
|
|
|
|
|
case PanelSelectedState.Selected:
|
|
|
|
|
Selected();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-27 18:52:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 19:24:15 +08:00
|
|
|
|
private PanelSelectedState state = PanelSelectedState.NotSelected;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
|
|
|
|
|
public PanelSelectedState State
|
|
|
|
|
{
|
|
|
|
|
get { return state; }
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (state == value) return;
|
|
|
|
|
state = value;
|
|
|
|
|
|
2016-11-21 03:34:16 +08:00
|
|
|
|
applyState();
|
2016-10-27 18:52:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Selected()
|
|
|
|
|
{
|
2016-11-23 04:58:46 +08:00
|
|
|
|
nestedContainer.BorderThickness = 2.5f;
|
|
|
|
|
nestedContainer.EdgeEffect = new EdgeEffect
|
2016-11-02 05:57:11 +08:00
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
};
|
2016-10-27 18:52:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Deselected()
|
|
|
|
|
{
|
2016-11-23 04:58:46 +08:00
|
|
|
|
nestedContainer.BorderThickness = 0;
|
|
|
|
|
nestedContainer.EdgeEffect = new EdgeEffect
|
2016-11-05 19:00:14 +08:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Offset = new Vector2(1),
|
|
|
|
|
Radius = 10,
|
|
|
|
|
Colour = new Color4(0, 0, 0, 100),
|
|
|
|
|
};
|
2016-10-27 18:52:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 05:57:11 +08:00
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
State = PanelSelectedState.Selected;
|
|
|
|
|
return true;
|
2016-10-27 18:52:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum PanelSelectedState
|
|
|
|
|
{
|
|
|
|
|
NotSelected,
|
|
|
|
|
Selected
|
|
|
|
|
}
|
|
|
|
|
}
|