Conversation
native/src/widget/tooltip.rs
Outdated
|
|
||
| fn overlay( | ||
| &mut self, | ||
| layout: Layout<'_>, |
There was a problem hiding this comment.
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.
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.
|
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
155fb9b to
061870a
Compare
061870a to
a19f89d
Compare
There was a problem hiding this comment.
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: