mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Rename force_embedding -> embed_viewports
This commit is contained in:
@@ -174,7 +174,7 @@ struct ContextImpl {
|
|||||||
viewport_commands: Vec<(ViewportId, ViewportCommand)>,
|
viewport_commands: Vec<(ViewportId, ViewportCommand)>,
|
||||||
|
|
||||||
is_desktop: bool,
|
is_desktop: bool,
|
||||||
force_embedding: bool,
|
embed_viewports: bool,
|
||||||
|
|
||||||
/// Written to during the frame.
|
/// Written to during the frame.
|
||||||
layer_rects_this_frame: ViewportMap<HashMap<LayerId, Vec<(Id, Rect)>>>,
|
layer_rects_this_frame: ViewportMap<HashMap<LayerId, Vec<(Id, Rect)>>>,
|
||||||
@@ -428,7 +428,7 @@ impl Default for Context {
|
|||||||
let s = Self(Arc::new(RwLock::new(ContextImpl::default())));
|
let s = Self(Arc::new(RwLock::new(ContextImpl::default())));
|
||||||
|
|
||||||
s.write(|ctx| {
|
s.write(|ctx| {
|
||||||
ctx.force_embedding = true;
|
ctx.embed_viewports = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
s
|
s
|
||||||
@@ -510,7 +510,7 @@ impl Context {
|
|||||||
let context = Context::default();
|
let context = Context::default();
|
||||||
context.write(|ctx| {
|
context.write(|ctx| {
|
||||||
ctx.is_desktop = desktop;
|
ctx.is_desktop = desktop;
|
||||||
ctx.force_embedding = !desktop;
|
ctx.embed_viewports = !desktop;
|
||||||
});
|
});
|
||||||
context
|
context
|
||||||
}
|
}
|
||||||
@@ -2531,14 +2531,14 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// If this is true no other native window will be created, when a viewport is created!
|
/// If this is true no other native window will be created, when a viewport is created!
|
||||||
pub fn force_embedding(&self) -> bool {
|
pub fn embed_viewports(&self) -> bool {
|
||||||
self.read(|ctx| ctx.force_embedding)
|
self.read(|ctx| ctx.embed_viewports)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this is true no other native window will be created, when a viewport is created!
|
/// 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
|
/// You will always be able to set to true
|
||||||
pub fn set_force_embedding(&self, value: bool) {
|
pub fn set_embed_viewports(&self, value: bool) {
|
||||||
self.write(|ctx| ctx.force_embedding = value || !ctx.is_desktop);
|
self.write(|ctx| ctx.embed_viewports = value || !ctx.is_desktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a command to the current viewport.
|
/// Send a command to the current viewport.
|
||||||
@@ -2568,7 +2568,7 @@ impl Context {
|
|||||||
viewport_builder: ViewportBuilder,
|
viewport_builder: ViewportBuilder,
|
||||||
viewport_ui_cb: impl Fn(&Context) + Send + Sync + 'static,
|
viewport_ui_cb: impl Fn(&Context) + Send + Sync + 'static,
|
||||||
) {
|
) {
|
||||||
if self.force_embedding() {
|
if self.embed_viewports() {
|
||||||
viewport_ui_cb(self);
|
viewport_ui_cb(self);
|
||||||
} else {
|
} else {
|
||||||
self.write(|ctx| {
|
self.write(|ctx| {
|
||||||
@@ -2601,7 +2601,7 @@ impl Context {
|
|||||||
/// The given ui function will be called immediately.
|
/// The given ui function will be called immediately.
|
||||||
/// This can only be called from the main thread.
|
/// 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
|
/// backend does not support sync viewports, the given callback
|
||||||
/// will be called immediately and the function will return.
|
/// will be called immediately and the function will return.
|
||||||
///
|
///
|
||||||
@@ -2621,7 +2621,7 @@ impl Context {
|
|||||||
viewport_builder: ViewportBuilder,
|
viewport_builder: ViewportBuilder,
|
||||||
viewport_ui_cb: impl FnOnce(&Context) -> T,
|
viewport_ui_cb: impl FnOnce(&Context) -> T,
|
||||||
) -> T {
|
) -> T {
|
||||||
if self.force_embedding() {
|
if self.embed_viewports() {
|
||||||
return viewport_ui_cb(self);
|
return viewport_ui_cb(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ impl eframe::App for App {
|
|||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.heading("Root viewport");
|
ui.heading("Root viewport");
|
||||||
{
|
{
|
||||||
let mut force_embedding = ctx.force_embedding();
|
let mut embed_viewports = ctx.embed_viewports();
|
||||||
ui.checkbox(&mut force_embedding, "Force embedding of new viewprts");
|
ui.checkbox(&mut embed_viewports, "Embed all viewports");
|
||||||
ctx.set_force_embedding(force_embedding);
|
ctx.set_embed_viewports(embed_viewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_ui(ui, &self.top);
|
generic_ui(ui, &self.top);
|
||||||
|
|||||||
Reference in New Issue
Block a user