Split off thumbnail to separate component

This commit is contained in:
Bartłomiej Dach 2021-10-23 17:59:52 +02:00
parent fe9a03c032
commit 4011da033b
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 63 additions and 17 deletions

View File

@ -23,7 +23,6 @@ using osu.Game.Overlays.BeatmapSet;
using osuTK;
using osu.Game.Overlays.BeatmapListing.Panels;
using osu.Game.Resources.Localisation.Web;
using osuTK.Graphics;
using DownloadButton = osu.Game.Beatmaps.Drawables.Cards.Buttons.DownloadButton;
namespace osu.Game.Beatmaps.Drawables.Cards
@ -42,7 +41,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
private readonly BeatmapDownloadTracker downloadTracker;
private UpdateableOnlineBeatmapSetCover leftCover;
private BeatmapCardThumbnail thumbnail;
private FillFlowContainer leftIconArea;
private Container rightAreaBackground;
@ -98,24 +97,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards
Colour = Colour4.White
},
},
new Container
thumbnail = new BeatmapCardThumbnail(beatmapSet)
{
Name = @"Left (icon) area",
Size = new Vector2(height),
Children = new Drawable[]
Child = leftIconArea = new FillFlowContainer
{
leftCover = new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List)
{
RelativeSizeAxes = Axes.Both,
OnlineInfo = beatmapSet
},
leftIconArea = new FillFlowContainer
{
Margin = new MarginPadding(5),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(1)
}
Margin = new MarginPadding(5),
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(1)
}
},
new Container
@ -395,10 +386,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards
if (IsHovered)
targetWidth = targetWidth - icon_area_width + corner_radius;
thumbnail.Dimmed.Value = IsHovered;
mainContent.ResizeWidthTo(targetWidth, TRANSITION_DURATION, Easing.OutQuint);
mainContentBackground.Dimmed.Value = IsHovered;
leftCover.FadeColour(IsHovered ? OsuColour.Gray(0.2f) : Color4.White, TRANSITION_DURATION, Easing.OutQuint);
statisticsContainer.FadeTo(IsHovered ? 1 : 0, TRANSITION_DURATION, Easing.OutQuint);
rightAreaBackground.FadeColour(downloadTracker.State.Value == DownloadState.LocallyAvailable ? colours.Lime0 : colourProvider.Background3, TRANSITION_DURATION, Easing.OutQuint);

View File

@ -0,0 +1,54 @@
// 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.
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osuTK.Graphics;
namespace osu.Game.Beatmaps.Drawables.Cards
{
public class BeatmapCardThumbnail : Container
{
public BindableBool Dimmed { get; } = new BindableBool();
private readonly APIBeatmapSet beatmapSetInfo;
private readonly UpdateableOnlineBeatmapSetCover cover;
private readonly Container content;
protected override Container<Drawable> Content => content;
public BeatmapCardThumbnail(APIBeatmapSet beatmapSetInfo)
{
this.beatmapSetInfo = beatmapSetInfo;
InternalChildren = new Drawable[]
{
cover = new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List)
{
RelativeSizeAxes = Axes.Both,
OnlineInfo = beatmapSetInfo
},
content = new Container
{
RelativeSizeAxes = Axes.Both
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
Dimmed.BindValueChanged(_ => updateState(), true);
FinishTransforms(true);
}
private void updateState()
{
cover.FadeColour(Dimmed.Value ? OsuColour.Gray(0.2f) : Color4.White, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
}
}
}