-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Tooltip widget #465
Tooltip widget #465
Conversation
native/src/widget/tooltip.rs
Outdated
|
||
fn overlay( | ||
&mut self, | ||
layout: Layout<'_>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider extending Widget::overlay
to also provide a cursor_position
. This should allow us to remove the local State
of the Tooltip
.
I'll think about it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did that in b8c5ebc and added a overlay_content_bounds
field. I need it to calculate where to put the tooltip (if tooltip_position
is different than TooltipPosition::FollowCursor
in Tooltip
). There is probably a better way to do it (?), but that's what I do currently.
Edit: Could change overlay_content_bounds
type to just Rectangle
in Widget
and use unwrap_or_else
instead of map
in UserInterface
.
c138eb8
to
19fb8ca
Compare
I would love for this to have an enum OverlayMode {
WithCursor, // current behavior
Top,
Right,
Bottom,
Left,
} Edit: Great job so far! The example program works for me. |
Yep, that sounds like a good idea! I'll try implementing that when I have time. |
19fb8ca
to
b1da5a4
Compare
https://streamable.com/3rsu4r video showcasing this! @clarkmoody |
Oh yeah! |
b8c5ebc
to
e85b538
Compare
e85b538
to
155fb9b
Compare
155fb9b
to
061870a
Compare
061870a
to
a19f89d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this! 🎉
I made some changes to restrict the API to text-only tooltips for the time being. As they are not interactive, we can avoid using the Widget::overlay
method completely and simply use a Clip
primitive in the renderer to produce a new layer.
I have also introduced gap
, padding
, and styling support (same as Container
) and simplified the example a bit.
I think this is ready to go! We can improve it further in future iterations.
This PR implements #460 as described in the issue. I have added a very simple example (definitely needs to be improved) to showcase the widget. I'm not sure about the widget name, since this acts as kind of a Container too. Or maybe the API could be done in a different way? I'd like to hear ideas about this.
Stuff to do: