Enable panel switching

This commit is contained in:
Conrad Irwin 2023-11-15 21:01:00 -07:00
parent 7f70712dac
commit 0a9fb3978b
15 changed files with 203 additions and 131 deletions

View file

@ -408,13 +408,12 @@ pub trait StatefulInteractiveComponent<V: 'static, E: Element<V>>: InteractiveCo
self
}
fn tooltip<W>(
fn tooltip(
mut self,
build_tooltip: impl Fn(&mut V, &mut ViewContext<V>) -> View<W> + 'static,
build_tooltip: impl Fn(&mut V, &mut ViewContext<V>) -> AnyView + 'static,
) -> Self
where
Self: Sized,
W: 'static + Render,
{
debug_assert!(
self.interactivity().tooltip_builder.is_none(),

View file

@ -1092,8 +1092,11 @@ impl<'a> WindowContext<'a> {
} else if let Some(active_tooltip) = self.app.active_tooltip.take() {
self.with_z_index(1, |cx| {
cx.with_element_offset(active_tooltip.cursor_offset, |cx| {
let available_space =
size(AvailableSpace::MinContent, AvailableSpace::MinContent);
let available_space = Size {
width: cx.window.viewport_size.width - active_tooltip.cursor_offset.x,
height: cx.window.viewport_size.height - active_tooltip.cursor_offset.y,
}
.map(Into::into);
active_tooltip.view.draw(available_space, cx);
});
});