mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Don't depend on parent sizing
This commit is contained in:
@ -426,19 +426,18 @@ namespace osu.Game.Screens.Select
|
|||||||
if (!scrollPositionCache.IsValid)
|
if (!scrollPositionCache.IsValid)
|
||||||
updateScrollPosition();
|
updateScrollPosition();
|
||||||
|
|
||||||
// The draw positions of individual sets extend beyond the size of the carousel and into its parent
|
// The draw positions of individual sets extend beyond the size of the carousel and into the footer and header.
|
||||||
// As a result, this should use the Parent's draw height instead.
|
float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT;
|
||||||
float drawHeight = Parent.DrawHeight;
|
|
||||||
|
|
||||||
// Remove all items that should no longer be on-screen
|
// Remove all items that should no longer be on-screen
|
||||||
scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + drawHeight || !p.IsPresent);
|
scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + visibleHeight || !p.IsPresent);
|
||||||
|
|
||||||
// Find index range of all items that should be on-screen
|
// Find index range of all items that should be on-screen
|
||||||
Trace.Assert(Items.Count == yPositions.Count);
|
Trace.Assert(Items.Count == yPositions.Count);
|
||||||
|
|
||||||
int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - Parent.Padding.Top);
|
int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - SongSelect.FILTER_CONTROL_HEIGHT);
|
||||||
if (firstIndex < 0) firstIndex = ~firstIndex;
|
if (firstIndex < 0) firstIndex = ~firstIndex;
|
||||||
int lastIndex = yPositions.BinarySearch(Current + drawHeight + Parent.Padding.Bottom);
|
int lastIndex = yPositions.BinarySearch(Current + visibleHeight + SongSelect.FOOTER_HEIGHT);
|
||||||
if (lastIndex < 0) lastIndex = ~lastIndex;
|
if (lastIndex < 0) lastIndex = ~lastIndex;
|
||||||
|
|
||||||
int notVisibleCount = 0;
|
int notVisibleCount = 0;
|
||||||
@ -490,7 +489,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
// Update externally controlled state of currently visible items
|
// Update externally controlled state of currently visible items
|
||||||
// (e.g. x-offset and opacity).
|
// (e.g. x-offset and opacity).
|
||||||
float halfHeight = drawHeight / 2;
|
float halfHeight = visibleHeight / 2;
|
||||||
foreach (DrawableCarouselItem p in scrollableContent.Children)
|
foreach (DrawableCarouselItem p in scrollableContent.Children)
|
||||||
updateItem(p, halfHeight);
|
updateItem(p, halfHeight);
|
||||||
}
|
}
|
||||||
@ -546,7 +545,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
yPositions.Clear();
|
yPositions.Clear();
|
||||||
|
|
||||||
float currentY = DrawHeight / 2;
|
float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT;
|
||||||
|
float currentY = visibleHeight / 2;
|
||||||
DrawableCarouselBeatmapSet lastSet = null;
|
DrawableCarouselBeatmapSet lastSet = null;
|
||||||
|
|
||||||
scrollTarget = null;
|
scrollTarget = null;
|
||||||
@ -600,7 +600,7 @@ namespace osu.Game.Screens.Select
|
|||||||
currentY += d.DrawHeight + 5;
|
currentY += d.DrawHeight + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentY += DrawHeight / 2;
|
currentY += visibleHeight / 2;
|
||||||
scrollableContent.Height = currentY;
|
scrollableContent.Height = currentY;
|
||||||
|
|
||||||
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
|
if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
|
||||||
@ -641,19 +641,19 @@ namespace osu.Game.Screens.Select
|
|||||||
/// the current scroll position.
|
/// the current scroll position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="p">The item to be updated.</param>
|
/// <param name="p">The item to be updated.</param>
|
||||||
/// <param name="parentHalfHeight">Half the draw height of the carousel container's parent.</param>
|
/// <param name="halfHeight">Half the draw height of the carousel container's parent.</param>
|
||||||
private void updateItem(DrawableCarouselItem p, float parentHalfHeight)
|
private void updateItem(DrawableCarouselItem p, float halfHeight)
|
||||||
{
|
{
|
||||||
var height = p.IsPresent ? p.DrawHeight : 0;
|
var height = p.IsPresent ? p.DrawHeight : 0;
|
||||||
|
|
||||||
// The actual Y position of the item needs to be offset by any potential padding set by the container's parent.
|
// The actual Y position of the item needs to be offset by any potential padding set by the container's parent.
|
||||||
float itemDrawY = p.Position.Y - Current + Parent.Padding.Top + height / 2;
|
float itemDrawY = p.Position.Y + SongSelect.FILTER_CONTROL_HEIGHT - Current + height / 2;
|
||||||
float dist = Math.Abs(1f - itemDrawY / parentHalfHeight);
|
float dist = Math.Abs(1f - itemDrawY / halfHeight);
|
||||||
|
|
||||||
// Setting the origin position serves as an additive position on top of potential
|
// Setting the origin position serves as an additive position on top of potential
|
||||||
// local transformation we may want to apply (e.g. when a item gets selected, we
|
// local transformation we may want to apply (e.g. when a item gets selected, we
|
||||||
// may want to smoothly transform it leftwards.)
|
// may want to smoothly transform it leftwards.)
|
||||||
p.OriginPosition = new Vector2(-offsetX(dist, parentHalfHeight), 0);
|
p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0);
|
||||||
|
|
||||||
// We are applying a multiplicative alpha (which is internally done by nesting an
|
// We are applying a multiplicative alpha (which is internally done by nesting an
|
||||||
// additional container and setting that container's alpha) such that we can
|
// additional container and setting that container's alpha) such that we can
|
||||||
|
@ -14,7 +14,6 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Screens.Select.Filter;
|
using osu.Game.Screens.Select.Filter;
|
||||||
using Container = osu.Framework.Graphics.Containers.Container;
|
using Container = osu.Framework.Graphics.Containers.Container;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
|
@ -62,10 +62,6 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public Footer()
|
public Footer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
Height = HEIGHT;
|
|
||||||
Anchor = Anchor.BottomCentre;
|
|
||||||
Origin = Anchor.BottomCentre;
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
|
@ -43,9 +43,10 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||||
|
|
||||||
|
public const float FILTER_CONTROL_HEIGHT = 100;
|
||||||
|
public const float FOOTER_HEIGHT = 50;
|
||||||
protected const float BACKGROUND_BLUR = 20;
|
protected const float BACKGROUND_BLUR = 20;
|
||||||
private const float left_area_padding = 20;
|
private const float left_area_padding = 20;
|
||||||
private const float filter_control_height = 100;
|
|
||||||
|
|
||||||
public readonly FilterControl FilterControl;
|
public readonly FilterControl FilterControl;
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Size = new Vector2(wedged_container_size.X, 1),
|
Size = new Vector2(wedged_container_size.X, 1),
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Bottom = Footer.HEIGHT,
|
Bottom = FOOTER_HEIGHT,
|
||||||
Top = wedged_container_size.Y + left_area_padding,
|
Top = wedged_container_size.Y + left_area_padding,
|
||||||
Left = left_area_padding,
|
Left = left_area_padding,
|
||||||
Right = left_area_padding * 2,
|
Right = left_area_padding * 2,
|
||||||
@ -153,8 +154,8 @@ namespace osu.Game.Screens.Select
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Top = filter_control_height,
|
Top = FILTER_CONTROL_HEIGHT,
|
||||||
Bottom = Footer.HEIGHT
|
Bottom = FOOTER_HEIGHT
|
||||||
},
|
},
|
||||||
Child = Carousel = new BeatmapCarousel
|
Child = Carousel = new BeatmapCarousel
|
||||||
{
|
{
|
||||||
@ -170,7 +171,7 @@ namespace osu.Game.Screens.Select
|
|||||||
FilterControl = new FilterControl
|
FilterControl = new FilterControl
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = filter_control_height,
|
Height = FILTER_CONTROL_HEIGHT,
|
||||||
FilterChanged = c => Carousel.Filter(c),
|
FilterChanged = c => Carousel.Filter(c),
|
||||||
Background = { Width = 2 },
|
Background = { Width = 2 },
|
||||||
Exit = () =>
|
Exit = () =>
|
||||||
@ -209,7 +210,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Margin = new MarginPadding { Bottom = Footer.HEIGHT },
|
Margin = new MarginPadding { Bottom = FOOTER_HEIGHT },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
BeatmapOptions = new BeatmapOptionsOverlay(),
|
BeatmapOptions = new BeatmapOptionsOverlay(),
|
||||||
@ -221,7 +222,13 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Footer = new Footer()
|
Footer = new Footer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = FOOTER_HEIGHT,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user