Skip to content

Commit

Permalink
Merge pull request #6335 from bdach/fix-popover-seizure
Browse files Browse the repository at this point in the history
Fix popovers one-frame-twitching in specific circumstances
  • Loading branch information
peppy authored Jul 18, 2024
2 parents 7465990 + 7caa069 commit ff053db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,30 @@ public void TestAllowableAnchors()
});
}

[Test]
public void TestComponentOffScreen()
{
DrawableWithPopover target = null!;

AddStep("add button", () => popoverContainer.Child = target = new DrawableWithPopover
{
Width = 200,
Height = 30,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
RelativePositionAxes = Axes.Both,
Text = "open",
CreateContent = _ => new BasicPopover
{
AllowableAnchors = new[] { Anchor.CentreLeft, Anchor.CentreRight },
Child = new SpriteText { Text = "no twitching!" }
}
});

AddStep("show popover", () => target.ShowPopover());
AddStep("move off screen", () => target.Y = 20);
}

private void createContent(Func<DrawableWithPopover, Popover> creationFunc)
=> AddStep("create content", () =>
{
Expand Down
9 changes: 8 additions & 1 deletion osu.Framework/Graphics/UserInterface/Popover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
using osu.Framework.Extensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osuTK;
using osuTK.Input;

Expand Down Expand Up @@ -100,14 +102,19 @@ internal set

protected override Container<Drawable> Content { get; } = new Container { AutoSizeAxes = Axes.Both };

protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => !Precision.AlmostIntersects(maskingBounds, Content.ScreenSpaceDrawQuad.AABBFloat);

protected Popover()
{
base.AddInternal(BoundingBoxContainer = new Container
{
AutoSizeAxes = Axes.Both,
Children = new[]
{
Arrow = CreateArrow(),
Arrow = CreateArrow().With(arr =>
{
arr.BypassAutoSizeAxes = Axes.Both;
}),
Body = new Container
{
AutoSizeAxes = Axes.Both,
Expand Down

0 comments on commit ff053db

Please sign in to comment.