mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
refactor: move some code around to make place for new Layout
This commit is contained in:
27
emigui/src/containers/popup.rs
Normal file
27
emigui/src/containers/popup.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::*;
|
||||
|
||||
pub fn show_tooltip(ctx: &Arc<Context>, add_contents: impl FnOnce(&mut Ui)) {
|
||||
if let Some(mouse_pos) = ctx.input().mouse_pos {
|
||||
// TODO: default size
|
||||
let id = Id::tooltip();
|
||||
let window_pos = mouse_pos + vec2(16.0, 16.0);
|
||||
show_popup(ctx, id, window_pos, add_contents);
|
||||
}
|
||||
}
|
||||
|
||||
/// Show a pop-over window
|
||||
pub fn show_popup(
|
||||
ctx: &Arc<Context>,
|
||||
id: Id,
|
||||
window_pos: Pos2,
|
||||
add_contents: impl FnOnce(&mut Ui),
|
||||
) -> InteractInfo {
|
||||
use containers::*;
|
||||
Area::new(id)
|
||||
.order(Order::Foreground)
|
||||
.fixed_pos(window_pos)
|
||||
.interactable(false)
|
||||
.show(ctx, |ui| Frame::popup(&ctx.style()).show(ui, add_contents))
|
||||
}
|
||||
Reference in New Issue
Block a user