1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

Now tooltip popup will open in a native window if he can, this is for making letting more problem to show to fix them!

This commit is contained in:
Konkitoman
2023-08-10 14:21:57 +03:00
parent 48646ef521
commit 70a5772f8d

View File

@@ -257,20 +257,25 @@ fn show_tooltip_area_dyn<'c, R>(
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>, add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> InnerResponse<R> { ) -> InnerResponse<R> {
use containers::*; use containers::*;
Area::new(area_id) ctx.create_viewport_sync(
.order(Order::Tooltip) ViewportBuilder::default().with_title(format!("Popup Window: {area_id:?}")),
.fixed_pos(window_pos) |ctx| {
.constrain(true) Area::new(area_id)
.interactable(false) .order(Order::Tooltip)
.drag_bounds(ctx.screen_rect()) .fixed_pos(window_pos)
.show(ctx, |ui| { .constrain(true)
Frame::popup(&ctx.style()) .interactable(false)
.show(ui, |ui| { .drag_bounds(ctx.screen_rect())
ui.set_max_width(ui.spacing().tooltip_width); .show(ctx, |ui| {
add_contents(ui) Frame::popup(&ctx.style())
.show(ui, |ui| {
ui.set_max_width(ui.spacing().tooltip_width);
add_contents(ui)
})
.inner
}) })
.inner },
}) )
} }
/// Was this popup visible last frame? /// Was this popup visible last frame?
@@ -280,8 +285,15 @@ pub fn was_tooltip_open_last_frame(ctx: &Context, tooltip_id: Id) -> bool {
for (count, (individual_id, _size)) in &state.individual_ids_and_sizes { for (count, (individual_id, _size)) in &state.individual_ids_and_sizes {
if *individual_id == tooltip_id { if *individual_id == tooltip_id {
let area_id = common_id.with(count); let area_id = common_id.with(count);
let layer_id = LayerId::new(Order::Tooltip, area_id);
if ctx.memory(|mem| mem.areas.visible_last_frame(&layer_id)) { let res = ctx.create_viewport_sync(
ViewportBuilder::default().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 {
return true; return true;
} }
} }