mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Add winit window access to eframe::Frame and CreationContext (#8205)
* Related: https://github.com/emilk/egui/issues/7798
This commit is contained in:
@@ -83,6 +83,10 @@ pub struct CreationContext<'s> {
|
||||
#[cfg(feature = "wgpu_no_default_features")]
|
||||
pub wgpu_render_state: Option<egui_wgpu::RenderState>,
|
||||
|
||||
/// The root [`winit::window::Window`].
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) window: Option<std::sync::Arc<winit::window::Window>>,
|
||||
|
||||
/// Raw platform window handle
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) raw_window_handle: Result<RawWindowHandle, HandleError>,
|
||||
@@ -125,11 +129,21 @@ impl CreationContext<'_> {
|
||||
#[cfg(feature = "wgpu_no_default_features")]
|
||||
wgpu_render_state: None,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
window: None,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
raw_window_handle: Err(HandleError::NotSupported),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
raw_display_handle: Err(HandleError::NotSupported),
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the root [`winit::window::Window`].
|
||||
///
|
||||
/// `None` for headless (tests etc).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn winit_window(&self) -> Option<&std::sync::Arc<winit::window::Window>> {
|
||||
self.window.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -659,6 +673,10 @@ pub struct Frame {
|
||||
#[doc(hidden)]
|
||||
pub wgpu_render_state: Option<egui_wgpu::RenderState>,
|
||||
|
||||
/// The current [`winit::window::Window`] (i.e. the one the active viewport is rendered to).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) window: Option<std::sync::Arc<winit::window::Window>>,
|
||||
|
||||
/// Raw platform window handle
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) raw_window_handle: Result<RawWindowHandle, HandleError>,
|
||||
@@ -704,6 +722,8 @@ impl Frame {
|
||||
raw_display_handle: Err(HandleError::NotSupported),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
raw_window_handle: Err(HandleError::NotSupported),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
window: None,
|
||||
storage: None,
|
||||
#[cfg(feature = "wgpu_no_default_features")]
|
||||
wgpu_render_state: None,
|
||||
@@ -733,6 +753,14 @@ impl Frame {
|
||||
self.storage.as_deref_mut()
|
||||
}
|
||||
|
||||
/// Access to the current [`winit::window::Window`] (i.e. the one the active viewport is rendered to).
|
||||
///
|
||||
/// `None` for headless (tests etc).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn winit_window(&self) -> Option<&std::sync::Arc<winit::window::Window>> {
|
||||
self.window.as_ref()
|
||||
}
|
||||
|
||||
/// A reference to the underlying [`glow`] (OpenGL) context.
|
||||
///
|
||||
/// This can be used, for instance, to:
|
||||
|
||||
Reference in New Issue
Block a user