mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08:00
Centralise hover state handling (and fix back-to-front conditionals)
This commit is contained in:
parent
6a1f535257
commit
ad430a6277
@ -56,7 +56,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
CornerRadius = BeatmapCard.CORNER_RADIUS,
|
CornerRadius = BeatmapCard.CORNER_RADIUS,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Unhovered = _ => collapseIfNotHovered(),
|
Unhovered = _ => updateFromHoverChange(),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
background = new Box
|
||||||
@ -78,10 +78,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Hovered = _ =>
|
Hovered = _ =>
|
||||||
{
|
{
|
||||||
queueExpandedStateChange(true);
|
updateFromHoverChange();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Unhovered = _ => collapseIfNotHovered(),
|
Unhovered = _ => updateFromHoverChange(),
|
||||||
Child = dropdownScroll = new ExpandedContentScrollContainer
|
Child = dropdownScroll = new ExpandedContentScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -125,11 +125,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
|
|
||||||
public void CancelExpand() => scheduledExpandedChange?.Cancel();
|
public void CancelExpand() => scheduledExpandedChange?.Cancel();
|
||||||
|
|
||||||
private void collapseIfNotHovered()
|
private void updateFromHoverChange() =>
|
||||||
{
|
queueExpandedStateChange(content.IsHovered || dropdownContent.IsHovered, 100);
|
||||||
if (!content.IsHovered && !dropdownContent.IsHovered)
|
|
||||||
queueExpandedStateChange(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void queueExpandedStateChange(bool newState, int delay = 0)
|
private void queueExpandedStateChange(bool newState, int delay = 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user