Introduce a new Tooltip element and a with_tooltip helper

This commit is contained in:
Antonio Scandurra 2022-06-01 09:55:25 +02:00
parent 94fc28b29d
commit 982de971fa
5 changed files with 112 additions and 31 deletions

View file

@ -31,7 +31,8 @@ use crate::{
rect::RectF,
vector::{vec2f, Vector2F},
},
json, DebugContext, Event, EventContext, LayoutContext, PaintContext, SizeConstraint,
json, DebugContext, Event, EventContext, LayoutContext, PaintContext, RenderContext,
SizeConstraint, View,
};
use core::panic;
use json::ToJson;
@ -155,6 +156,18 @@ pub trait Element {
{
FlexItem::new(self.boxed()).float()
}
fn with_tooltip<T: View>(
self,
id: usize,
tooltip: ElementBox,
cx: &mut RenderContext<T>,
) -> Tooltip
where
Self: 'static + Sized,
{
Tooltip::new(id, self.boxed(), tooltip, cx)
}
}
pub enum Lifecycle<T: Element> {