1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 02:22:59 +08:00

Merge pull request #5730 from peppy/fix-song-select-context-menus

Fix song select context menus displaying off-screen
This commit is contained in:
Dan Balasescu 2019-08-16 13:58:42 +09:00 committed by GitHub
commit 9874235a7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 11 deletions

View File

@ -24,7 +24,7 @@ using osu.Game.Screens.Select.Carousel;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class BeatmapCarousel : OsuScrollContainer public class BeatmapCarousel : CompositeDrawable
{ {
private const float bleed_top = FilterControl.HEIGHT; private const float bleed_top = FilterControl.HEIGHT;
private const float bleed_bottom = Footer.HEIGHT; private const float bleed_bottom = Footer.HEIGHT;
@ -61,6 +61,8 @@ namespace osu.Game.Screens.Select
/// </summary> /// </summary>
public bool BeatmapSetsLoaded { get; private set; } public bool BeatmapSetsLoaded { get; private set; }
private readonly OsuScrollContainer scroll;
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>(); private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
public IEnumerable<BeatmapSetInfo> BeatmapSets public IEnumerable<BeatmapSetInfo> BeatmapSets
@ -110,13 +112,17 @@ namespace osu.Game.Screens.Select
public BeatmapCarousel() public BeatmapCarousel()
{ {
root = new CarouselRoot(this); root = new CarouselRoot(this);
Child = new OsuContextMenuContainer InternalChild = new OsuContextMenuContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.Both,
AutoSizeAxes = Axes.Y, Child = scroll = new CarouselScrollContainer
Child = scrollableContent = new Container<DrawableCarouselItem>
{ {
RelativeSizeAxes = Axes.X, Masking = false,
RelativeSizeAxes = Axes.Both,
Child = scrollableContent = new Container<DrawableCarouselItem>
{
RelativeSizeAxes = Axes.X,
}
} }
}; };
} }
@ -127,7 +133,7 @@ namespace osu.Game.Screens.Select
config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm); config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm);
config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled); config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled);
RightClickScrollingEnabled.ValueChanged += enabled => RightMouseScrollbar = enabled.NewValue; RightClickScrollingEnabled.ValueChanged += enabled => scroll.RightMouseScrollbar = enabled.NewValue;
RightClickScrollingEnabled.TriggerChange(); RightClickScrollingEnabled.TriggerChange();
loadBeatmapSets(beatmaps.GetAllUsableBeatmapSetsEnumerable()); loadBeatmapSets(beatmaps.GetAllUsableBeatmapSetsEnumerable());
@ -351,12 +357,12 @@ namespace osu.Game.Screens.Select
/// <summary> /// <summary>
/// The position of the lower visible bound with respect to the current scroll position. /// The position of the lower visible bound with respect to the current scroll position.
/// </summary> /// </summary>
private float visibleBottomBound => Current + DrawHeight + bleed_bottom; private float visibleBottomBound => scroll.Current + DrawHeight + bleed_bottom;
/// <summary> /// <summary>
/// The position of the upper visible bound with respect to the current scroll position. /// The position of the upper visible bound with respect to the current scroll position.
/// </summary> /// </summary>
private float visibleUpperBound => Current - bleed_top; private float visibleUpperBound => scroll.Current - bleed_top;
public void FlushPendingFilterOperations() public void FlushPendingFilterOperations()
{ {
@ -628,7 +634,7 @@ namespace osu.Game.Screens.Select
private void updateScrollPosition() private void updateScrollPosition()
{ {
if (scrollTarget != null) ScrollTo(scrollTarget.Value); if (scrollTarget != null) scroll.ScrollTo(scrollTarget.Value);
scrollPositionCache.Validate(); scrollPositionCache.Validate();
} }
@ -688,5 +694,35 @@ namespace osu.Game.Screens.Select
base.PerformSelection(); base.PerformSelection();
} }
} }
private class CarouselScrollContainer : OsuScrollContainer
{
private bool rightMouseScrollBlocked;
protected override bool OnMouseDown(MouseDownEvent e)
{
if (e.Button == MouseButton.Right)
{
// we need to block right click absolute scrolling when hovering a carousel item so context menus can display.
// this can be reconsidered when we have an alternative to right click scrolling.
if (GetContainingInputManager().HoveredDrawables.OfType<DrawableCarouselItem>().Any())
{
rightMouseScrollBlocked = true;
return false;
}
}
rightMouseScrollBlocked = false;
return base.OnMouseDown(e);
}
protected override bool OnDragStart(DragStartEvent e)
{
if (rightMouseScrollBlocked)
return false;
return base.OnDragStart(e);
}
}
} }
} }

View File

@ -157,7 +157,6 @@ namespace osu.Game.Screens.Select
}, },
Child = Carousel = new BeatmapCarousel Child = Carousel = new BeatmapCarousel
{ {
Masking = false,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Size = new Vector2(1 - wedged_container_size.X, 1), Size = new Vector2(1 - wedged_container_size.X, 1),
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,