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
|
2017-02-04 08:50:58 +00:00
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-02-25 12:12:39 +00:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2017-02-04 08:50:58 +00:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
2017-02-10 07:26:43 +00:00
|
|
|
|
public class Nub : CircularContainer, IStateful<CheckBoxState>
|
2017-02-04 08:50:58 +00:00
|
|
|
|
{
|
|
|
|
|
public const float COLLAPSED_SIZE = 20;
|
|
|
|
|
public const float EXPANDED_SIZE = 40;
|
|
|
|
|
|
|
|
|
|
private Box fill;
|
|
|
|
|
|
|
|
|
|
const float border_width = 3;
|
|
|
|
|
private Color4 glowingColour, idleColour;
|
|
|
|
|
|
2017-02-04 11:06:53 +00:00
|
|
|
|
public Nub()
|
2017-02-04 08:50:58 +00:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(COLLAPSED_SIZE, 12);
|
|
|
|
|
|
|
|
|
|
BorderColour = Color4.White;
|
|
|
|
|
BorderThickness = border_width;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
fill = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-02-05 08:40:58 +00:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
AlwaysPresent = true,
|
2017-02-04 08:50:58 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
Colour = idleColour = colours.Pink;
|
|
|
|
|
glowingColour = colours.PinkLighter;
|
|
|
|
|
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.PinkDarker,
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 10,
|
|
|
|
|
Roundness = 8,
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-25 12:12:39 +00:00
|
|
|
|
FadeEdgeEffectTo(0);
|
2017-02-04 08:50:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Glowing
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
FadeColour(glowingColour, 500, EasingTypes.OutQuint);
|
2017-02-25 12:12:39 +00:00
|
|
|
|
FadeEdgeEffectTo(1, 500, EasingTypes.OutQuint);
|
2017-02-04 08:50:58 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-02-25 12:12:39 +00:00
|
|
|
|
FadeEdgeEffectTo(0, 500);
|
2017-02-04 08:50:58 +00:00
|
|
|
|
FadeColour(idleColour, 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Expanded
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, EasingTypes.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CheckBoxState state;
|
|
|
|
|
|
|
|
|
|
public CheckBoxState State
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
state = value;
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case CheckBoxState.Checked:
|
|
|
|
|
fill.FadeIn(200, EasingTypes.OutQuint);
|
|
|
|
|
break;
|
|
|
|
|
case CheckBoxState.Unchecked:
|
|
|
|
|
fill.FadeTo(0.01f, 200, EasingTypes.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|