1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

* Fix posibile deadlock when sending a viewport command from a sync viewport

* Improve viewports example
This commit is contained in:
Konkitoman
2023-09-06 16:30:20 +03:00
parent b1189c14ae
commit fb80880ff8
3 changed files with 59 additions and 21 deletions

View File

@@ -86,6 +86,17 @@ impl eframe::App for App {
if ui.button("Add").clicked() {
*state += 1;
}
if ui.button("Set parent pos {0, 0}").clicked() {
let ctx = ui.ctx().clone();
let parent_id = ctx.get_parent_viewport_id();
ctx.viewport_command_for(
parent_id,
egui::ViewportCommand::OuterPosition(
egui::pos2(0.0, 0.0),
),
);
}
};
show_as_popup(
@@ -111,6 +122,17 @@ impl eframe::App for App {
if ui.button("Add").clicked() {
*state += 1;
}
if ui.button("Set parent pos {0, 0}").clicked() {
let ctx = ui.ctx().clone();
let parent_id = ctx.get_parent_viewport_id();
ctx.viewport_command_for(
parent_id,
egui::ViewportCommand::OuterPosition(
egui::pos2(0.0, 0.0),
),
);
}
};
show_as_popup(
@@ -160,6 +182,17 @@ impl eframe::App for App {
if ui.button("Add").clicked() {
*state += 1;
}
if ui.button("Set parent pos {0, 0}").clicked() {
let ctx = ui.ctx().clone();
let parent_id = ctx.get_parent_viewport_id();
ctx.viewport_command_for(
parent_id,
egui::ViewportCommand::OuterPosition(
egui::pos2(0.0, 0.0),
),
);
}
};
show_as_popup(
@@ -185,6 +218,17 @@ impl eframe::App for App {
if ui.button("Add").clicked() {
*state += 1;
}
if ui.button("Set parent pos {0, 0}").clicked() {
let ctx = ui.ctx().clone();
let parent_id = ctx.get_parent_viewport_id();
ctx.viewport_command_for(
parent_id,
egui::ViewportCommand::OuterPosition(
egui::pos2(0.0, 0.0),
),
);
}
};
show_as_popup(