mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Update example for debuging purposes
There is a bug that some how makes the windows to be liked! Winit events look fine but some thing i think is happening with area id or some thing
This commit is contained in:
@@ -12,12 +12,14 @@ fn main() {
|
|||||||
NativeOptions::default(),
|
NativeOptions::default(),
|
||||||
move |ctx, _frame| {
|
move |ctx, _frame| {
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
|
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
||||||
let mut is_desktop = ctx.is_desktop();
|
let mut is_desktop = ctx.is_desktop();
|
||||||
ui.checkbox(&mut is_desktop, "Is Desktop");
|
ui.checkbox(&mut is_desktop, "Is Desktop");
|
||||||
ctx.set_desktop(is_desktop);
|
ctx.set_desktop(is_desktop);
|
||||||
|
|
||||||
egui::CollapsingHeader::new("Show Test1").show(ui, |ui| {
|
egui::CollapsingHeader::new("Show Test1").show(ui, |ui| {
|
||||||
egui::Window::new("Test1").show(ctx, move |ui, id, parent_id| {
|
egui::Window::new("Test1").show(ctx, move |ui, id, parent_id| {
|
||||||
|
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
||||||
let mut embedded = ui.data_mut(|data| {
|
let mut embedded = ui.data_mut(|data| {
|
||||||
*data.get_temp_mut_or(Id::new("Test1").with("_embedded"), true)
|
*data.get_temp_mut_or(Id::new("Test1").with("_embedded"), true)
|
||||||
});
|
});
|
||||||
@@ -46,6 +48,7 @@ fn main() {
|
|||||||
});
|
});
|
||||||
egui::CollapsingHeader::new("Shout Test2").show(ui, |ui| {
|
egui::CollapsingHeader::new("Shout Test2").show(ui, |ui| {
|
||||||
egui::Window::new("Test2").show(ctx, move |ui, id, parent_id| {
|
egui::Window::new("Test2").show(ctx, move |ui, id, parent_id| {
|
||||||
|
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
||||||
let mut embedded = ui.data_mut(|data| {
|
let mut embedded = ui.data_mut(|data| {
|
||||||
*data.get_temp_mut_or(Id::new("Test2").with("_embedded"), true)
|
*data.get_temp_mut_or(Id::new("Test2").with("_embedded"), true)
|
||||||
});
|
});
|
||||||
@@ -61,6 +64,29 @@ fn main() {
|
|||||||
ctx.current_rendering_viewport()
|
ctx.current_rendering_viewport()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if ui.button("Drag").is_pointer_button_down_on() {
|
||||||
|
ctx.viewport_command(id, egui::window::ViewportCommand::Drag)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
egui::CollapsingHeader::new("Shout Test3").show(ui, |ui| {
|
||||||
|
egui::Window::new("Test3").show(ctx, move |ui, id, parent_id| {
|
||||||
|
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
||||||
|
let mut embedded = ui.data_mut(|data| {
|
||||||
|
*data.get_temp_mut_or(Id::new("Test3").with("_embedded"), true)
|
||||||
|
});
|
||||||
|
if ui.checkbox(&mut embedded, "Should embedd?").clicked() {
|
||||||
|
ui.ctx().request_repaint_viewport(parent_id);
|
||||||
|
}
|
||||||
|
ui.data_mut(|data| {
|
||||||
|
data.insert_persisted(Id::new("Test3").with("_embedded"), embedded)
|
||||||
|
});
|
||||||
|
let ctx = ui.ctx().clone();
|
||||||
|
ui.label(format!(
|
||||||
|
"Current rendering window: {}",
|
||||||
|
ctx.current_rendering_viewport()
|
||||||
|
));
|
||||||
|
|
||||||
if ui.button("Drag").is_pointer_button_down_on() {
|
if ui.button("Drag").is_pointer_button_down_on() {
|
||||||
ctx.viewport_command(id, egui::window::ViewportCommand::Drag)
|
ctx.viewport_command(id, egui::window::ViewportCommand::Drag)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user