mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:05:37 +08:00
Share extra row dropdown show/cancel show logic
This commit is contained in:
parent
3fa45479b0
commit
7aab12d4b0
@ -44,7 +44,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
private readonly BeatmapDownloadTracker downloadTracker;
|
||||
|
||||
private BeatmapCardContent content = null!;
|
||||
[Cached]
|
||||
private readonly BeatmapCardContent content;
|
||||
|
||||
private BeatmapCardThumbnail thumbnail = null!;
|
||||
|
||||
@ -72,6 +73,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
this.beatmapSet = beatmapSet;
|
||||
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
||||
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
||||
content = new BeatmapCardContent(height);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
@ -80,13 +82,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
Width = width;
|
||||
Height = height;
|
||||
|
||||
FillFlowContainer leftIconArea;
|
||||
GridContainer titleContainer;
|
||||
GridContainer artistContainer;
|
||||
FillFlowContainer leftIconArea = null!;
|
||||
GridContainer titleContainer = null!;
|
||||
GridContainer artistContainer = null!;
|
||||
|
||||
InternalChild = content = new BeatmapCardContent(height)
|
||||
InternalChild = content.With(c =>
|
||||
{
|
||||
MainContent = new Container
|
||||
c.MainContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
@ -281,20 +283,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
ChildrenEnumerable = createStatistics()
|
||||
},
|
||||
new BeatmapCardExtraInfoRow(beatmapSet)
|
||||
{
|
||||
Hovered = _ =>
|
||||
{
|
||||
content.ExpandAfterDelay();
|
||||
return false;
|
||||
},
|
||||
Unhovered = _ =>
|
||||
{
|
||||
// Handles the case where a user has not shown explicit intent to view expanded info.
|
||||
// ie. quickly moved over the info row area but didn't remain within it.
|
||||
if (!Expanded.Value)
|
||||
content.CancelExpand();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
downloadProgressBar = new BeatmapCardDownloadProgressBar
|
||||
@ -311,16 +299,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ExpandedContent = new Container
|
||||
};
|
||||
c.ExpandedContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
|
||||
Child = new BeatmapCardDifficultyList(beatmapSet)
|
||||
},
|
||||
Expanded = { BindTarget = Expanded }
|
||||
};
|
||||
};
|
||||
c.Expanded.BindTarget = Expanded;
|
||||
});
|
||||
|
||||
if (beatmapSet.HasVideo)
|
||||
leftIconArea.Add(new IconPill(FontAwesome.Solid.Film) { IconSize = new Vector2(20) });
|
||||
|
@ -40,7 +40,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
private readonly BeatmapDownloadTracker downloadTracker;
|
||||
|
||||
private BeatmapCardContent content = null!;
|
||||
[Cached]
|
||||
private readonly BeatmapCardContent content;
|
||||
|
||||
private BeatmapCardThumbnail thumbnail = null!;
|
||||
|
||||
@ -66,6 +67,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
this.beatmapSet = beatmapSet;
|
||||
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
||||
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
||||
content = new BeatmapCardContent(height);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
@ -74,13 +76,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
Width = width;
|
||||
Height = height;
|
||||
|
||||
FillFlowContainer leftIconArea;
|
||||
GridContainer titleContainer;
|
||||
GridContainer artistContainer;
|
||||
FillFlowContainer leftIconArea = null!;
|
||||
GridContainer titleContainer = null!;
|
||||
GridContainer artistContainer = null!;
|
||||
|
||||
InternalChild = content = new BeatmapCardContent(height)
|
||||
InternalChild = content.With(c =>
|
||||
{
|
||||
MainContent = new Container
|
||||
c.MainContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
@ -295,20 +297,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
}
|
||||
},
|
||||
new BeatmapCardExtraInfoRow(beatmapSet)
|
||||
{
|
||||
Hovered = _ =>
|
||||
{
|
||||
content.ExpandAfterDelay();
|
||||
return false;
|
||||
},
|
||||
Unhovered = _ =>
|
||||
{
|
||||
// This hide should only trigger if the expanded content has not shown yet.
|
||||
// ie. if the user has not shown intent to want to see it (quickly moved over the info row area).
|
||||
if (!Expanded.Value)
|
||||
content.CancelExpand();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
downloadProgressBar = new BeatmapCardDownloadProgressBar
|
||||
@ -325,16 +313,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ExpandedContent = new Container
|
||||
};
|
||||
c.ExpandedContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
|
||||
Child = new BeatmapCardDifficultyList(beatmapSet)
|
||||
},
|
||||
Expanded = { BindTarget = Expanded }
|
||||
};
|
||||
};
|
||||
c.Expanded.BindTarget = Expanded;
|
||||
});
|
||||
|
||||
if (beatmapSet.HasVideo)
|
||||
leftIconArea.Add(new IconPill(FontAwesome.Solid.Film) { IconSize = new Vector2(20) });
|
||||
|
@ -1,21 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
{
|
||||
public class BeatmapCardExtraInfoRow : HoverHandlingContainer
|
||||
public class BeatmapCardExtraInfoRow : CompositeDrawable
|
||||
{
|
||||
[Resolved(CanBeNull = true)]
|
||||
private BeatmapCardContent? content { get; set; }
|
||||
|
||||
public BeatmapCardExtraInfoRow(APIBeatmapSet beatmapSet)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Child = new FillFlowContainer
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
@ -39,5 +46,19 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
content?.ExpandAfterDelay();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
if (content?.Expanded.Value == false)
|
||||
content.CancelExpand();
|
||||
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user