DRAFT: Popups being clipped bug fix - #989
Draft
rswinkle wants to merge 6 commits into
Draft
Conversation
…ent width handling
...for determining whether a popup will fit as a dropdown vs needing to drop "up". Additionally, pin the direction so a popup menu won't flip back and forth as you expand/collapse a tree inside of it.
When user given height is less than content height, use that (will have a scrollbar) so we don't flip unnecessarily Opposite of Menu example of larger than needed requested height, in which case we use real content height to determine whether to flip
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.
This was an idea I had months ago to deal with tooltips going off screen. Basically we add a member to the context to track the window size (requires changes to backends but everything is backward compatible so the backends that I didn't update get the old behavior). With that being updated by the backend, most things follow a relatively obvious sane policy (drop downs flip upward if they don't fit below, menus align with the right edge if they get clipped on the right, scrollbars get introduced only if there's not enough space total, user popups (nk_popup_begin) are fixed etc.) but tooltips are actually the hardest to decide. Right now they behave non-symmetrically.
First place it according to origin and offset. If it overflows on the right/bottom align the cursor with the right/bottom of the tooltip unless that would cause overflow on the left/top. If it's still overflowing the right/bottom, slide it left/up till it lines up with the edge. If x/y < 0 then slide right/down to x/y = 0. So if there's insufficient space for the tooltip, it will always clip the right/bottom rather than the left/top.
This asymmetry is easiest to see using the "Hover for magic" orbiting tooltip:
tooltip_asymmetry.mp4
Honestly it's probably fine as it is, especially since the alternative is losing the content entirely to clipping, but there are arguments to be made for many other policies, symmetric, trying more to take into account the original origin specification, etc. I think this is probably the simplest policy that makes sense though.
Here's a longer video demonstrating the state of everything. I think I covered every type of popup and multiple edges for many, if not insufficient space for all of them:
popup_clipping_bug_fix.mp4