Allow Nub/OsuCheckbox/OsuSliderBar colours to be overridden.

This commit is contained in:
smoogipooo
2017-05-30 16:40:35 +09:00
parent 08219ccb42
commit c8066cfde9
3 changed files with 85 additions and 26 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
@ -12,13 +13,12 @@ using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface
{
public class Nub : CircularContainer, IHasCurrentValue<bool>
public class Nub : CircularContainer, IHasCurrentValue<bool>, IHasAccentColour
{
public const float COLLAPSED_SIZE = 20;
public const float EXPANDED_SIZE = 40;
private const float border_width = 3;
private Color4 glowingColour, idleColour;
public Nub()
{
@ -53,33 +53,41 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = idleColour = colours.Pink;
glowingColour = colours.PinkLighter;
AccentColour = colours.Pink;
GlowingAccentColour = colours.PinkLighter;
GlowColour = colours.PinkDarker;
EdgeEffect = new EdgeEffect
{
Colour = colours.PinkDarker,
Colour = GlowColour,
Type = EdgeEffectType.Glow,
Radius = 10,
Roundness = 8,
};
}
protected override void LoadComplete()
{
FadeEdgeEffectTo(0);
}
private bool glowing;
public bool Glowing
{
get { return glowing; }
set
{
glowing = value;
if (value)
{
FadeColour(glowingColour, 500, EasingTypes.OutQuint);
FadeColour(GlowingAccentColour, 500, EasingTypes.OutQuint);
FadeEdgeEffectTo(1, 500, EasingTypes.OutQuint);
}
else
{
FadeEdgeEffectTo(0, 500);
FadeColour(idleColour, 500);
FadeColour(AccentColour, 500);
}
}
}
@ -93,5 +101,43 @@ namespace osu.Game.Graphics.UserInterface
}
public Bindable<bool> Current { get; } = new Bindable<bool>();
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
set
{
accentColour = value;
if (!Glowing)
Colour = value;
}
}
private Color4 glowingAccentColour;
public Color4 GlowingAccentColour
{
get { return glowingAccentColour; }
set
{
glowingAccentColour = value;
if (Glowing)
Colour = value;
}
}
private Color4 glowColour;
public Color4 GlowColour
{
get { return glowColour; }
set
{
glowColour = value;
var effect = EdgeEffect;
effect.Colour = value;
EdgeEffect = effect;
}
}
}
}