mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Share extra row dropdown show/cancel show logic
This commit is contained in:
@ -44,7 +44,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
|
|
||||||
private readonly BeatmapDownloadTracker downloadTracker;
|
private readonly BeatmapDownloadTracker downloadTracker;
|
||||||
|
|
||||||
private BeatmapCardContent content = null!;
|
[Cached]
|
||||||
|
private readonly BeatmapCardContent content;
|
||||||
|
|
||||||
private BeatmapCardThumbnail thumbnail = null!;
|
private BeatmapCardThumbnail thumbnail = null!;
|
||||||
|
|
||||||
@ -72,6 +73,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
this.beatmapSet = beatmapSet;
|
this.beatmapSet = beatmapSet;
|
||||||
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
||||||
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
||||||
|
content = new BeatmapCardContent(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
@ -80,13 +82,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
|
|
||||||
FillFlowContainer leftIconArea;
|
FillFlowContainer leftIconArea = null!;
|
||||||
GridContainer titleContainer;
|
GridContainer titleContainer = null!;
|
||||||
GridContainer artistContainer;
|
GridContainer artistContainer = null!;
|
||||||
|
|
||||||
InternalChild = content = new BeatmapCardContent(height)
|
InternalChild = content.With(c =>
|
||||||
{
|
{
|
||||||
MainContent = new Container
|
c.MainContent = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -281,20 +283,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
ChildrenEnumerable = createStatistics()
|
ChildrenEnumerable = createStatistics()
|
||||||
},
|
},
|
||||||
new BeatmapCardExtraInfoRow(beatmapSet)
|
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
|
downloadProgressBar = new BeatmapCardDownloadProgressBar
|
||||||
@ -311,16 +299,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
ExpandedContent = new Container
|
c.ExpandedContent = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
|
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
|
||||||
Child = new BeatmapCardDifficultyList(beatmapSet)
|
Child = new BeatmapCardDifficultyList(beatmapSet)
|
||||||
},
|
};
|
||||||
Expanded = { BindTarget = Expanded }
|
c.Expanded.BindTarget = Expanded;
|
||||||
};
|
});
|
||||||
|
|
||||||
if (beatmapSet.HasVideo)
|
if (beatmapSet.HasVideo)
|
||||||
leftIconArea.Add(new IconPill(FontAwesome.Solid.Film) { IconSize = new Vector2(20) });
|
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 readonly BeatmapDownloadTracker downloadTracker;
|
||||||
|
|
||||||
private BeatmapCardContent content = null!;
|
[Cached]
|
||||||
|
private readonly BeatmapCardContent content;
|
||||||
|
|
||||||
private BeatmapCardThumbnail thumbnail = null!;
|
private BeatmapCardThumbnail thumbnail = null!;
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
this.beatmapSet = beatmapSet;
|
this.beatmapSet = beatmapSet;
|
||||||
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
favouriteState = new Bindable<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
|
||||||
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
downloadTracker = new BeatmapDownloadTracker(beatmapSet);
|
||||||
|
content = new BeatmapCardContent(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
@ -74,13 +76,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
|
|
||||||
FillFlowContainer leftIconArea;
|
FillFlowContainer leftIconArea = null!;
|
||||||
GridContainer titleContainer;
|
GridContainer titleContainer = null!;
|
||||||
GridContainer artistContainer;
|
GridContainer artistContainer = null!;
|
||||||
|
|
||||||
InternalChild = content = new BeatmapCardContent(height)
|
InternalChild = content.With(c =>
|
||||||
{
|
{
|
||||||
MainContent = new Container
|
c.MainContent = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -295,20 +297,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
new BeatmapCardExtraInfoRow(beatmapSet)
|
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
|
downloadProgressBar = new BeatmapCardDownloadProgressBar
|
||||||
@ -325,16 +313,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
ExpandedContent = new Container
|
c.ExpandedContent = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
|
Padding = new MarginPadding { Horizontal = 10, Vertical = 13 },
|
||||||
Child = new BeatmapCardDifficultyList(beatmapSet)
|
Child = new BeatmapCardDifficultyList(beatmapSet)
|
||||||
},
|
};
|
||||||
Expanded = { BindTarget = Expanded }
|
c.Expanded.BindTarget = Expanded;
|
||||||
};
|
});
|
||||||
|
|
||||||
if (beatmapSet.HasVideo)
|
if (beatmapSet.HasVideo)
|
||||||
leftIconArea.Add(new IconPill(FontAwesome.Solid.Film) { IconSize = new Vector2(20) });
|
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.
|
// 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.
|
// 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;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Drawables.Cards
|
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)
|
public BeatmapCardExtraInfoRow(APIBeatmapSet beatmapSet)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
Child = new FillFlowContainer
|
InternalChild = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user