Don't use Parent

This commit is contained in:
Endrik Tombak 2020-04-19 18:29:06 +03:00
parent a8bfd21f3f
commit b57d709d15
2 changed files with 11 additions and 9 deletions

View File

@ -28,8 +28,8 @@ namespace osu.Game.Screens.Select
{
public class BeatmapCarousel : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
private const float bleed_top = FilterControl.HEIGHT;
private const float bleed_bottom = Footer.HEIGHT;
public float BleedTop;
public float BleedBottom;
/// <summary>
/// Triggered when the <see cref="BeatmapSets"/> loaded change and are completely loaded.
@ -373,17 +373,17 @@ namespace osu.Game.Screens.Select
/// the beatmap carousel bleeds into the <see cref="FilterControl"/> and the <see cref="Footer"/>
/// </remarks>
/// </summary>
private float visibleHalfHeight => (DrawHeight + bleed_bottom + bleed_top) / 2;
private float visibleHalfHeight => (DrawHeight + BleedBottom + BleedTop) / 2;
/// <summary>
/// The position of the lower visible bound with respect to the current scroll position.
/// </summary>
private float visibleBottomBound => scroll.Current + DrawHeight + bleed_bottom;
private float visibleBottomBound => scroll.Current + DrawHeight + BleedBottom;
/// <summary>
/// The position of the upper visible bound with respect to the current scroll position.
/// </summary>
private float visibleUpperBound => scroll.Current - bleed_top;
private float visibleUpperBound => scroll.Current - BleedTop;
public void FlushPendingFilterOperations()
{
@ -641,11 +641,11 @@ namespace osu.Game.Screens.Select
case DrawableCarouselBeatmap beatmap:
{
if (beatmap.Item.State.Value == CarouselItemState.Selected)
// scroll position at currentY makes the set panel appear at the very top of the carousel in screen space
// move down by half of parent height (which is the height of the carousel's visible extent, including semi-transparent areas)
// then reapply parent's padding from the top by adding it
// scroll position at currentY makes the set panel appear at the very top of the carousel's screen space
// move down by half of visible height (height of the carousel's visible extent, including semi-transparent areas)
// then reapply the top semi-transparent area (because carousel's screen space starts below it)
// and finally add half of the panel's own height to achieve vertical centering of the panel itself
scrollTarget = currentY - Parent.DrawHeight / 2 + Parent.Padding.Top + beatmap.DrawHeight / 2;
scrollTarget = currentY - visibleHalfHeight + BleedTop + beatmap.DrawHeight / 2;
void performMove(float y, float? startY = null)
{

View File

@ -153,6 +153,8 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
RelativeSizeAxes = Axes.Both,
BleedTop = FilterControl.HEIGHT,
BleedBottom = Footer.HEIGHT,
SelectionChanged = updateSelectedBeatmap,
BeatmapSetsChanged = carouselBeatmapsLoaded,
GetRecommendedBeatmap = recommender.GetRecommendedBeatmap,