Skip to content

Update InputCapturingStateHover calculation to support collapsed panels #35

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

Merged
merged 6 commits into from
May 2, 2025

Conversation

mikenye
Copy link
Contributor

@mikenye mikenye commented May 2, 2025

Resolves #34 by updating InputCapturingStateHover calculation to support collapsed panels.


This PR fixes an issue where InputCapturingStateHover could still be returned for a collapsed window.

Problem

When a debug UI window is collapsed, the full layout.Bounds was still being checked for pointer containment. This meant that even when only the title bar was visible, InputCapturingStateHover would be set if the pointer was anywhere in the (now-hidden) body area.

Fix

  • When a container is collapsed, we now calculate a collapsedBounds rectangle that excludes the body area by subtracting BodyBounds.Dy() from the bottom of the window.
  • We use this collapsedBounds to determine whether the pointer is hovering over a collapsed window’s visible area (i.e. just the title bar).
  • This ensures InputCapturingStateHover reflects only what is actually visible.

Copy link
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

mikenye added 2 commits May 2, 2025 10:59
 - Make code "Hajime-spec" :-)
 - Make code "Hajime-spec" :-)
context.go Outdated
@@ -96,6 +96,10 @@ func (c *Context) update(f func(ctx *Context) error) (inputCapturingState InputC
// Check whether the cursor is on any of the root containers.
pt := c.pointingPosition()
for _, cnt := range c.rootContainers {
bounds := cnt.layout.Bounds
if cnt.collapsed {
bounds.Max.Y -= cnt.layout.BodyBounds.Dy()
Copy link
Member

@hajimehoshi hajimehoshi May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds.Max.Y = cnt.layout.BodyBounds.Min.Y

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 1733713

Copy link
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@hajimehoshi hajimehoshi merged commit 6ec5151 into ebitengine:main May 2, 2025
6 checks passed
@mikenye mikenye deleted the fix_issue_34 branch May 2, 2025 03:18
hajimehoshi pushed a commit that referenced this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debugui: Incorrect InputCapturingState when panel is collapsed
2 participants