mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 15:13:12 -04:00
Remove Context::is_desktop
This commit is contained in:
@@ -338,11 +338,12 @@ impl EpiIntegration {
|
||||
app_name: &str,
|
||||
native_options: &crate::NativeOptions,
|
||||
storage: Option<Box<dyn epi::Storage>>,
|
||||
desktop: bool,
|
||||
is_desktop: bool,
|
||||
#[cfg(feature = "glow")] gl: Option<std::sync::Arc<glow::Context>>,
|
||||
#[cfg(feature = "wgpu")] wgpu_render_state: Option<egui_wgpu::RenderState>,
|
||||
) -> Self {
|
||||
let egui_ctx = egui::Context::new(desktop);
|
||||
let egui_ctx = egui::Context::default();
|
||||
egui_ctx.set_embed_viewports(!is_desktop);
|
||||
|
||||
let memory = load_egui_memory(storage.as_deref()).unwrap_or_default();
|
||||
egui_ctx.memory_mut(|mem| *mem = memory);
|
||||
|
||||
@@ -173,7 +173,6 @@ struct ContextImpl {
|
||||
viewports: ViewportMap<Viewport>,
|
||||
viewport_commands: Vec<(ViewportId, ViewportCommand)>,
|
||||
|
||||
is_desktop: bool,
|
||||
embed_viewports: bool,
|
||||
|
||||
/// Written to during the frame.
|
||||
@@ -504,16 +503,6 @@ impl Context {
|
||||
|
||||
self.write(|ctx| ctx.begin_frame_mut(new_input, id_pair));
|
||||
}
|
||||
|
||||
/// Create a new Context and specify if is desktop
|
||||
pub fn new(desktop: bool) -> Context {
|
||||
let context = Context::default();
|
||||
context.write(|ctx| {
|
||||
ctx.is_desktop = desktop;
|
||||
ctx.embed_viewports = !desktop;
|
||||
});
|
||||
context
|
||||
}
|
||||
}
|
||||
|
||||
/// ## Borrows parts of [`Context`]
|
||||
@@ -2525,20 +2514,22 @@ impl Context {
|
||||
});
|
||||
}
|
||||
|
||||
/// This will tell you if is possible to open a native window
|
||||
pub fn is_desktop(&self) -> bool {
|
||||
self.read(|ctx| ctx.is_desktop)
|
||||
}
|
||||
|
||||
/// If this is true no other native window will be created, when a viewport is created!
|
||||
/// If `true`, [`Self::create_viewport_async`] and [`Self::create_viewport_sync`] will
|
||||
/// embed the new viewports as [`egui::Window`]s instead of spawning a new native window.
|
||||
///
|
||||
/// `eframe` sets this to `false` on supported platforms,
|
||||
/// but the default value is `true`.
|
||||
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
|
||||
/// If `true`, [`Self::create_viewport_async`] and [`Self::create_viewport_sync`] will
|
||||
/// embed the new viewports as [`egui::Window`]s instead of spawning a new native window.
|
||||
///
|
||||
/// `eframe` sets this to `false` on supported platforms,
|
||||
/// but the default value is `true`.
|
||||
pub fn set_embed_viewports(&self, value: bool) {
|
||||
self.write(|ctx| ctx.embed_viewports = value || !ctx.is_desktop);
|
||||
self.write(|ctx| ctx.embed_viewports = value);
|
||||
}
|
||||
|
||||
/// Send a command to the current viewport.
|
||||
|
||||
Reference in New Issue
Block a user