From c4bed0e6d29944cb6045267a3a4fdd17cf40bf34 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 25 Jul 2019 15:31:21 +0900 Subject: [PATCH] Resize BeatmapCarousel, update carouselitem logic --- osu.Game/Screens/Select/BeatmapCarousel.cs | 21 +++++++++------- osu.Game/Screens/Select/FilterControl.cs | 6 ----- osu.Game/Screens/Select/SongSelect.cs | 28 +++++++++++++++------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 16354534f4..938ae1c028 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -108,10 +108,12 @@ namespace osu.Game.Screens.Select root = new CarouselRoot(this); Child = new OsuContextMenuContainer { + Masking = false, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Child = scrollableContent = new Container { + Masking = false, RelativeSizeAxes = Axes.X, } }; @@ -424,7 +426,9 @@ namespace osu.Game.Screens.Select if (!scrollPositionCache.IsValid) updateScrollPosition(); - float drawHeight = DrawHeight; + // The draw positions of individual sets extend beyond the size of the carousel and into its parent + // As a result, this should use the Parent's draw height instead. + float drawHeight = Parent.DrawHeight; // Remove all items that should no longer be on-screen scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + drawHeight || !p.IsPresent); @@ -432,9 +436,9 @@ namespace osu.Game.Screens.Select // Find index range of all items that should be on-screen Trace.Assert(Items.Count == yPositions.Count); - int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT); + int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - Parent.Padding.Top); if (firstIndex < 0) firstIndex = ~firstIndex; - int lastIndex = yPositions.BinarySearch(Current + drawHeight); + int lastIndex = yPositions.BinarySearch(Current + drawHeight + Parent.Padding.Bottom); if (lastIndex < 0) lastIndex = ~lastIndex; int notVisibleCount = 0; @@ -637,18 +641,19 @@ namespace osu.Game.Screens.Select /// the current scroll position. /// /// The item to be updated. - /// Half the draw height of the carousel container. - private void updateItem(DrawableCarouselItem p, float halfHeight) + /// Half the draw height of the carousel container's parent. + private void updateItem(DrawableCarouselItem p, float parentHalfHeight) { var height = p.IsPresent ? p.DrawHeight : 0; - float itemDrawY = p.Position.Y - Current + height / 2; - float dist = Math.Abs(1f - itemDrawY / halfHeight); + // 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 dist = Math.Abs(1f - itemDrawY / parentHalfHeight); // 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 // may want to smoothly transform it leftwards.) - p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0); + p.OriginPosition = new Vector2(-offsetX(dist, parentHalfHeight), 0); // 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 diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 57fe15fd99..97ba1cce6b 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -187,11 +187,5 @@ namespace osu.Game.Screens.Select } private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); - - protected override bool OnMouseDown(MouseDownEvent e) => true; - - protected override bool OnMouseMove(MouseMoveEvent e) => true; - - protected override bool OnClick(ClickEvent e) => true; } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 20dbcf2693..011c62f0eb 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -45,6 +45,7 @@ namespace osu.Game.Screens.Select protected const float BACKGROUND_BLUR = 20; private const float left_area_padding = 20; + private const float filter_control_height = 100; public readonly FilterControl FilterControl; @@ -121,7 +122,7 @@ namespace osu.Game.Screens.Select Size = new Vector2(wedged_container_size.X, 1), Padding = new MarginPadding { - Bottom = 50, + Bottom = Footer.HEIGHT, Top = wedged_container_size.Y + left_area_padding, Left = left_area_padding, Right = left_area_padding * 2, @@ -147,20 +148,29 @@ namespace osu.Game.Screens.Select Width = 0.5f, Children = new Drawable[] { - Carousel = new BeatmapCarousel + new Container { - Masking = false, RelativeSizeAxes = Axes.Both, - Size = new Vector2(1 - wedged_container_size.X, 1), - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - SelectionChanged = updateSelectedBeatmap, - BeatmapSetsChanged = carouselBeatmapsLoaded, + Padding = new MarginPadding + { + Top = filter_control_height, + Bottom = Footer.HEIGHT + }, + Child = Carousel = new BeatmapCarousel + { + Masking = false, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(1 - wedged_container_size.X, 1), + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + SelectionChanged = updateSelectedBeatmap, + BeatmapSetsChanged = carouselBeatmapsLoaded, + }, }, FilterControl = new FilterControl { RelativeSizeAxes = Axes.X, - Height = 100, + Height = filter_control_height, FilterChanged = c => Carousel.Filter(c), Background = { Width = 2 }, Exit = () =>