Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix popovers one-frame-twitching in specific circumstances #6335

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading