1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-03 07:10:04 -04:00

Remove viewport_id and parent_viewport_id from Window::show arguments because can be accessed from Context::get_viewport_id and Context::get_parent_viewport_id

This commit is contained in:
Konkitoman
2023-08-03 19:53:17 +03:00
parent 7f791f4bf9
commit 1448c5047f
30 changed files with 81 additions and 81 deletions

View File

@@ -434,7 +434,7 @@ impl<'open> Window<'open> {
pub fn show<R>( pub fn show<R>(
self, self,
ctx: &Context, ctx: &Context,
add_contents: impl FnOnce(&mut Ui, u64, u64) -> R, add_contents: impl FnOnce(&mut Ui) -> R,
) -> Option<InnerResponse<Option<R>>> { ) -> Option<InnerResponse<Option<R>>> {
self.show_dyn(ctx, Box::new(add_contents)) self.show_dyn(ctx, Box::new(add_contents))
} }
@@ -442,7 +442,7 @@ impl<'open> Window<'open> {
fn show_dyn<'a, R>( fn show_dyn<'a, R>(
self, self,
ctx: &Context, ctx: &Context,
add_contents: Box<dyn FnOnce(&mut Ui, u64, u64) -> R + 'a>, add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'a>,
) -> Option<InnerResponse<Option<R>>> { ) -> Option<InnerResponse<Option<R>>> {
let Window { let Window {
title, title,
@@ -662,17 +662,9 @@ impl<'open> Window<'open> {
} }
if scroll.has_any_bar() { if scroll.has_any_bar() {
scroll scroll.show(ui, |ui| add_contents(ui)).inner
.show(ui, |ui| {
add_contents(
ui,
viewport_id,
parent_viewport_id,
)
})
.inner
} else { } else {
add_contents(ui, viewport_id, parent_viewport_id) add_contents(ui)
} }
}) })
}) })
@@ -854,9 +846,9 @@ impl<'open> Window<'open> {
} }
if scroll.has_any_bar() { if scroll.has_any_bar() {
scroll.show(ui, |ui| add_contents(ui, 0, 0)).inner scroll.show(ui, |ui| add_contents(ui)).inner
} else { } else {
add_contents(ui, 0, 0) add_contents(ui)
} }
}) })
}) })

View File

@@ -417,7 +417,7 @@ impl EguiWindows {
egui::Window::new("🔧 Settings") egui::Window::new("🔧 Settings")
.open(settings) .open(settings)
.vscroll(true) .vscroll(true)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
tmp_ctx.settings_ui(ui); tmp_ctx.settings_ui(ui);
}); });
@@ -425,7 +425,7 @@ impl EguiWindows {
egui::Window::new("🔍 Inspection") egui::Window::new("🔍 Inspection")
.open(inspection) .open(inspection)
.vscroll(true) .vscroll(true)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
tmp_ctx.inspection_ui(ui); tmp_ctx.inspection_ui(ui);
}); });
@@ -433,7 +433,7 @@ impl EguiWindows {
egui::Window::new("📝 Memory") egui::Window::new("📝 Memory")
.open(memory) .open(memory)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
tmp_ctx.memory_ui(ui); tmp_ctx.memory_ui(ui);
}); });
@@ -442,7 +442,7 @@ impl EguiWindows {
.open(output_events) .open(output_events)
.resizable(true) .resizable(true)
.default_width(520.0) .default_width(520.0)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
ui.label( ui.label(
"Recent output events from egui. \ "Recent output events from egui. \
These are emitted when you interact with widgets, or move focus between them with TAB. \ These are emitted when you interact with widgets, or move focus between them with TAB. \

View File

@@ -475,7 +475,7 @@ impl WrapApp {
let dropped_files = self.dropped_files.clone(); let dropped_files = self.dropped_files.clone();
egui::Window::new("Dropped files") egui::Window::new("Dropped files")
.open(&mut open) .open(&mut open)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
let dropped_files = &*dropped_files.read().unwrap(); let dropped_files = &*dropped_files.read().unwrap();
for file in dropped_files { for file in dropped_files {
let mut info = if let Some(path) = &file.path { let mut info = if let Some(path) = &file.path {

View File

@@ -12,7 +12,7 @@ impl super::Demo for About {
egui::Window::new(self.name()) egui::Window::new(self.name())
.default_width(320.0) .default_width(320.0)
.open(open) .open(open)
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
use super::View as _; use super::View as _;
Self::default().ui(ui); Self::default().ui(ui);
}); });

View File

@@ -40,7 +40,7 @@ impl super::Demo for CodeEditor {
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.default_height(500.0) .default_height(500.0)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -84,7 +84,7 @@ impl super::Demo for CodeExample {
.default_size([800.0, 400.0]) .default_size([800.0, 400.0])
.vscroll(false) .vscroll(false)
.hscroll(true) .hscroll(true)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -70,7 +70,7 @@ impl super::Demo for ContextMenus {
.vscroll(false) .vscroll(false)
.resizable(false) .resizable(false)
.open(open) .open(open)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -16,7 +16,7 @@ impl super::Demo for DancingStrings {
.open(open) .open(open)
.default_size(vec2(512.0, 256.0)) .default_size(vec2(512.0, 256.0))
.vscroll(false) .vscroll(false)
.show(ctx, |ui, _, _| Self::default().ui(ui)); .show(ctx, |ui| Self::default().ui(ui));
} }
} }

View File

@@ -202,7 +202,7 @@ impl DemoWindows {
.open(&mut about_is_open) .open(&mut about_is_open)
.resizable(false) .resizable(false)
.collapsible(false) .collapsible(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
let close = close.clone(); let close = close.clone();
clone.data.write().unwrap().about.ui(ui); clone.data.write().unwrap().about.ui(ui);
ui.add_space(12.0); ui.add_space(12.0);

View File

@@ -120,7 +120,7 @@ impl super::Demo for DragAndDropDemo {
.default_size(vec2(256.0, 256.0)) .default_size(vec2(256.0, 256.0))
.vscroll(false) .vscroll(false)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -32,7 +32,7 @@ impl super::Demo for FontBook {
let clone = self.clone(); let clone = self.clone();
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -12,7 +12,7 @@ impl super::Demo for Highlighting {
egui::Window::new(self.name()) egui::Window::new(self.name())
.default_width(320.0) .default_width(320.0)
.open(open) .open(open)
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
use super::View as _; use super::View as _;
Self::default().ui(ui); Self::default().ui(ui);
}); });

View File

@@ -92,7 +92,7 @@ impl super::Demo for LayoutTest {
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -62,7 +62,7 @@ impl Demo for MiscDemoWindow {
.open(open) .open(open)
.vscroll(true) .vscroll(true)
.hscroll(true) .hscroll(true)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -39,7 +39,7 @@ impl super::Demo for MultiTouch {
.open(open) .open(open)
.default_size(vec2(512.0, 512.0)) .default_size(vec2(512.0, 512.0))
.resizable(true) .resizable(true)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -166,7 +166,7 @@ impl super::Demo for PaintBezier {
.vscroll(false) .vscroll(false)
.resizable(false) .resizable(false)
.default_size([300.0, 350.0]) .default_size([300.0, 350.0])
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -94,7 +94,7 @@ impl super::Demo for Painting {
.open(open) .open(open)
.default_size(vec2(512.0, 512.0)) .default_size(vec2(512.0, 512.0))
.vscroll(false) .vscroll(false)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -68,7 +68,7 @@ impl super::Demo for PlotDemo {
.open(open) .open(open)
.default_size(vec2(400.0, 400.0)) .default_size(vec2(400.0, 400.0))
.vscroll(false) .vscroll(false)
.show(ctx, move |ui, _, _| clone.clone().ui(ui)); .show(ctx, move |ui| clone.clone().ui(ui));
} }
} }

View File

@@ -50,7 +50,7 @@ impl super::Demo for Scrolling {
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -63,7 +63,7 @@ impl super::Demo for Sliders {
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -16,7 +16,7 @@ impl super::Demo for StripDemo {
.open(open) .open(open)
.resizable(true) .resizable(true)
.default_width(400.0) .default_width(400.0)
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
use super::View as _; use super::View as _;
Self::default().ui(ui); Self::default().ui(ui);
}); });

View File

@@ -49,7 +49,7 @@ impl super::Demo for TableDemo {
.open(open) .open(open)
.resizable(true) .resizable(true)
.default_width(400.0) .default_width(400.0)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -9,9 +9,7 @@ impl super::Demo for CursorTest {
} }
fn show(&mut self, ctx: &egui::Context, open: &mut bool) { fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()) egui::Window::new(self.name()).open(open).show(ctx, |ui| {
.open(open)
.show(ctx, |ui, _, _| {
use super::View as _; use super::View as _;
Self::default().ui(ui); Self::default().ui(ui);
}); });
@@ -43,9 +41,7 @@ impl super::Demo for IdTest {
} }
fn show(&mut self, ctx: &egui::Context, open: &mut bool) { fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()) egui::Window::new(self.name()).open(open).show(ctx, |ui| {
.open(open)
.show(ctx, |ui, _, _| {
use super::View as _; use super::View as _;
Self::default().ui(ui); Self::default().ui(ui);
}); });
@@ -139,7 +135,7 @@ impl super::Demo for ManualLayoutTest {
egui::Window::new(self.name()) egui::Window::new(self.name())
.resizable(false) .resizable(false)
.open(open) .open(open)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });
@@ -236,7 +232,7 @@ impl super::Demo for TableTest {
let clone = self.clone(); let clone = self.clone();
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });
@@ -357,7 +353,7 @@ impl super::Demo for InputTest {
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });
@@ -438,7 +434,7 @@ impl super::Demo for WindowResizeTest {
Window::new("↔ auto-sized") Window::new("↔ auto-sized")
.open(open) .open(open)
.auto_sized() .auto_sized()
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
ui.label("This window will auto-size based on its contents."); ui.label("This window will auto-size based on its contents.");
ui.heading("Resize this area:"); ui.heading("Resize this area:");
Resize::default().show(ui, |ui| { Resize::default().show(ui, |ui| {
@@ -452,7 +448,7 @@ impl super::Demo for WindowResizeTest {
.vscroll(true) .vscroll(true)
.resizable(true) .resizable(true)
.default_height(300.0) .default_height(300.0)
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
ui.label( ui.label(
"This window is resizable and has a scroll area. You can shrink it to any size.", "This window is resizable and has a scroll area. You can shrink it to any size.",
); );
@@ -465,7 +461,7 @@ impl super::Demo for WindowResizeTest {
.vscroll(false) .vscroll(false)
.resizable(true) .resizable(true)
.default_height(300.0) .default_height(300.0)
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
ui.label("This window is resizable but has no built-in scroll area."); ui.label("This window is resizable but has no built-in scroll area.");
ui.label("However, we have a sub-region with a scroll bar:"); ui.label("However, we have a sub-region with a scroll bar:");
ui.separator(); ui.separator();
@@ -481,7 +477,7 @@ impl super::Demo for WindowResizeTest {
.open(open) .open(open)
.vscroll(false) .vscroll(false)
.resizable(true) .resizable(true)
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
ui.label("This window is resizable but has no scroll area. This means it can only be resized to a size where all the contents is visible."); ui.label("This window is resizable but has no scroll area. This means it can only be resized to a size where all the contents is visible.");
ui.label("egui will not clip the contents of a window, nor add whitespace to it."); ui.label("egui will not clip the contents of a window, nor add whitespace to it.");
ui.separator(); ui.separator();
@@ -495,7 +491,7 @@ impl super::Demo for WindowResizeTest {
.vscroll(false) .vscroll(false)
.resizable(true) .resizable(true)
.default_height(300.0) .default_height(300.0)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
ui.label("Shows how you can fill an area with a widget."); ui.label("Shows how you can fill an area with a widget.");
let mut text = clone.text.write().unwrap(); let mut text = clone.text.write().unwrap();
ui.add_sized(ui.available_size(), TextEdit::multiline(&mut *text)); ui.add_sized(ui.available_size(), TextEdit::multiline(&mut *text));
@@ -506,7 +502,7 @@ impl super::Demo for WindowResizeTest {
.vscroll(false) .vscroll(false)
.resizable(true) .resizable(true)
.default_size([250.0, 150.0]) .default_size([250.0, 150.0])
.show(ctx, |ui, _, _| { .show(ctx, |ui| {
ui.label("This window has empty space that fills up the available space, preventing auto-shrink."); ui.label("This window has empty space that fills up the available space, preventing auto-shrink.");
ui.allocate_space(ui.available_size()); ui.allocate_space(ui.available_size());
}); });

View File

@@ -32,7 +32,7 @@ impl super::Demo for TextEdit {
egui::Window::new(self.name()) egui::Window::new(self.name())
.open(open) .open(open)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -63,7 +63,7 @@ impl super::Demo for WidgetGallery {
.open(open) .open(open)
.resizable(true) .resizable(true)
.default_width(280.0) .default_width(280.0)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
use super::View as _; use super::View as _;
clone.clone().ui(ui); clone.clone().ui(ui);
}); });

View File

@@ -83,7 +83,7 @@ impl super::Demo for WindowOptions {
window = window.anchor(anchor, anchor_offset); window = window.anchor(anchor, anchor_offset);
} }
let clone = self.clone(); let clone = self.clone();
window.show(ctx, move |ui, _, _| { window.show(ctx, move |ui| {
let mut clone = clone.clone(); let mut clone = clone.clone();
clone.ui(ui) clone.ui(ui)
}); });

View File

@@ -14,7 +14,7 @@ impl super::Demo for WindowWithPanels {
.default_height(400.0) .default_height(400.0)
.vscroll(false) .vscroll(false)
.open(open); .open(open);
window.show(ctx, |ui, _, _| Self {}.ui(ui)); window.show(ctx, |ui| Self {}.ui(ui));
} }
} }

View File

@@ -55,7 +55,7 @@ impl eframe::App for MyApp {
egui::Window::new("Do you want to quit?") egui::Window::new("Do you want to quit?")
.collapsible(false) .collapsible(false)
.resizable(false) .resizable(false)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
if ui.button("Cancel").clicked() { if ui.button("Cancel").clicked() {
data.write().unwrap().show_confirmation_dialog = false; data.write().unwrap().show_confirmation_dialog = false;

View File

@@ -53,7 +53,7 @@ impl ThreadState {
let title = self.data.read().unwrap().title.clone(); let title = self.data.read().unwrap().title.clone();
egui::Window::new(title) egui::Window::new(title)
.default_pos(pos) .default_pos(pos)
.show(ctx, move |ui, _, _| { .show(ctx, move |ui| {
let data = &mut *clone.data.write().unwrap(); let data = &mut *clone.data.write().unwrap();
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Your name: "); ui.label("Your name: ");
@@ -147,10 +147,11 @@ impl eframe::App for MyApp {
return; return;
} }
let data = self.data.clone(); let data = self.data.clone();
egui::Window::new("Main thread").show(ctx, move |ui, _, parent_id| { egui::Window::new("Main thread").show(ctx, move |ui| {
if ui.button("Spawn another thread").clicked() { if ui.button("Spawn another thread").clicked() {
data.write().unwrap().spawn_thread(); data.write().unwrap().spawn_thread();
ui.ctx().request_repaint_viewport(parent_id); ui.ctx()
.request_repaint_viewport(ui.ctx().get_parent_viewport_id());
} }
}); });

View File

@@ -61,15 +61,16 @@ fn main() {
} }
egui::CollapsingHeader::new("Show Test1").show(ui, |ui| { egui::CollapsingHeader::new("Show Test1").show(ui, |ui| {
egui::Window::new("Test1").embedded(&mut embedded1).show( egui::Window::new("Test1")
ctx, .embedded(&mut embedded1)
|ui, id, parent_id| { .show(ctx, |ui| {
ui.label(format!("Frame: {}", ui.ctx().frame_nr())); 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("_is_embedded"), true) *data.get_temp_mut_or(Id::new("Test1").with("_is_embedded"), true)
}); });
if ui.checkbox(&mut embedded, "Should embedd?").clicked() { if ui.checkbox(&mut embedded, "Should embedd?").clicked() {
ui.ctx().request_repaint_viewport(parent_id); ui.ctx()
.request_repaint_viewport(ui.ctx().get_parent_viewport_id());
} }
ui.data_mut(|data| { ui.data_mut(|data| {
data.insert_persisted(Id::new("Test1").with("_embedded"), embedded) data.insert_persisted(Id::new("Test1").with("_embedded"), embedded)
@@ -84,8 +85,11 @@ fn main() {
ctx.get_viewport_id() ctx.get_viewport_id()
)); ));
if ui.button("Drag").is_pointer_button_down_on() { if ui.button("Drag").is_pointer_button_down_on() {
if id != parent_id { if ctx.get_viewport_id() != ctx.get_parent_viewport_id() {
ctx.viewport_command(id, egui::window::ViewportCommand::Drag) ctx.viewport_command(
ctx.get_viewport_id(),
egui::window::ViewportCommand::Drag,
)
} else { } else {
ctx.memory_mut(|mem| { ctx.memory_mut(|mem| {
mem.set_dragged_id( mem.set_dragged_id(
@@ -94,17 +98,17 @@ 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| {
ui.label(format!("Frame: {}", ui.ctx().frame_nr())); 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)
}); });
if ui.checkbox(&mut embedded, "Should embedd?").clicked() { if ui.checkbox(&mut embedded, "Should embedd?").clicked() {
ui.ctx().request_repaint_viewport(parent_id); ui.ctx()
.request_repaint_viewport(ui.ctx().get_parent_viewport_id());
} }
ui.data_mut(|data| { ui.data_mut(|data| {
data.insert_persisted(Id::new("Test2").with("_embedded"), embedded) data.insert_persisted(Id::new("Test2").with("_embedded"), embedded)
@@ -119,18 +123,22 @@ fn main() {
)); ));
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(
ctx.get_viewport_id(),
egui::window::ViewportCommand::Drag,
)
} }
}); });
}); });
egui::CollapsingHeader::new("Shout Test3").show(ui, |ui| { egui::CollapsingHeader::new("Shout Test3").show(ui, |ui| {
egui::Window::new("Test3").show(ctx, move |ui, id, parent_id| { egui::Window::new("Test3").show(ctx, move |ui| {
ui.label(format!("Frame: {}", ui.ctx().frame_nr())); 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("Test3").with("_embedded"), true) *data.get_temp_mut_or(Id::new("Test3").with("_embedded"), true)
}); });
if ui.checkbox(&mut embedded, "Should embedd?").clicked() { if ui.checkbox(&mut embedded, "Should embedd?").clicked() {
ui.ctx().request_repaint_viewport(parent_id); ui.ctx()
.request_repaint_viewport(ui.ctx().get_parent_viewport_id());
} }
ui.data_mut(|data| { ui.data_mut(|data| {
data.insert_persisted(Id::new("Test3").with("_embedded"), embedded) data.insert_persisted(Id::new("Test3").with("_embedded"), embedded)
@@ -142,7 +150,10 @@ fn main() {
)); ));
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(
ctx.get_viewport_id(),
egui::window::ViewportCommand::Drag,
)
} }
}); });
}); });