mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Fix carousel items' borders getting blown out when selected and hovered
I tried restructuring the hierarchy to avoid needing this added property (moving the hover layer out of the border container) but this leads to some subpixel leakage outside the borders which looks even worse. Closes #6915.
This commit is contained in:
parent
e30fb72ee2
commit
c3a98b6ad1
@ -24,9 +24,13 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
public Container BorderContainer;
|
||||
|
||||
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
|
||||
private HoverLayer hoverLayer;
|
||||
|
||||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
private const float corner_radius = 10;
|
||||
private const float border_thickness = 2.5f;
|
||||
|
||||
public CarouselHeader()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -36,12 +40,12 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 10,
|
||||
CornerRadius = corner_radius,
|
||||
BorderColour = new Color4(221, 255, 255, 255),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Content,
|
||||
new HoverLayer()
|
||||
hoverLayer = new HoverLayer()
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -59,6 +63,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
case CarouselItemState.Collapsed:
|
||||
case CarouselItemState.NotSelected:
|
||||
hoverLayer.InsetForBorder = false;
|
||||
|
||||
BorderContainer.BorderThickness = 0;
|
||||
BorderContainer.EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
@ -70,7 +76,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
break;
|
||||
|
||||
case CarouselItemState.Selected:
|
||||
BorderContainer.BorderThickness = 2.5f;
|
||||
hoverLayer.InsetForBorder = true;
|
||||
|
||||
BorderContainer.BorderThickness = border_thickness;
|
||||
BorderContainer.EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
@ -107,6 +115,26 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
sampleHover = audio.Samples.Get("SongSelect/song-ping");
|
||||
}
|
||||
|
||||
public bool InsetForBorder
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// apply same border as above to avoid applying additive overlay to it (and blowing out the colour).
|
||||
Masking = true;
|
||||
CornerRadius = corner_radius;
|
||||
BorderThickness = border_thickness;
|
||||
}
|
||||
else
|
||||
{
|
||||
BorderThickness = 0;
|
||||
CornerRadius = 0;
|
||||
Masking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
box.FadeIn(100, Easing.OutQuint);
|
||||
|
Loading…
Reference in New Issue
Block a user