mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Remove externally exposed Expanded
state and change behaviour and visuals surrounding it
This commit is contained in:
@ -17,11 +17,10 @@ using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class Nub : CircularContainer, IHasCurrentValue<bool>, IHasAccentColour
|
||||
public class Nub : CompositeDrawable, IHasCurrentValue<bool>, IHasAccentColour
|
||||
{
|
||||
public const float HEIGHT = 15;
|
||||
|
||||
public const float COLLAPSED_SIZE = 30;
|
||||
public const float EXPANDED_SIZE = 50;
|
||||
|
||||
private const float border_width = 3;
|
||||
@ -29,32 +28,34 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const double animate_in_duration = 200;
|
||||
private const double animate_out_duration = 500;
|
||||
|
||||
private readonly Box fill;
|
||||
private readonly Container main;
|
||||
|
||||
public Nub()
|
||||
{
|
||||
Box fill;
|
||||
Size = new Vector2(EXPANDED_SIZE, HEIGHT);
|
||||
|
||||
Size = new Vector2(COLLAPSED_SIZE, HEIGHT);
|
||||
|
||||
BorderColour = Color4.White;
|
||||
BorderThickness = border_width;
|
||||
|
||||
Masking = true;
|
||||
|
||||
Children = new[]
|
||||
InternalChildren = new[]
|
||||
{
|
||||
fill = new Box
|
||||
main = new CircularContainer
|
||||
{
|
||||
BorderColour = Color4.White,
|
||||
BorderThickness = border_width,
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
fill = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Current.ValueChanged += filled =>
|
||||
{
|
||||
fill.FadeTo(filled.NewValue ? 1 : 0, 200, Easing.OutQuint);
|
||||
this.TransformTo(nameof(BorderThickness), filled.NewValue ? 8.5f : border_width, 200, Easing.OutQuint);
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
@ -64,7 +65,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
GlowingAccentColour = colourProvider?.Highlight1.Lighten(0.2f) ?? colours.PinkLighter;
|
||||
GlowColour = colourProvider?.Light4 ?? colours.PinkDarker;
|
||||
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
main.EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Colour = GlowColour.Opacity(0),
|
||||
Type = EdgeEffectType.Glow,
|
||||
@ -73,6 +74,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Current.BindValueChanged(onCurrentValueChanged, true);
|
||||
}
|
||||
|
||||
private bool glowing;
|
||||
|
||||
public bool Glowing
|
||||
@ -84,28 +92,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (value)
|
||||
{
|
||||
this.FadeColour(GlowingAccentColour, animate_in_duration, Easing.OutQuint);
|
||||
FadeEdgeEffectTo(0.6f, animate_in_duration, Easing.OutQuint);
|
||||
main.FadeColour(GlowingAccentColour, animate_in_duration, Easing.OutQuint);
|
||||
main.FadeEdgeEffectTo(0.6f, animate_in_duration, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeEdgeEffectTo(0, animate_out_duration);
|
||||
this.FadeColour(AccentColour, animate_out_duration);
|
||||
main.FadeEdgeEffectTo(0, animate_out_duration);
|
||||
main.FadeColour(AccentColour, animate_out_duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Expanded
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
this.ResizeTo(new Vector2(EXPANDED_SIZE, HEIGHT), animate_in_duration, Easing.OutQuint);
|
||||
else
|
||||
this.ResizeTo(new Vector2(COLLAPSED_SIZE, HEIGHT), animate_out_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Bindable<bool> current = new Bindable<bool>();
|
||||
|
||||
public Bindable<bool> Current
|
||||
@ -130,7 +127,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
accentColour = value;
|
||||
if (!Glowing)
|
||||
Colour = value;
|
||||
main.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +140,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
glowingAccentColour = value;
|
||||
if (Glowing)
|
||||
Colour = value;
|
||||
main.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,8 +155,20 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
var effect = EdgeEffect;
|
||||
effect.Colour = Glowing ? value : value.Opacity(0);
|
||||
EdgeEffect = effect;
|
||||
main.EdgeEffect = effect;
|
||||
}
|
||||
}
|
||||
|
||||
private void onCurrentValueChanged(ValueChangedEvent<bool> filled)
|
||||
{
|
||||
fill.FadeTo(filled.NewValue ? 1 : 0, 200, Easing.OutQuint);
|
||||
|
||||
if (filled.NewValue)
|
||||
main.ResizeWidthTo(1, animate_in_duration, Easing.OutElasticHalf);
|
||||
else
|
||||
main.ResizeWidthTo(0.9f, animate_out_duration, Easing.OutElastic);
|
||||
|
||||
main.TransformTo(nameof(BorderThickness), filled.NewValue ? 8.5f : border_width, 200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user