Simplify usage of tooltip

Now you simply specify a text, an action and a style and GPUI will
take of rendering it properly. This is simpler compared to always
providing a custom element and should make tooltip more consistent
across the UI.
This commit is contained in:
Antonio Scandurra 2022-06-02 09:12:50 +02:00
parent 9ca9f63046
commit cc028cca78
5 changed files with 99 additions and 35 deletions

View file

@ -31,7 +31,7 @@ use crate::{
rect::RectF,
vector::{vec2f, Vector2F},
},
json, DebugContext, Event, EventContext, LayoutContext, PaintContext, RenderContext,
json, Action, DebugContext, Event, EventContext, LayoutContext, PaintContext, RenderContext,
SizeConstraint, View,
};
use core::panic;
@ -160,13 +160,15 @@ pub trait Element {
fn with_tooltip<T: View>(
self,
id: usize,
tooltip: ElementBox,
text: String,
action: Option<Box<dyn Action>>,
style: TooltipStyle,
cx: &mut RenderContext<T>,
) -> Tooltip
where
Self: 'static + Sized,
{
Tooltip::new(id, self.boxed(), tooltip, cx)
Tooltip::new(id, text, action, style, self.boxed(), cx)
}
}