From 622814d8edfec7357cab3cc9bfccf2088872a24f Mon Sep 17 00:00:00 2001 From: Konkitoman Date: Fri, 11 Aug 2023 18:30:45 +0300 Subject: [PATCH] Now show_tooltip_area_dyn and was_tooltip_open_last_frame was reverted to be like before! --- crates/egui/src/containers/popup.rs | 51 +++++++++-------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/crates/egui/src/containers/popup.rs b/crates/egui/src/containers/popup.rs index c74794466..70b03966a 100644 --- a/crates/egui/src/containers/popup.rs +++ b/crates/egui/src/containers/popup.rs @@ -257,35 +257,20 @@ fn show_tooltip_area_dyn<'c, R>( add_contents: Box R + 'c>, ) -> InnerResponse { use containers::*; - // TODO: Get window pos from winit - let parent_window_pos = (0, 0); - // TODO: Need some how to calculate the ui size before rendering! - ctx.create_viewport_sync( - ViewportBuilder::default() - .with_position(Some(( - window_pos.x as i32 + parent_window_pos.0, - window_pos.y as i32 + parent_window_pos.1, - ))) - .with_decorations(false) - .with_title(format!("Popup Window: {area_id:?}")), - |ctx| { - ctx.viewport_command(ctx.get_viewport_id(), ViewportCommand::CursorHitTest(false)); - Area::new(area_id) - .order(Order::Tooltip) - .fixed_pos(window_pos) - .constrain(true) - .interactable(false) - .drag_bounds(ctx.screen_rect()) - .show(ctx, |ui| { - Frame::popup(&ctx.style()) - .show(ui, |ui| { - ui.set_max_width(ui.spacing().tooltip_width); - add_contents(ui) - }) - .inner + Area::new(area_id) + .order(Order::Tooltip) + .fixed_pos(window_pos) + .constrain(true) + .interactable(false) + .drag_bounds(ctx.screen_rect()) + .show(ctx, |ui| { + Frame::popup(&ctx.style()) + .show(ui, |ui| { + ui.set_max_width(ui.spacing().tooltip_width); + add_contents(ui) }) - }, - ) + .inner + }) } /// Was this popup visible last frame? @@ -296,14 +281,8 @@ pub fn was_tooltip_open_last_frame(ctx: &Context, tooltip_id: Id) -> bool { if *individual_id == tooltip_id { let area_id = common_id.with(count); - let res = ctx.create_viewport_sync( - ViewportBuilder::empty().with_title(format!("Popup Window: {area_id:?}")), - |ctx| { - let layer_id = LayerId::new(Order::Tooltip, area_id); - ctx.memory(|mem| mem.areas.visible_last_frame(&layer_id)) - }, - ); - if res { + let layer_id = LayerId::new(Order::Tooltip, area_id); + if ctx.memory(|mem| mem.areas.visible_last_frame(&layer_id)) { return true; } }