mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 23:13:13 -04:00
Now show_tooltip_area_dyn and was_tooltip_open_last_frame was reverted to be like before!
This commit is contained in:
@@ -257,35 +257,20 @@ fn show_tooltip_area_dyn<'c, R>(
|
||||
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
||||
) -> InnerResponse<R> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user