From a52d38312cd00b2739a9d954dbeeb2ad6fd44b57 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 6 Nov 2023 19:19:37 +0100 Subject: [PATCH] MAIN -> ROOT --- crates/eframe/src/native/epi_integration.rs | 6 +- crates/eframe/src/native/run.rs | 66 ++++++++++----------- crates/eframe/src/web/app_runner.rs | 4 +- crates/egui/src/context.rs | 38 ++++++------ crates/egui/src/lib.rs | 8 +-- crates/egui/src/viewport.rs | 18 +++--- crates/egui_demo_lib/benches/benchmark.rs | 16 ++--- crates/egui_demo_lib/src/lib.rs | 8 +-- crates/egui_glow/src/winit.rs | 6 +- examples/viewports/src/main.rs | 4 +- 10 files changed, 89 insertions(+), 85 deletions(-) diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 6803b9b2b3e..cca0f999f1a 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -87,7 +87,7 @@ pub fn window_builder( .. } = native_options; - let mut window_builder = egui::ViewportBuilder::new(ViewportId::MAIN) + let mut window_builder = egui::ViewportBuilder::new(ViewportId::ROOT) .with_title(title) .with_close_button(true) // The default for all other viewports is `false`! .with_decorations(*decorated) @@ -425,7 +425,7 @@ impl EpiIntegration { let saved_memory: egui::Memory = self.egui_ctx.memory(|mem| mem.clone()); self.egui_ctx .memory_mut(|mem| mem.set_everything_is_visible(true)); - let full_output = self.update(app, window, egui_winit, &None, ViewportIdPair::MAIN); + let full_output = self.update(app, window, egui_winit, &None, ViewportIdPair::ROOT); self.pending_full_output.append(full_output); // Handle it next frame self.egui_ctx.memory_mut(|mem| *mem = saved_memory); // We don't want to remember that windows were huge. self.egui_ctx.clear_animations(); @@ -450,7 +450,7 @@ impl EpiIntegration { match event { WindowEvent::CloseRequested => { log::debug!("Received WindowEvent::CloseRequested"); - self.close = app.on_close_event() && viewport_id == ViewportId::MAIN; + self.close = app.on_close_event() && viewport_id == ViewportId::ROOT; log::debug!("App::on_close_event returned {}", self.close); } WindowEvent::Destroyed => { diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 5f747b32318..1e39a7f55d9 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -441,7 +441,7 @@ fn run_and_exit(event_loop: EventLoop, mut winit_app: impl WinitApp + // WaitUntil seems to not work on iOS #[cfg(target_os = "ios")] winit_app - .get_window_winit_id(ViewportId::MAIN) + .get_window_winit_id(ViewportId::ROOT) .map(|window_id| { winit_app .window(window_id) @@ -662,24 +662,24 @@ mod glow_integration { let mut viewport_maps = HashMap::default(); let mut window_maps = ViewportMap::default(); if let Some(window) = &window { - viewport_maps.insert(window.id(), ViewportId::MAIN); - window_maps.insert(ViewportId::MAIN, window.id()); + viewport_maps.insert(window.id(), ViewportId::ROOT); + window_maps.insert(ViewportId::ROOT, window.id()); } let mut windows = ViewportMap::default(); windows.insert( - ViewportId::MAIN, + ViewportId::ROOT, Rc::new(RefCell::new(Viewport { gl_surface: None, window: window.map(|w| Rc::new(RefCell::new(w))), egui_winit: None, viewport_ui_cb: None, - id_pair: ViewportIdPair::MAIN, + id_pair: ViewportIdPair::ROOT, })), ); let mut builders = ViewportMap::default(); - builders.insert(ViewportId::MAIN, window_builder); + builders.insert(ViewportId::ROOT, window_builder); // the fun part with opengl gl is that we never know whether there is an error. the context creation might have failed, but // it could keep working until we try to make surface current or swap buffers or something else. future glutin improvements might @@ -892,7 +892,7 @@ mod glow_integration { native_options, running: Rc::new(RefCell::new(None)), app_creator: Some(app_creator), - is_focused: Rc::new(RefCell::new(Some(ViewportId::MAIN))), + is_focused: Rc::new(RefCell::new(Some(ViewportId::ROOT))), } } @@ -914,7 +914,7 @@ mod glow_integration { }; glutin_window_context.on_resume(event_loop)?; - if let Some(window) = &glutin_window_context.viewports.get(&ViewportId::MAIN) { + if let Some(window) = &glutin_window_context.viewports.get(&ViewportId::ROOT) { let window = window.borrow(); if let Some(window) = &window.window { epi_integration::apply_native_options_to_window( @@ -960,7 +960,7 @@ mod glow_integration { .unwrap_or_else(|err| panic!("An OpenGL error occurred: {err}\n")); glutin_ctx.max_texture_side = painter.max_texture_side(); - glutin_ctx.viewports[&ViewportId::MAIN] + glutin_ctx.viewports[&ViewportId::ROOT] .borrow_mut() .egui_winit .as_mut() @@ -969,7 +969,7 @@ mod glow_integration { let system_theme = system_theme( &glutin_ctx - .window(ViewportId::MAIN) + .window(ViewportId::ROOT) .borrow() .window .as_ref() @@ -979,7 +979,7 @@ mod glow_integration { ); let mut integration = epi_integration::EpiIntegration::new( &glutin_ctx - .window(ViewportId::MAIN) + .window(ViewportId::ROOT) .borrow() .window .as_ref() @@ -1017,7 +1017,7 @@ mod glow_integration { #[cfg(feature = "accesskit")] { let event_loop_proxy = self.repaint_proxy.lock().clone(); - let window = &glutin_ctx.viewports[&ViewportId::MAIN]; + let window = &glutin_ctx.viewports[&ViewportId::ROOT]; let window = &mut *window.borrow_mut(); integration.init_accesskit( window.egui_winit.as_mut().unwrap(), @@ -1030,7 +1030,7 @@ mod glow_integration { if self.native_options.mouse_passthrough { glutin_ctx - .window(ViewportId::MAIN) + .window(ViewportId::ROOT) .borrow() .window .as_ref() @@ -1044,7 +1044,7 @@ mod glow_integration { .expect("Single-use AppCreator has unexpectedly already been taken"); let mut app; { - let window = glutin_ctx.window(ViewportId::MAIN); + let window = glutin_ctx.window(ViewportId::ROOT); let window = &mut *window.borrow_mut(); app = app_creator(&epi::CreationContext { egui_ctx: integration.egui_ctx.clone(), @@ -1259,7 +1259,7 @@ mod glow_integration { glutin_ctx: &Rc>, mut viewports: Vec, ) { - let mut active_viewports_ids = vec![ViewportId::MAIN]; + let mut active_viewports_ids = vec![ViewportId::ROOT]; viewports.retain_mut( |ViewportOutput { @@ -1405,7 +1405,7 @@ mod glow_integration { running .glutin_ctx .borrow() - .window(ViewportId::MAIN) + .window(ViewportId::ROOT) .borrow() .window .as_ref() @@ -1443,7 +1443,7 @@ mod glow_integration { { let glutin = glutin.borrow(); let viewport = &glutin.viewports[&viewport_id].clone(); - if viewport.borrow().viewport_ui_cb.is_none() && viewport_id != ViewportId::MAIN + if viewport.borrow().viewport_ui_cb.is_none() && viewport_id != ViewportId::ROOT { if let Some(parent_viewport) = glutin.viewports.get(&viewport.borrow().id_pair.parent) @@ -1699,7 +1699,7 @@ mod glow_integration { .glutin_ctx .borrow() .window_maps - .get(&ViewportId::MAIN) + .get(&ViewportId::ROOT) .copied() .unwrap(), ) @@ -1784,7 +1784,7 @@ mod glow_integration { .borrow() .viewport_maps .get(window_id) - .map_or(false, |id| *id == ViewportId::MAIN) + .map_or(false, |id| *id == ViewportId::ROOT) && running.integration.borrow().should_close() => { log::debug!("Received WindowEvent::CloseRequested"); @@ -1967,7 +1967,7 @@ mod wgpu_integration { native_options, running: None, app_creator: Some(app_creator), - is_focused: Rc::new(RefCell::new(Some(ViewportId::MAIN))), + is_focused: Rc::new(RefCell::new(Some(ViewportId::ROOT))), } } @@ -2065,12 +2065,12 @@ mod wgpu_integration { #[cfg(target_os = "android")] fn drop_window(&mut self) -> std::result::Result<(), egui_wgpu::WgpuError> { if let Some(running) = &mut self.running { - running.viewports.borrow_mut().remove(&ViewportId::MAIN); + running.viewports.borrow_mut().remove(&ViewportId::ROOT); pollster::block_on( running .painter .borrow_mut() - .set_window(ViewportId::MAIN, None), + .set_window(ViewportId::ROOT, None), )?; } Ok(()) @@ -2095,7 +2095,7 @@ mod wgpu_integration { ), self.native_options.transparent, ); - pollster::block_on(painter.set_window(ViewportId::MAIN, Some(&window)))?; + pollster::block_on(painter.set_window(ViewportId::ROOT, Some(&window)))?; let wgpu_render_state = painter.render_state(); @@ -2164,22 +2164,22 @@ mod wgpu_integration { } let mut viewport_maps = HashMap::default(); - viewport_maps.insert(window.id(), ViewportId::MAIN); + viewport_maps.insert(window.id(), ViewportId::ROOT); let viewport_maps = Rc::new(RefCell::new(viewport_maps)); let viewports = Rc::new(RefCell::new(Viewports::default())); viewports.borrow_mut().insert( - ViewportId::MAIN, + ViewportId::ROOT, Viewport { window: Some(Rc::new(RefCell::new(window))), state: Rc::new(RefCell::new(Some(state))), viewport_ui_cb: None, - parent_id: ViewportId::MAIN, + parent_id: ViewportId::ROOT, }, ); let builders = Rc::new(RefCell::new(ViewportMap::default())); - builders.borrow_mut().insert(ViewportId::MAIN, builder); + builders.borrow_mut().insert(ViewportId::ROOT, builder); let painter = Rc::new(RefCell::new(painter)); @@ -2385,7 +2385,7 @@ mod wgpu_integration { if let Some(mut running) = self.running.take() { crate::profile_function!(); if let Some(Viewport { window, .. }) = - running.viewports.borrow().get(&ViewportId::MAIN) + running.viewports.borrow().get(&ViewportId::ROOT) { running.integration.borrow_mut().save( running.app.as_mut(), @@ -2443,7 +2443,7 @@ mod wgpu_integration { return EventResult::Wait; }; // This is used to not render a viewport if is sync - if viewport_id != ViewportId::MAIN && viewport_ui_cb.is_none() { + if viewport_id != ViewportId::ROOT && viewport_ui_cb.is_none() { if let Some(viewport) = running.viewports.borrow().get(&parent_id) { if let Some(window) = viewport.window.as_ref() { return EventResult::RepaintNext(window.borrow().id()); @@ -2512,7 +2512,7 @@ mod wgpu_integration { integration.post_present(&window.borrow()); } - let mut active_viewports_ids = vec![ViewportId::MAIN]; + let mut active_viewports_ids = vec![ViewportId::ROOT]; out_viewports.retain_mut( |ViewportOutput { @@ -2624,14 +2624,14 @@ mod wgpu_integration { Ok(match event { winit::event::Event::Resumed => { if let Some(running) = &self.running { - if running.viewports.borrow().get(&ViewportId::MAIN).is_none() { + if running.viewports.borrow().get(&ViewportId::ROOT).is_none() { let _ = Self::create_window( event_loop, running.integration.borrow().frame.storage(), &self.app_name, &mut self.native_options, )?; - self.set_window(ViewportId::MAIN)?; + self.set_window(ViewportId::ROOT)?; } } else { let storage = epi_integration::create_storage( @@ -2654,7 +2654,7 @@ mod wgpu_integration { .unwrap() .viewports .borrow() - .get(&ViewportId::MAIN) + .get(&ViewportId::ROOT) .unwrap() .window .as_ref() diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 2d884a5151d..dfc41604075 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -183,7 +183,7 @@ impl AppRunner { let full_output = self .egui_ctx - .run(raw_input, ViewportIdPair::MAIN, |egui_ctx| { + .run(raw_input, ViewportIdPair::ROOT, |egui_ctx| { self.app.update(egui_ctx, &mut self.frame); }); let egui::FullOutput { @@ -195,7 +195,7 @@ impl AppRunner { self.handle_platform_output(platform_output); self.textures_delta.append(textures_delta); - let clipped_primitives = self.egui_ctx.tessellate(shapes, ViewportId::MAIN); + let clipped_primitives = self.egui_ctx.tessellate(shapes, ViewportId::ROOT); { let app_output = self.frame.take_app_output(); diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 62d7248932c..17a31b27606 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -349,16 +349,16 @@ impl ContextImpl { } impl ContextImpl { - /// Return the `ViewportId` of the current viewport + /// Return the `ViewportId` of the current viewport. /// - /// In the case of this viewport is the main viewport will be `ViewportId::MAIN` + /// For the root viewport this will return [`ViewportId::ROOT`]. pub(crate) fn viewport_id(&self) -> ViewportId { self.viewport_stack.last().copied().unwrap_or_default().this } - /// Return the `ViewportId` of his parent + /// Return the `ViewportId` of his parent. /// - /// In the case of this viewport is the main viewport will be `ViewportId::MAIN` + /// For the root viewport this will return [`ViewportId::ROOT`]. pub(crate) fn parent_viewport_id(&self) -> ViewportId { self.viewport_stack .last() @@ -407,7 +407,7 @@ impl ContextImpl { /// // Game loop: /// loop { /// let raw_input = egui::RawInput::default(); -/// let full_output = ctx.run(raw_input, egui::ViewportIdPair::MAIN, |ctx| { +/// let full_output = ctx.run(raw_input, egui::ViewportIdPair::ROOT, |ctx| { /// egui::CentralPanel::default().show(&ctx, |ui| { /// ui.label("Hello world!"); /// if ui.button("Click me").clicked() { @@ -416,7 +416,7 @@ impl ContextImpl { /// }); /// }); /// handle_platform_output(full_output.platform_output); -/// let clipped_primitives = ctx.tessellate(full_output.shapes, egui::ViewportId::MAIN); // create triangles to paint +/// let clipped_primitives = ctx.tessellate(full_output.shapes, egui::ViewportId::ROOT); // create triangles to paint /// paint(full_output.textures_delta, clipped_primitives); /// } /// ``` @@ -473,7 +473,7 @@ impl Context { /// /// // Each frame: /// let input = egui::RawInput::default(); - /// let full_output = ctx.run(input, egui::ViewportIdPair::MAIN, |ctx| { + /// let full_output = ctx.run(input, egui::ViewportIdPair::ROOT, |ctx| { /// egui::CentralPanel::default().show(&ctx, |ui| { /// ui.label("Hello egui!"); /// }); @@ -502,7 +502,7 @@ impl Context { /// /// // Each frame: /// let input = egui::RawInput::default(); - /// ctx.begin_frame(input, egui::ViewportIdPair::MAIN); + /// ctx.begin_frame(input, egui::ViewportIdPair::ROOT); /// /// egui::CentralPanel::default().show(&ctx, |ui| { /// ui.label("Hello egui!"); @@ -1341,7 +1341,7 @@ impl Context { for viewport in ctx.viewports.values() { ctx.repaint.request_repaint_settle(viewport.id_pair.this); } - ctx.repaint.request_repaint_settle(ViewportId::MAIN); + ctx.repaint.request_repaint_settle(ViewportId::ROOT); ctx.memory.override_pixels_per_point = Some(pixels_per_point); }); } @@ -1492,7 +1492,7 @@ impl Context { ); ctx.viewports.values().map(|vp| vp.id_pair.this).collect() }); - viewports.push(ViewportId::MAIN); + viewports.push(ViewportId::ROOT); if self.input(|i| i.wants_repaint()) { self.request_repaint(); @@ -1556,7 +1556,7 @@ impl Context { // If there are no viewport that contains the current viewport that viewport needs to be destroyed! let available_viewports = self.read(|ctx| { - let mut available_viewports = vec![ViewportId::MAIN]; + let mut available_viewports = vec![ViewportId::ROOT]; for vp in ctx.viewports.values() { available_viewports.push(vp.id_pair.this); } @@ -2500,16 +2500,20 @@ impl Context { /// ## Viewports impl Context { - /// Return the `ViewportId` of the current viewport - /// In the case of this viewport is the main viewport will be `ViewportId::MAIN` - /// Don't use this outside of `Self::run`, or after `Self::end_frame` + /// Return the `ViewportId` of the current viewport. + /// + /// If this is the root viewport, this will return [`ViewportId::ROOT`]. + /// + /// Don't use this outside of `Self::run`, or after `Self::end_frame`. pub fn viewport_id(&self) -> ViewportId { self.read(|ctx| ctx.viewport_id()) } - /// Return the `ViewportId` of his parent - /// In the case of this viewport is the main viewport will be `ViewportId::MAIN` - /// Don't use this outside of `Self::run`, or after `Self::end_frame` + /// Return the `ViewportId` of his parent. + /// + /// If this is the root viewport, this will return [`ViewportId::ROOT`]. + /// + /// Don't use this outside of `Self::run`, or after `Self::end_frame`. pub fn parent_viewport_id(&self) -> ViewportId { self.read(|ctx| ctx.parent_viewport_id()) } diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index 029311ecd0c..61466d5972b 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -125,7 +125,7 @@ //! loop { //! let raw_input: egui::RawInput = gather_input(); //! -//! let full_output = ctx.run(raw_input, egui::ViewportIdPair::MAIN, |ctx| { +//! let full_output = ctx.run(raw_input, egui::ViewportIdPair::ROOT, |ctx| { //! egui::CentralPanel::default().show(&ctx, |ui| { //! ui.label("Hello world!"); //! if ui.button("Click me").clicked() { @@ -134,7 +134,7 @@ //! }); //! }); //! handle_platform_output(full_output.platform_output); -//! let clipped_primitives = ctx.tessellate(full_output.shapes, egui::ViewportId::MAIN); // create triangles to paint +//! let clipped_primitives = ctx.tessellate(full_output.shapes, egui::ViewportId::ROOT); // create triangles to paint //! paint(full_output.textures_delta, clipped_primitives); //! } //! ``` @@ -606,7 +606,7 @@ pub enum WidgetType { pub fn __run_test_ctx(mut run_ui: impl FnMut(&Context)) { let ctx = Context::default(); ctx.set_fonts(FontDefinitions::empty()); // prevent fonts from being loaded (save CPU time) - let _ = ctx.run(Default::default(), ViewportIdPair::MAIN, |ctx| { + let _ = ctx.run(Default::default(), ViewportIdPair::ROOT, |ctx| { run_ui(ctx); }); } @@ -615,7 +615,7 @@ pub fn __run_test_ctx(mut run_ui: impl FnMut(&Context)) { pub fn __run_test_ui(mut add_contents: impl FnMut(&mut Ui)) { let ctx = Context::default(); ctx.set_fonts(FontDefinitions::empty()); // prevent fonts from being loaded (save CPU time) - let _ = ctx.run(Default::default(), ViewportIdPair::MAIN, |ctx| { + let _ = ctx.run(Default::default(), ViewportIdPair::ROOT, |ctx| { crate::CentralPanel::default().show(ctx, |ui| { add_contents(ui); }); diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index 905ed357850..a4ce59c0d56 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -23,7 +23,7 @@ pub struct ViewportId(pub Id); impl Default for ViewportId { fn default() -> Self { - Self::MAIN + Self::ROOT } } @@ -34,8 +34,8 @@ impl std::fmt::Debug for ViewportId { } impl ViewportId { - /// This will return the `ViewportId` of the main viewport - pub const MAIN: Self = Self(Id::null()); + /// The `ViewportId` of the root viewport. + pub const ROOT: Self = Self(Id::null()); pub fn from_hash_of(source: impl std::hash::Hash) -> Self { Self(Id::new(source)) @@ -66,17 +66,17 @@ pub struct ViewportIdPair { impl Default for ViewportIdPair { fn default() -> Self { Self { - this: ViewportId::MAIN, - parent: ViewportId::MAIN, + this: ViewportId::ROOT, + parent: ViewportId::ROOT, } } } impl ViewportIdPair { - /// This will return the `ViewportIdPair` of the main viewport - pub const MAIN: Self = Self { - this: ViewportId::MAIN, - parent: ViewportId::MAIN, + /// The `ViewportIdPair` of the root viewport, which is its own parent. + pub const ROOT: Self = Self { + this: ViewportId::ROOT, + parent: ViewportId::ROOT, }; } diff --git a/crates/egui_demo_lib/benches/benchmark.rs b/crates/egui_demo_lib/benches/benchmark.rs index b1dda1a059b..552167f8540 100644 --- a/crates/egui_demo_lib/benches/benchmark.rs +++ b/crates/egui_demo_lib/benches/benchmark.rs @@ -13,26 +13,26 @@ pub fn criterion_benchmark(c: &mut Criterion) { // The most end-to-end benchmark. c.bench_function("demo_with_tessellate__realistic", |b| { b.iter(|| { - let full_output = ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| { + let full_output = ctx.run(RawInput::default(), ViewportIdPair::ROOT, |ctx| { demo_windows.ui(ctx); }); - ctx.tessellate(full_output.shapes, ViewportId::MAIN) + ctx.tessellate(full_output.shapes, ViewportId::ROOT) }); }); c.bench_function("demo_no_tessellate", |b| { b.iter(|| { - ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| { + ctx.run(RawInput::default(), ViewportIdPair::ROOT, |ctx| { demo_windows.ui(ctx); }) }); }); - let full_output = ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| { + let full_output = ctx.run(RawInput::default(), ViewportIdPair::ROOT, |ctx| { demo_windows.ui(ctx); }); c.bench_function("demo_only_tessellate", |b| { - b.iter(|| ctx.tessellate(full_output.shapes.clone(), ViewportId::MAIN)); + b.iter(|| ctx.tessellate(full_output.shapes.clone(), ViewportId::ROOT)); }); } @@ -42,7 +42,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { let mut demo_windows = egui_demo_lib::DemoWindows::default(); c.bench_function("demo_full_no_tessellate", |b| { b.iter(|| { - ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| { + ctx.run(RawInput::default(), ViewportIdPair::ROOT, |ctx| { demo_windows.ui(ctx); }) }); @@ -51,7 +51,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { { let ctx = egui::Context::default(); - let _ = ctx.run(RawInput::default(), ViewportIdPair::MAIN, |ctx| { + let _ = ctx.run(RawInput::default(), ViewportIdPair::ROOT, |ctx| { egui::CentralPanel::default().show(ctx, |ui| { c.bench_function("label &str", |b| { b.iter(|| { @@ -69,7 +69,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { { let ctx = egui::Context::default(); - ctx.begin_frame(RawInput::default(), ViewportIdPair::MAIN); + ctx.begin_frame(RawInput::default(), ViewportIdPair::ROOT); egui::CentralPanel::default().show(&ctx, |ui| { c.bench_function("Painter::rect", |b| { diff --git a/crates/egui_demo_lib/src/lib.rs b/crates/egui_demo_lib/src/lib.rs index 471550fe404..16fa1dd6c45 100644 --- a/crates/egui_demo_lib/src/lib.rs +++ b/crates/egui_demo_lib/src/lib.rs @@ -76,10 +76,10 @@ fn test_egui_e2e() { const NUM_FRAMES: usize = 5; for _ in 0..NUM_FRAMES { - let full_output = ctx.run(raw_input.clone(), ViewportIdPair::MAIN, |ctx| { + let full_output = ctx.run(raw_input.clone(), ViewportIdPair::ROOT, |ctx| { demo_windows.ui(ctx); }); - let clipped_primitives = ctx.tessellate(full_output.shapes, ViewportId::MAIN); + let clipped_primitives = ctx.tessellate(full_output.shapes, ViewportId::ROOT); assert!(!clipped_primitives.is_empty()); } } @@ -95,10 +95,10 @@ fn test_egui_zero_window_size() { const NUM_FRAMES: usize = 5; for _ in 0..NUM_FRAMES { - let full_output = ctx.run(raw_input.clone(), ViewportIdPair::MAIN, |ctx| { + let full_output = ctx.run(raw_input.clone(), ViewportIdPair::ROOT, |ctx| { demo_windows.ui(ctx); }); - let clipped_primitives = ctx.tessellate(full_output.shapes, ViewportId::MAIN); + let clipped_primitives = ctx.tessellate(full_output.shapes, ViewportId::ROOT); assert!( clipped_primitives.is_empty(), "There should be nothing to show, has at least one primitive with clip_rect: {:?}", diff --git a/crates/egui_glow/src/winit.rs b/crates/egui_glow/src/winit.rs index 1c2885958c4..fe19892cb43 100644 --- a/crates/egui_glow/src/winit.rs +++ b/crates/egui_glow/src/winit.rs @@ -50,11 +50,11 @@ impl EguiGlow { textures_delta, shapes, .. - } = self.egui_ctx.run(raw_input, ViewportIdPair::MAIN, run_ui); + } = self.egui_ctx.run(raw_input, ViewportIdPair::ROOT, run_ui); self.egui_winit.handle_platform_output( window, - ViewportId::MAIN, + ViewportId::ROOT, &self.egui_ctx, platform_output, ); @@ -72,7 +72,7 @@ impl EguiGlow { self.painter.set_texture(id, &image_delta); } - let clipped_primitives = self.egui_ctx.tessellate(shapes, ViewportId::MAIN); + let clipped_primitives = self.egui_ctx.tessellate(shapes, ViewportId::ROOT); let dimensions: [u32; 2] = window.inner_size().into(); self.painter.paint_primitives( dimensions, diff --git a/examples/viewports/src/main.rs b/examples/viewports/src/main.rs index b538d59e8d7..738c7b44e1d 100644 --- a/examples/viewports/src/main.rs +++ b/examples/viewports/src/main.rs @@ -58,8 +58,8 @@ impl Default for App { impl eframe::App for App { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { egui::CentralPanel::default().show(ctx, |ui| { - ui.heading("Main viewport"); - generic_ui(ui, Id::new("main_viewport")); + ui.heading("Root viewport"); + generic_ui(ui, Id::new("root_viewport")); { let mut force_embedding = ctx.force_embedding(); ui.checkbox(&mut force_embedding, "Force embedding of new viewprts");