[#2856] Refactor pointer hover#2857
Open
oznogon wants to merge 6 commits intodaid:masterfrom
Open
Conversation
… should capture hover state
- Add GuiContainer::getHoverElement() to return the GUI element being hovered at the mouse position. This is patterend after getClickElement() but uses interceptsPointer() instead of onMouseDown(). - Add GuiContainer::clearHover() to clear active hover effects for an element and its children.
Implement new per-element hover detection on GuiCanvas, which recurses into child elements.
Since we already iterate on elements in drawElements, check and clear hover there if necessary instead of in a separate pass. This changes the arguments for drawElements to pass the hovered element.
...GuiElement subclasses + frequencyCurve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reuse the reverse recursive child iteration of
getClickElement()to manage hover state ingetHoverElement(), instead of applying hover state to all elements in the stack that share the pointer's coordinates. This prevents hover state from bleeding into elements occluded by higher elements.Hover checks and
hover_coordinatesassignment are now made duringGuiContainer::drawElements(). Elements are tagged as intercepting the pointer for hover state with theGuiElement::intercepts_pointerBoolean, with non-interactive elements defaulting tofalseto pass hover state through.Before: Hover state unexpectedly passes through to occluded elements
Screencast_20260414_084527.webm
After: Hover state is caught by the occluding elements
Screencast_20260414_084439.webm
Fixes #2856.