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

Drag and Drop cursor overlaps tooltip #1739

Closed
sherief opened this issue Apr 10, 2018 · 4 comments
Closed

Drag and Drop cursor overlaps tooltip #1739

sherief opened this issue Apr 10, 2018 · 4 comments
Labels

Comments

@sherief
Copy link

sherief commented Apr 10, 2018

See attached picture. I think the tooltip should be offset by the cursor rect so that the mouse cursor doesn't make the first letter or two difficult to read.
capture

@ocornut
Copy link
Owner

ocornut commented Apr 10, 2018

There's code in BeginDragDropSource() that explicitly override the tooltip position:

SetNextWindowPos(g.IO.MousePos);
[...]
BeginTooltip();

I think at the time I felt it looked really strange to have the tooltip offset by the regular amount (you can try by commenting out the call to SetNextWindowPos(), let me know?).

Note that you may call BeginDragDropSource() with ImGuiDragDropFlags_SourceNoPreviewTooltip and call BeginToolTip yourself, but I'd be interested in figuring out the better default behavior.

@sherief
Copy link
Author

sherief commented Apr 10, 2018

Thanks for the pointer! I tried offsetting the tooltip by the mouse cursor size and it looks nice enough, I vote for it as a default:

            g.IO.Fonts->GetMouseCursorTexData(g.MouseCursor, &offset, &size, &uv[0], &uv[2]);
            SetNextWindowPos(g.IO.MousePos + size);

capture

@ocornut ocornut added the drag drop drag and drop label Apr 11, 2018
ocornut added a commit that referenced this issue May 23, 2018
…s off the mouse cursor, but also closer to it than regular tooltips, and not clamped by viewport. (#1739)
@ocornut
Copy link
Owner

ocornut commented May 23, 2018

@sherief : I have pushed a change like that now.

I'm intentionally not using GetMouseCursorTexData() for two reasons now:

  • there's no guarantee that the user is using the software mouse cursor (in fact it is fairly unlikely right now)
  • in case the mouse cursor changes, we don't want the tooltip to be moved

I think using an hard-coded offset + scale satisfy this without overreaching (it's arguably under-engineered but not problematic at the moment).

@ocornut ocornut closed this as completed May 23, 2018
@sherief
Copy link
Author

sherief commented May 24, 2018

You're right, I like your solution better!

ocornut added a commit that referenced this issue May 28, 2018
…oltip to avoid discontinuity where dynamically swapping tooltip at the target site. Made drag source tooltip override previous tooltip if any. (#1739, #143).
ocornut added a commit that referenced this issue May 28, 2018
…emantic (drag and drop tooltip doesn't get clipped within display boundaries). Revert part of 3218666. (#1739, #143).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants