From a85adf59b2ab910ee656927a4cef40a9ce5071fa Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 7 Nov 2023 09:20:31 +0100 Subject: [PATCH] Rename `force_embedding` -> `embed_viewports` --- crates/egui/src/context.rs | 20 ++++++++++---------- examples/test_viewports/src/main.rs | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 68550656d3c..b9ffefaf7f5 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -174,7 +174,7 @@ struct ContextImpl { viewport_commands: Vec<(ViewportId, ViewportCommand)>, is_desktop: bool, - force_embedding: bool, + embed_viewports: bool, /// Written to during the frame. layer_rects_this_frame: ViewportMap>>, @@ -428,7 +428,7 @@ impl Default for Context { let s = Self(Arc::new(RwLock::new(ContextImpl::default()))); s.write(|ctx| { - ctx.force_embedding = true; + ctx.embed_viewports = true; }); s @@ -510,7 +510,7 @@ impl Context { let context = Context::default(); context.write(|ctx| { ctx.is_desktop = desktop; - ctx.force_embedding = !desktop; + ctx.embed_viewports = !desktop; }); context } @@ -2531,14 +2531,14 @@ impl Context { } /// If this is true no other native window will be created, when a viewport is created! - pub fn force_embedding(&self) -> bool { - self.read(|ctx| ctx.force_embedding) + pub fn embed_viewports(&self) -> bool { + self.read(|ctx| ctx.embed_viewports) } /// If this is true no other native window will be created, when a viewport is created! /// You will always be able to set to true - pub fn set_force_embedding(&self, value: bool) { - self.write(|ctx| ctx.force_embedding = value || !ctx.is_desktop); + pub fn set_embed_viewports(&self, value: bool) { + self.write(|ctx| ctx.embed_viewports = value || !ctx.is_desktop); } /// Send a command to the current viewport. @@ -2568,7 +2568,7 @@ impl Context { viewport_builder: ViewportBuilder, viewport_ui_cb: impl Fn(&Context) + Send + Sync + 'static, ) { - if self.force_embedding() { + if self.embed_viewports() { viewport_ui_cb(self); } else { self.write(|ctx| { @@ -2601,7 +2601,7 @@ impl Context { /// The given ui function will be called immediately. /// This can only be called from the main thread. /// - /// If [`Context::force_embedding`] is true, or if the current egui + /// If [`Context::embed_viewports`] is true, or if the current egui /// backend does not support sync viewports, the given callback /// will be called immediately and the function will return. /// @@ -2621,7 +2621,7 @@ impl Context { viewport_builder: ViewportBuilder, viewport_ui_cb: impl FnOnce(&Context) -> T, ) -> T { - if self.force_embedding() { + if self.embed_viewports() { return viewport_ui_cb(self); } diff --git a/examples/test_viewports/src/main.rs b/examples/test_viewports/src/main.rs index 58bbf53f004..f1a723f2a3f 100644 --- a/examples/test_viewports/src/main.rs +++ b/examples/test_viewports/src/main.rs @@ -104,9 +104,9 @@ impl eframe::App for App { egui::CentralPanel::default().show(ctx, |ui| { ui.heading("Root viewport"); { - let mut force_embedding = ctx.force_embedding(); - ui.checkbox(&mut force_embedding, "Force embedding of new viewprts"); - ctx.set_force_embedding(force_embedding); + let mut embed_viewports = ctx.embed_viewports(); + ui.checkbox(&mut embed_viewports, "Embed all viewports"); + ctx.set_embed_viewports(embed_viewports); } generic_ui(ui, &self.top);