mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Now every window has egui-winit, but a big problem is that a window don't render if the window frame number is bigger the the current frame, this is a spaculation because i don't know if a window stores the current frame i don't know what happens because new window render from the first time but the egui-ctx don't want to render the new window
is like i have tow egui-ctx
This commit is contained in:
@@ -7,7 +7,7 @@ use raw_window_handle::{HasRawDisplayHandle as _, HasRawWindowHandle as _};
|
|||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
use egui::accesskit;
|
use egui::accesskit;
|
||||||
use egui::{window::WindowBuilder, NumExt as _};
|
use egui::{epaint::ahash::HashMap, window::WindowBuilder, NumExt as _};
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
use egui_winit::accesskit_winit;
|
use egui_winit::accesskit_winit;
|
||||||
use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};
|
use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};
|
||||||
@@ -327,7 +327,6 @@ pub struct EpiIntegration {
|
|||||||
last_auto_save: std::time::Instant,
|
last_auto_save: std::time::Instant,
|
||||||
pub egui_ctx: egui::Context,
|
pub egui_ctx: egui::Context,
|
||||||
pending_full_output: egui::FullOutput,
|
pending_full_output: egui::FullOutput,
|
||||||
egui_winit: egui_winit::State,
|
|
||||||
/// When set, it is time to close the native window.
|
/// When set, it is time to close the native window.
|
||||||
close: bool,
|
close: bool,
|
||||||
can_drag_window: bool,
|
can_drag_window: bool,
|
||||||
@@ -382,10 +381,6 @@ impl EpiIntegration {
|
|||||||
raw_window_handle: window.raw_window_handle(),
|
raw_window_handle: window.raw_window_handle(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut egui_winit = egui_winit::State::new(event_loop);
|
|
||||||
egui_winit.set_max_texture_side(max_texture_side);
|
|
||||||
egui_winit.set_pixels_per_point(native_pixels_per_point);
|
|
||||||
|
|
||||||
let app_icon_setter = super::app_icon::AppTitleIconSetter::new(
|
let app_icon_setter = super::app_icon::AppTitleIconSetter::new(
|
||||||
app_name.to_owned(),
|
app_name.to_owned(),
|
||||||
native_options.icon_data.clone(),
|
native_options.icon_data.clone(),
|
||||||
@@ -395,7 +390,6 @@ impl EpiIntegration {
|
|||||||
frame,
|
frame,
|
||||||
last_auto_save: std::time::Instant::now(),
|
last_auto_save: std::time::Instant::now(),
|
||||||
egui_ctx,
|
egui_ctx,
|
||||||
egui_winit,
|
|
||||||
pending_full_output: Default::default(),
|
pending_full_output: Default::default(),
|
||||||
close: false,
|
close: false,
|
||||||
can_drag_window: false,
|
can_drag_window: false,
|
||||||
@@ -408,28 +402,33 @@ impl EpiIntegration {
|
|||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
pub fn init_accesskit<E: From<accesskit_winit::ActionRequestEvent> + Send>(
|
pub fn init_accesskit<E: From<accesskit_winit::ActionRequestEvent> + Send>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
egui_winit: &mut egui_winit::State,
|
||||||
window: &winit::window::Window,
|
window: &winit::window::Window,
|
||||||
event_loop_proxy: winit::event_loop::EventLoopProxy<E>,
|
event_loop_proxy: winit::event_loop::EventLoopProxy<E>,
|
||||||
) {
|
) {
|
||||||
let egui_ctx = self.egui_ctx.clone();
|
let egui_ctx = self.egui_ctx.clone();
|
||||||
self.egui_winit
|
egui_winit.init_accesskit(window, event_loop_proxy, move || {
|
||||||
.init_accesskit(window, event_loop_proxy, move || {
|
// This function is called when an accessibility client
|
||||||
// This function is called when an accessibility client
|
// (e.g. screen reader) makes its first request. If we got here,
|
||||||
// (e.g. screen reader) makes its first request. If we got here,
|
// we know that an accessibility tree is actually wanted.
|
||||||
// we know that an accessibility tree is actually wanted.
|
egui_ctx.enable_accesskit();
|
||||||
egui_ctx.enable_accesskit();
|
// Enqueue a repaint so we'll receive a full tree update soon.
|
||||||
// Enqueue a repaint so we'll receive a full tree update soon.
|
egui_ctx.request_repaint();
|
||||||
egui_ctx.request_repaint();
|
egui_ctx.accesskit_placeholder_tree_update()
|
||||||
egui_ctx.accesskit_placeholder_tree_update()
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn warm_up(&mut self, app: &mut dyn epi::App, window: &winit::window::Window) {
|
pub fn warm_up(
|
||||||
|
&mut self,
|
||||||
|
app: &mut dyn epi::App,
|
||||||
|
window: &winit::window::Window,
|
||||||
|
egui_winit: &mut egui_winit::State,
|
||||||
|
) {
|
||||||
crate::profile_function!();
|
crate::profile_function!();
|
||||||
let saved_memory: egui::Memory = self.egui_ctx.memory(|mem| mem.clone());
|
let saved_memory: egui::Memory = self.egui_ctx.memory(|mem| mem.clone());
|
||||||
self.egui_ctx
|
self.egui_ctx
|
||||||
.memory_mut(|mem| mem.set_everything_is_visible(true));
|
.memory_mut(|mem| mem.set_everything_is_visible(true));
|
||||||
let full_output = self.update(app, window);
|
let full_output = self.update(app, window, egui_winit);
|
||||||
self.pending_full_output.append(full_output); // Handle it next frame
|
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.memory_mut(|mem| *mem = saved_memory); // We don't want to remember that windows were huge.
|
||||||
self.egui_ctx.clear_animations();
|
self.egui_ctx.clear_animations();
|
||||||
@@ -444,6 +443,8 @@ impl EpiIntegration {
|
|||||||
&mut self,
|
&mut self,
|
||||||
app: &mut dyn epi::App,
|
app: &mut dyn epi::App,
|
||||||
event: &winit::event::WindowEvent<'_>,
|
event: &winit::event::WindowEvent<'_>,
|
||||||
|
window_id: &winit::window::WindowId,
|
||||||
|
egui_winit: &mut egui_winit::State,
|
||||||
) -> EventResponse {
|
) -> EventResponse {
|
||||||
use winit::event::{ElementState, MouseButton, WindowEvent};
|
use winit::event::{ElementState, MouseButton, WindowEvent};
|
||||||
|
|
||||||
@@ -473,18 +474,24 @@ impl EpiIntegration {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.egui_winit.on_event(&self.egui_ctx, event)
|
egui_winit.on_event(&self.egui_ctx, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
pub fn on_accesskit_action_request(&mut self, request: accesskit::ActionRequest) {
|
pub fn on_accesskit_action_request(
|
||||||
self.egui_winit.on_accesskit_action_request(request);
|
&mut self,
|
||||||
|
request: accesskit::ActionRequest,
|
||||||
|
window_id: &winit::window::WindowId,
|
||||||
|
egui_winit: &mut egui_winit::State,
|
||||||
|
) {
|
||||||
|
egui_winit.on_accesskit_action_request(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
app: &mut dyn epi::App,
|
app: &mut dyn epi::App,
|
||||||
window: &winit::window::Window,
|
window: &winit::window::Window,
|
||||||
|
egui_winit: &mut egui_winit::State,
|
||||||
) -> egui::FullOutput {
|
) -> egui::FullOutput {
|
||||||
let frame_start = std::time::Instant::now();
|
let frame_start = std::time::Instant::now();
|
||||||
|
|
||||||
@@ -492,7 +499,7 @@ impl EpiIntegration {
|
|||||||
|
|
||||||
self.frame.info.window_info =
|
self.frame.info.window_info =
|
||||||
read_window_info(window, self.egui_ctx.pixels_per_point(), &self.window_state);
|
read_window_info(window, self.egui_ctx.pixels_per_point(), &self.window_state);
|
||||||
let raw_input = self.egui_winit.take_egui_input(window);
|
let raw_input = egui_winit.take_egui_input(window);
|
||||||
|
|
||||||
// Run user code:
|
// Run user code:
|
||||||
let full_output = self.egui_ctx.run(raw_input, |egui_ctx| {
|
let full_output = self.egui_ctx.run(raw_input, |egui_ctx| {
|
||||||
@@ -547,9 +554,9 @@ impl EpiIntegration {
|
|||||||
&mut self,
|
&mut self,
|
||||||
window: &winit::window::Window,
|
window: &winit::window::Window,
|
||||||
platform_output: egui::PlatformOutput,
|
platform_output: egui::PlatformOutput,
|
||||||
|
egui_winit: &mut egui_winit::State,
|
||||||
) {
|
) {
|
||||||
self.egui_winit
|
egui_winit.handle_platform_output(window, &self.egui_ctx, platform_output);
|
||||||
.handle_platform_output(window, &self.egui_ctx, platform_output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use winit::event_loop::{
|
|||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
use egui_winit::accesskit_winit;
|
use egui_winit::accesskit_winit;
|
||||||
use egui_winit::winit;
|
use egui_winit::{winit, EventResponse};
|
||||||
|
|
||||||
use crate::{epi, Result};
|
use crate::{epi, Result};
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ trait WinitApp {
|
|||||||
|
|
||||||
fn save_and_destroy(&mut self);
|
fn save_and_destroy(&mut self);
|
||||||
|
|
||||||
fn run_ui_and_paint(&mut self, window_id: Option<winit::window::WindowId>) -> Vec<EventResult>;
|
fn run_ui_and_paint(&mut self, window_id: winit::window::WindowId) -> Vec<EventResult>;
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
@@ -130,6 +130,8 @@ fn run_and_return(
|
|||||||
|
|
||||||
log::debug!("Entering the winit event loop (run_return)…");
|
log::debug!("Entering the winit event loop (run_return)…");
|
||||||
|
|
||||||
|
println!("Run and return");
|
||||||
|
|
||||||
let mut windows_next_repaint_times = HashMap::default();
|
let mut windows_next_repaint_times = HashMap::default();
|
||||||
|
|
||||||
let mut returned_result = Ok(());
|
let mut returned_result = Ok(());
|
||||||
@@ -149,12 +151,13 @@ fn run_and_return(
|
|||||||
// See: https://github.com/rust-windowing/winit/issues/987
|
// See: https://github.com/rust-windowing/winit/issues/987
|
||||||
// See: https://github.com/rust-windowing/winit/issues/1619
|
// See: https://github.com/rust-windowing/winit/issues/1619
|
||||||
winit::event::Event::RedrawEventsCleared if cfg!(windows) => {
|
winit::event::Event::RedrawEventsCleared if cfg!(windows) => {
|
||||||
windows_next_repaint_times.clear();
|
// windows_next_repaint_times.clear();
|
||||||
winit_app.run_ui_and_paint(None)
|
// winit_app.run_ui_and_paint(None)
|
||||||
|
vec![EventResult::Wait]
|
||||||
}
|
}
|
||||||
winit::event::Event::RedrawRequested(window_id) if !cfg!(windows) => {
|
winit::event::Event::RedrawRequested(window_id) if !cfg!(windows) => {
|
||||||
windows_next_repaint_times.remove(window_id);
|
windows_next_repaint_times.remove(window_id);
|
||||||
winit_app.run_ui_and_paint(Some(*window_id))
|
winit_app.run_ui_and_paint(*window_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
winit::event::Event::UserEvent(UserEvent::RequestRepaint {
|
winit::event::Event::UserEvent(UserEvent::RequestRepaint {
|
||||||
@@ -187,7 +190,7 @@ fn run_and_return(
|
|||||||
{
|
{
|
||||||
// This can happen if we close a window, and then reopen a new one,
|
// This can happen if we close a window, and then reopen a new one,
|
||||||
// or if we have multiple windows open.
|
// or if we have multiple windows open.
|
||||||
vec![EventResult::Wait]
|
vec![EventResult::RepaintNext(window_id.clone())]
|
||||||
}
|
}
|
||||||
|
|
||||||
event => match winit_app.on_event(event_loop, event) {
|
event => match winit_app.on_event(event_loop, event) {
|
||||||
@@ -211,7 +214,7 @@ fn run_and_return(
|
|||||||
// Fix flickering on Windows, see https://github.com/emilk/egui/pull/2280
|
// Fix flickering on Windows, see https://github.com/emilk/egui/pull/2280
|
||||||
windows_next_repaint_times.remove(&window_id);
|
windows_next_repaint_times.remove(&window_id);
|
||||||
|
|
||||||
winit_app.run_ui_and_paint(Some(window_id));
|
winit_app.run_ui_and_paint(window_id);
|
||||||
} else {
|
} else {
|
||||||
// Fix for https://github.com/emilk/egui/issues/2425
|
// Fix for https://github.com/emilk/egui/issues/2425
|
||||||
windows_next_repaint_times.insert(window_id, Instant::now());
|
windows_next_repaint_times.insert(window_id, Instant::now());
|
||||||
@@ -243,7 +246,6 @@ fn run_and_return(
|
|||||||
for (window_id, repaint_time) in windows_next_repaint_times.clone().iter() {
|
for (window_id, repaint_time) in windows_next_repaint_times.clone().iter() {
|
||||||
if *repaint_time <= Instant::now() {
|
if *repaint_time <= Instant::now() {
|
||||||
if let Some(window) = winit_app.window(*window_id) {
|
if let Some(window) = winit_app.window(*window_id) {
|
||||||
log::trace!("request_redraw {window_id:?}");
|
|
||||||
window.request_redraw();
|
window.request_redraw();
|
||||||
windows_next_repaint_times.remove(window_id);
|
windows_next_repaint_times.remove(window_id);
|
||||||
}
|
}
|
||||||
@@ -290,6 +292,8 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
|
|
||||||
let mut windows_next_repaint_times = HashMap::default();
|
let mut windows_next_repaint_times = HashMap::default();
|
||||||
|
|
||||||
|
println!("Run and exit");
|
||||||
|
|
||||||
event_loop.run(move |event, event_loop, control_flow| {
|
event_loop.run(move |event, event_loop, control_flow| {
|
||||||
let events = match event {
|
let events = match event {
|
||||||
winit::event::Event::LoopDestroyed => {
|
winit::event::Event::LoopDestroyed => {
|
||||||
@@ -301,12 +305,13 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
// See: https://github.com/rust-windowing/winit/issues/987
|
// See: https://github.com/rust-windowing/winit/issues/987
|
||||||
// See: https://github.com/rust-windowing/winit/issues/1619
|
// See: https://github.com/rust-windowing/winit/issues/1619
|
||||||
winit::event::Event::RedrawEventsCleared if cfg!(windows) => {
|
winit::event::Event::RedrawEventsCleared if cfg!(windows) => {
|
||||||
windows_next_repaint_times.clear();
|
// windows_next_repaint_times.clear();
|
||||||
winit_app.run_ui_and_paint(None)
|
// winit_app.run_ui_and_paint(None)
|
||||||
|
vec![]
|
||||||
}
|
}
|
||||||
winit::event::Event::RedrawRequested(window_id) if !cfg!(windows) => {
|
winit::event::Event::RedrawRequested(window_id) if !cfg!(windows) => {
|
||||||
windows_next_repaint_times.remove(&window_id);
|
windows_next_repaint_times.remove(&window_id);
|
||||||
winit_app.run_ui_and_paint(Some(window_id))
|
winit_app.run_ui_and_paint(window_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
winit::event::Event::UserEvent(UserEvent::RequestRepaint {
|
winit::event::Event::UserEvent(UserEvent::RequestRepaint {
|
||||||
@@ -345,7 +350,7 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
// Fix flickering on Windows, see https://github.com/emilk/egui/pull/2280
|
// Fix flickering on Windows, see https://github.com/emilk/egui/pull/2280
|
||||||
windows_next_repaint_times.remove(&window_id);
|
windows_next_repaint_times.remove(&window_id);
|
||||||
|
|
||||||
winit_app.run_ui_and_paint(Some(window_id));
|
winit_app.run_ui_and_paint(window_id);
|
||||||
} else {
|
} else {
|
||||||
// Fix for https://github.com/emilk/egui/issues/2425
|
// Fix for https://github.com/emilk/egui/issues/2425
|
||||||
windows_next_repaint_times.insert(window_id, Instant::now());
|
windows_next_repaint_times.insert(window_id, Instant::now());
|
||||||
@@ -407,6 +412,7 @@ mod glow_integration {
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use egui::{epaint::ahash::HashMap, window::WindowBuilder, NumExt as _};
|
use egui::{epaint::ahash::HashMap, window::WindowBuilder, NumExt as _};
|
||||||
|
use egui_winit::EventResponse;
|
||||||
use glow::HasContext;
|
use glow::HasContext;
|
||||||
use glutin::{
|
use glutin::{
|
||||||
display::GetGlDisplay,
|
display::GetGlDisplay,
|
||||||
@@ -448,6 +454,7 @@ mod glow_integration {
|
|||||||
gl_surface: Option<glutin::surface::Surface<glutin::surface::WindowSurface>>,
|
gl_surface: Option<glutin::surface::Surface<glutin::surface::WindowSurface>>,
|
||||||
window: Option<winit::window::Window>,
|
window: Option<winit::window::Window>,
|
||||||
window_id: u64,
|
window_id: u64,
|
||||||
|
pub egui_winit: Option<egui_winit::State>,
|
||||||
}
|
}
|
||||||
/// This struct will contain both persistent and temporary glutin state.
|
/// This struct will contain both persistent and temporary glutin state.
|
||||||
///
|
///
|
||||||
@@ -593,6 +600,7 @@ mod glow_integration {
|
|||||||
gl_surface: None,
|
gl_surface: None,
|
||||||
window,
|
window,
|
||||||
window_id: 0,
|
window_id: 0,
|
||||||
|
egui_winit: None,
|
||||||
}],
|
}],
|
||||||
window_maps,
|
window_maps,
|
||||||
})
|
})
|
||||||
@@ -663,9 +671,20 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
// we will reach this point only once in most platforms except android.
|
// we will reach this point only once in most platforms except android.
|
||||||
// create window/surface/make context current once and just use them forever.
|
// create window/surface/make context current once and just use them forever.
|
||||||
|
|
||||||
|
let native_pixels_per_point = window.scale_factor() as f32;
|
||||||
|
|
||||||
|
if win.egui_winit.is_none() {
|
||||||
|
let mut egui_winit = egui_winit::State::new(event_loop);
|
||||||
|
// egui_winit.set_max_texture_side(max_texture_side);
|
||||||
|
egui_winit.set_pixels_per_point(native_pixels_per_point);
|
||||||
|
win.egui_winit = Some(egui_winit);
|
||||||
|
}
|
||||||
|
|
||||||
win.gl_surface = Some(gl_surface);
|
win.gl_surface = Some(gl_surface);
|
||||||
self.current_gl_context = Some(current_gl_context);
|
self.current_gl_context = Some(current_gl_context);
|
||||||
self.window_maps.insert(window.id(), win.window_id);
|
self.window_maps.insert(window.id(), win.window_id);
|
||||||
|
window.request_redraw();
|
||||||
win.window = Some(window);
|
win.window = Some(window);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -721,18 +740,6 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn swap_buffers(&self, window_index: usize) -> glutin::error::Result<()> {
|
|
||||||
self.windows[window_index]
|
|
||||||
.gl_surface
|
|
||||||
.as_ref()
|
|
||||||
.expect("failed to get surface to swap buffers")
|
|
||||||
.swap_buffers(
|
|
||||||
self.current_gl_context
|
|
||||||
.as_ref()
|
|
||||||
.expect("failed to get current context to swap buffers"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_proc_address(&self, addr: &std::ffi::CStr) -> *const std::ffi::c_void {
|
fn get_proc_address(&self, addr: &std::ffi::CStr) -> *const std::ffi::c_void {
|
||||||
self.gl_config.display().get_proc_address(addr)
|
self.gl_config.display().get_proc_address(addr)
|
||||||
}
|
}
|
||||||
@@ -810,7 +817,7 @@ mod glow_integration {
|
|||||||
.unwrap_or(&self.app_name),
|
.unwrap_or(&self.app_name),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (gl_window, gl) = Self::create_glutin_windowed_context(
|
let (mut gl_window, gl) = Self::create_glutin_windowed_context(
|
||||||
event_loop,
|
event_loop,
|
||||||
storage.as_deref(),
|
storage.as_deref(),
|
||||||
&self.app_name,
|
&self.app_name,
|
||||||
@@ -837,7 +844,12 @@ mod glow_integration {
|
|||||||
);
|
);
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
{
|
{
|
||||||
integration.init_accesskit(gl_window.window(0), self.repaint_proxy.lock().clone());
|
let mut window = &mut gl_window.windows[0];
|
||||||
|
integration.init_accesskit(
|
||||||
|
&mut window.egui_winit.as_mut().unwrap(),
|
||||||
|
&window.window.as_ref().unwrap(),
|
||||||
|
self.repaint_proxy.lock().clone(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let theme = system_theme.unwrap_or(self.native_options.default_theme);
|
let theme = system_theme.unwrap_or(self.native_options.default_theme);
|
||||||
integration.egui_ctx.set_visuals(theme.egui_visuals());
|
integration.egui_ctx.set_visuals(theme.egui_visuals());
|
||||||
@@ -864,7 +876,7 @@ mod glow_integration {
|
|||||||
event_loop_proxy
|
event_loop_proxy
|
||||||
.lock()
|
.lock()
|
||||||
.send_event(UserEvent::RequestRepaint {
|
.send_event(UserEvent::RequestRepaint {
|
||||||
window_id: 0,
|
window_id: info.window_id,
|
||||||
when,
|
when,
|
||||||
frame_nr,
|
frame_nr,
|
||||||
})
|
})
|
||||||
@@ -886,7 +898,12 @@ mod glow_integration {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if app.warm_up_enabled() {
|
if app.warm_up_enabled() {
|
||||||
integration.warm_up(app.as_mut(), gl_window.window(0));
|
let window = &mut gl_window.windows[0];
|
||||||
|
integration.warm_up(
|
||||||
|
app.as_mut(),
|
||||||
|
window.window.as_ref().unwrap(),
|
||||||
|
window.egui_winit.as_mut().unwrap(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.running = Some(GlowWinitRunning {
|
self.running = Some(GlowWinitRunning {
|
||||||
@@ -963,23 +980,16 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_ui_and_paint(
|
fn run_ui_and_paint(&mut self, window_id: winit::window::WindowId) -> Vec<EventResult> {
|
||||||
&mut self,
|
|
||||||
window_id: Option<winit::window::WindowId>,
|
|
||||||
) -> Vec<EventResult> {
|
|
||||||
if let Some(running) = &mut self.running {
|
if let Some(running) = &mut self.running {
|
||||||
let mut windows_indexes = vec![];
|
let mut windows_indexes = vec![];
|
||||||
if let Some(window_id) = window_id {
|
for (i, window) in running.gl_window.windows.iter().enumerate() {
|
||||||
for (i, window) in running.gl_window.windows.iter().enumerate() {
|
if let Some(window) = &window.window {
|
||||||
if let Some(window) = &window.window {
|
if window.id() == window_id {
|
||||||
if window.id() == window_id {
|
windows_indexes.push(i);
|
||||||
windows_indexes.push(i);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
windows_indexes = (0..running.gl_window.windows.len()).collect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut inner = |window_index| {
|
let mut inner = |window_index| {
|
||||||
@@ -1006,9 +1016,8 @@ mod glow_integration {
|
|||||||
let control_flow;
|
let control_flow;
|
||||||
{
|
{
|
||||||
// let window = gl_window.window(window_index);
|
// let window = gl_window.window(window_index);
|
||||||
let win: Option<&Window> = gl_window.windows.get(window_index);
|
let win: Option<&mut Window> = gl_window.windows.get_mut(window_index);
|
||||||
let win = win.unwrap();
|
let win = win.unwrap();
|
||||||
let window = win.window.as_ref().unwrap();
|
|
||||||
gl_window.current_gl_context = Some(
|
gl_window.current_gl_context = Some(
|
||||||
gl_window
|
gl_window
|
||||||
.current_gl_context
|
.current_gl_context
|
||||||
@@ -1020,9 +1029,8 @@ mod glow_integration {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
integration.egui_ctx.set_current_window_id(win.window_id);
|
let screen_size_in_pixels: [u32; 2] =
|
||||||
|
win.window.as_ref().unwrap().inner_size().into();
|
||||||
let screen_size_in_pixels: [u32; 2] = window.inner_size().into();
|
|
||||||
|
|
||||||
egui_glow::painter::clear(
|
egui_glow::painter::clear(
|
||||||
&gl,
|
&gl,
|
||||||
@@ -1030,15 +1038,24 @@ mod glow_integration {
|
|||||||
app.clear_color(&integration.egui_ctx.style().visuals),
|
app.clear_color(&integration.egui_ctx.style().visuals),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
integration.egui_ctx.set_current_window_id(win.window_id);
|
||||||
egui::FullOutput {
|
egui::FullOutput {
|
||||||
platform_output,
|
platform_output,
|
||||||
repaint_after,
|
repaint_after,
|
||||||
textures_delta,
|
textures_delta,
|
||||||
shapes,
|
shapes,
|
||||||
windows,
|
windows,
|
||||||
} = integration.update(app.as_mut(), window);
|
} = integration.update(
|
||||||
|
app.as_mut(),
|
||||||
|
win.window.as_ref().unwrap(),
|
||||||
|
win.egui_winit.as_mut().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
integration.handle_platform_output(window, platform_output);
|
integration.handle_platform_output(
|
||||||
|
win.window.as_ref().unwrap(),
|
||||||
|
platform_output,
|
||||||
|
win.egui_winit.as_mut().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
let clipped_primitives = {
|
let clipped_primitives = {
|
||||||
crate::profile_scope!("tessellate");
|
crate::profile_scope!("tessellate");
|
||||||
@@ -1061,14 +1078,22 @@ mod glow_integration {
|
|||||||
integration.frame.screenshot.set(Some(screenshot));
|
integration.frame.screenshot.set(Some(screenshot));
|
||||||
}
|
}
|
||||||
|
|
||||||
integration.post_rendering(app.as_mut(), window);
|
integration.post_rendering(app.as_mut(), win.window.as_ref().unwrap());
|
||||||
|
|
||||||
{
|
{
|
||||||
crate::profile_scope!("swap_buffers");
|
crate::profile_scope!("swap_buffers");
|
||||||
gl_window.swap_buffers(window_index).unwrap();
|
win.gl_surface
|
||||||
|
.as_ref()
|
||||||
|
.expect("failed to get surface to swap buffers")
|
||||||
|
.swap_buffers(
|
||||||
|
gl_window
|
||||||
|
.current_gl_context
|
||||||
|
.as_ref()
|
||||||
|
.expect("failed to get current context to swap buffers"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
integration.post_present(window);
|
integration.post_present(win.window.as_ref().unwrap());
|
||||||
|
|
||||||
#[cfg(feature = "__screenshot")]
|
#[cfg(feature = "__screenshot")]
|
||||||
// give it time to settle:
|
// give it time to settle:
|
||||||
@@ -1097,7 +1122,7 @@ mod glow_integration {
|
|||||||
control_flow = if integration.should_close() {
|
control_flow = if integration.should_close() {
|
||||||
EventResult::Exit
|
EventResult::Exit
|
||||||
} else if repaint_after.is_zero() {
|
} else if repaint_after.is_zero() {
|
||||||
EventResult::RepaintNext(window.id())
|
EventResult::RepaintNext(win.window.as_ref().unwrap().id())
|
||||||
} else if let Some(repaint_after_instant) =
|
} else if let Some(repaint_after_instant) =
|
||||||
std::time::Instant::now().checked_add(repaint_after)
|
std::time::Instant::now().checked_add(repaint_after)
|
||||||
{
|
{
|
||||||
@@ -1107,14 +1132,17 @@ mod glow_integration {
|
|||||||
// winit to use `WaitUntil(MAX_INSTANT)` explicitly. they can roll their own
|
// winit to use `WaitUntil(MAX_INSTANT)` explicitly. they can roll their own
|
||||||
// egui backend impl i guess.
|
// egui backend impl i guess.
|
||||||
|
|
||||||
EventResult::RepaintAt(window.id(), repaint_after_instant)
|
EventResult::RepaintAt(
|
||||||
|
win.window.as_ref().unwrap().id(),
|
||||||
|
repaint_after_instant,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
EventResult::Wait
|
EventResult::Wait
|
||||||
};
|
};
|
||||||
|
|
||||||
integration.maybe_autosave(app.as_mut(), window);
|
integration.maybe_autosave(app.as_mut(), win.window.as_ref().unwrap());
|
||||||
|
|
||||||
if window.is_minimized() == Some(true) {
|
if win.window.as_ref().unwrap().is_minimized() == Some(true) {
|
||||||
// On Mac, a minimized Window uses up all CPU:
|
// On Mac, a minimized Window uses up all CPU:
|
||||||
// https://github.com/emilk/egui/issues/325
|
// https://github.com/emilk/egui/issues/325
|
||||||
crate::profile_scope!("bg_sleep");
|
crate::profile_scope!("bg_sleep");
|
||||||
@@ -1151,6 +1179,7 @@ mod glow_integration {
|
|||||||
gl_surface: None,
|
gl_surface: None,
|
||||||
window: None,
|
window: None,
|
||||||
window_id: id,
|
window_id: id,
|
||||||
|
egui_winit: None,
|
||||||
});
|
});
|
||||||
wins.push(id);
|
wins.push(id);
|
||||||
}
|
}
|
||||||
@@ -1262,8 +1291,22 @@ mod glow_integration {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let event_response =
|
let event_response = 'res: {
|
||||||
running.integration.on_event(running.app.as_mut(), event);
|
for window in running.gl_window.windows.iter_mut() {
|
||||||
|
if window.window.as_ref().unwrap().id() == *window_id {
|
||||||
|
break 'res running.integration.on_event(
|
||||||
|
running.app.as_mut(),
|
||||||
|
event,
|
||||||
|
window_id,
|
||||||
|
window.egui_winit.as_mut().unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventResponse {
|
||||||
|
consumed: false,
|
||||||
|
repaint: false,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if running.integration.should_close() {
|
if running.integration.should_close() {
|
||||||
EventResult::Exit
|
EventResult::Exit
|
||||||
@@ -1282,12 +1325,19 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
winit::event::Event::UserEvent(UserEvent::AccessKitActionRequest(
|
winit::event::Event::UserEvent(UserEvent::AccessKitActionRequest(
|
||||||
accesskit_winit::ActionRequestEvent { request, .. },
|
accesskit_winit::ActionRequestEvent { request, window_id },
|
||||||
)) => {
|
)) => {
|
||||||
if let Some(running) = &mut self.running {
|
if let Some(running) = &mut self.running {
|
||||||
running
|
for window in running.gl_window.windows.iter_mut() {
|
||||||
.integration
|
if window.window.as_ref().unwrap().id() == *window_id {
|
||||||
.on_accesskit_action_request(request.clone());
|
running.integration.on_accesskit_action_request(
|
||||||
|
request.clone(),
|
||||||
|
window_id,
|
||||||
|
window.egui_winit.as_mut().unwrap(),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
// As a form of user input, accessibility actions should
|
// As a form of user input, accessibility actions should
|
||||||
// lead to a repaint.
|
// lead to a repaint.
|
||||||
EventResult::RepaintNext(running.gl_window.window(0).id())
|
EventResult::RepaintNext(running.gl_window.window(0).id())
|
||||||
@@ -1417,97 +1467,98 @@ mod wgpu_integration {
|
|||||||
storage: Option<Box<dyn epi::Storage>>,
|
storage: Option<Box<dyn epi::Storage>>,
|
||||||
window: winit::window::Window,
|
window: winit::window::Window,
|
||||||
) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
||||||
#[allow(unsafe_code, unused_mut, unused_unsafe)]
|
unimplemented!();
|
||||||
let mut painter = egui_wgpu::winit::Painter::new(
|
// #[allow(unsafe_code, unused_mut, unused_unsafe)]
|
||||||
self.native_options.wgpu_options.clone(),
|
// let mut painter = egui_wgpu::winit::Painter::new(
|
||||||
self.native_options.multisampling.max(1) as _,
|
// self.native_options.wgpu_options.clone(),
|
||||||
egui_wgpu::depth_format_from_bits(
|
// self.native_options.multisampling.max(1) as _,
|
||||||
self.native_options.depth_buffer,
|
// egui_wgpu::depth_format_from_bits(
|
||||||
self.native_options.stencil_buffer,
|
// self.native_options.depth_buffer,
|
||||||
),
|
// self.native_options.stencil_buffer,
|
||||||
self.native_options.transparent,
|
// ),
|
||||||
);
|
// self.native_options.transparent,
|
||||||
pollster::block_on(painter.set_window(Some(&window)))?;
|
// );
|
||||||
|
// pollster::block_on(painter.set_window(Some(&window)))?;
|
||||||
|
|
||||||
let wgpu_render_state = painter.render_state();
|
// let wgpu_render_state = painter.render_state();
|
||||||
|
|
||||||
let system_theme = system_theme(&window, &self.native_options);
|
// let system_theme = system_theme(&window, &self.native_options);
|
||||||
let mut integration = epi_integration::EpiIntegration::new(
|
// let mut integration = epi_integration::EpiIntegration::new(
|
||||||
event_loop,
|
// event_loop,
|
||||||
painter.max_texture_side().unwrap_or(2048),
|
// painter.max_texture_side().unwrap_or(2048),
|
||||||
&window,
|
// &window,
|
||||||
system_theme,
|
// system_theme,
|
||||||
&self.app_name,
|
// &self.app_name,
|
||||||
&self.native_options,
|
// &self.native_options,
|
||||||
storage,
|
// storage,
|
||||||
#[cfg(feature = "glow")]
|
// #[cfg(feature = "glow")]
|
||||||
None,
|
// None,
|
||||||
wgpu_render_state.clone(),
|
// wgpu_render_state.clone(),
|
||||||
);
|
// );
|
||||||
#[cfg(feature = "accesskit")]
|
// #[cfg(feature = "accesskit")]
|
||||||
{
|
// {
|
||||||
integration.init_accesskit(&window, self.repaint_proxy.lock().unwrap().clone());
|
// integration.init_accesskit(&window, self.repaint_proxy.lock().unwrap().clone());
|
||||||
}
|
// }
|
||||||
let theme = system_theme.unwrap_or(self.native_options.default_theme);
|
// let theme = system_theme.unwrap_or(self.native_options.default_theme);
|
||||||
integration.egui_ctx.set_visuals(theme.egui_visuals());
|
// integration.egui_ctx.set_visuals(theme.egui_visuals());
|
||||||
|
|
||||||
window.set_ime_allowed(true);
|
// window.set_ime_allowed(true);
|
||||||
|
|
||||||
{
|
// {
|
||||||
let event_loop_proxy = self.repaint_proxy.clone();
|
// let event_loop_proxy = self.repaint_proxy.clone();
|
||||||
|
|
||||||
// !!! TODO !!!
|
// // !!! TODO !!!
|
||||||
// Need a better way to redraw all the windows idependent of one eachother
|
// // Need a better way to redraw all the windows idependent of one eachother
|
||||||
|
|
||||||
integration
|
// integration
|
||||||
.egui_ctx
|
// .egui_ctx
|
||||||
.set_request_repaint_callback(move |info| {
|
// .set_request_repaint_callback(move |info| {
|
||||||
log::trace!("request_repaint_callback: {info:?}");
|
// log::trace!("request_repaint_callback: {info:?}");
|
||||||
let when = Instant::now() + info.after;
|
// let when = Instant::now() + info.after;
|
||||||
let frame_nr = info.current_frame_nr;
|
// let frame_nr = info.current_frame_nr;
|
||||||
|
|
||||||
// !!! WARNING !!!
|
// // !!! WARNING !!!
|
||||||
// This will only work for 10 windows
|
// // This will only work for 10 windows
|
||||||
|
|
||||||
for i in 0..10 {
|
// for i in 0..10 {
|
||||||
event_loop_proxy
|
// event_loop_proxy
|
||||||
.lock()
|
// .lock()
|
||||||
.unwrap()
|
// .unwrap()
|
||||||
.send_event(UserEvent::RequestRepaint {
|
// .send_event(UserEvent::RequestRepaint {
|
||||||
when,
|
// when,
|
||||||
frame_nr,
|
// frame_nr,
|
||||||
window_id: i,
|
// window_id: i,
|
||||||
})
|
// })
|
||||||
.ok();
|
// .ok();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
let app_creator = std::mem::take(&mut self.app_creator)
|
// let app_creator = std::mem::take(&mut self.app_creator)
|
||||||
.expect("Single-use AppCreator has unexpectedly already been taken");
|
// .expect("Single-use AppCreator has unexpectedly already been taken");
|
||||||
let mut app = app_creator(&epi::CreationContext {
|
// let mut app = app_creator(&epi::CreationContext {
|
||||||
egui_ctx: integration.egui_ctx.clone(),
|
// egui_ctx: integration.egui_ctx.clone(),
|
||||||
integration_info: integration.frame.info(),
|
// integration_info: integration.frame.info(),
|
||||||
storage: integration.frame.storage(),
|
// storage: integration.frame.storage(),
|
||||||
#[cfg(feature = "glow")]
|
// #[cfg(feature = "glow")]
|
||||||
gl: None,
|
// gl: None,
|
||||||
wgpu_render_state,
|
// wgpu_render_state,
|
||||||
raw_display_handle: window.raw_display_handle(),
|
// raw_display_handle: window.raw_display_handle(),
|
||||||
raw_window_handle: window.raw_window_handle(),
|
// raw_window_handle: window.raw_window_handle(),
|
||||||
});
|
// });
|
||||||
|
|
||||||
if app.warm_up_enabled() {
|
// if app.warm_up_enabled() {
|
||||||
integration.warm_up(app.as_mut(), &window);
|
// integration.warm_up(app.as_mut(), &window);
|
||||||
}
|
// }
|
||||||
|
|
||||||
self.running = Some(WgpuWinitRunning {
|
// self.running = Some(WgpuWinitRunning {
|
||||||
painter,
|
// painter,
|
||||||
integration,
|
// integration,
|
||||||
app,
|
// app,
|
||||||
});
|
// });
|
||||||
self.window = Some(window);
|
// self.window = Some(window);
|
||||||
|
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1553,10 +1604,7 @@ mod wgpu_integration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_ui_and_paint(
|
fn run_ui_and_paint(&mut self, window_id: winit::window::WindowId) -> Vec<EventResult> {
|
||||||
&mut self,
|
|
||||||
window_id: Option<winit::window::WindowId>,
|
|
||||||
) -> Vec<EventResult> {
|
|
||||||
// !!! WARNING !!!
|
// !!! WARNING !!!
|
||||||
// Nothing is implemented for WGPU
|
// Nothing is implemented for WGPU
|
||||||
|
|
||||||
|
|||||||
@@ -160,11 +160,10 @@ struct ContextImpl {
|
|||||||
|
|
||||||
repaint: Repaint,
|
repaint: Repaint,
|
||||||
|
|
||||||
windows: HashMap<String, (WindowBuilder, u64, bool)>,
|
windows: HashMap<String, (WindowBuilder, u64, u64, bool)>,
|
||||||
window_counter: u64,
|
window_counter: u64,
|
||||||
current_rendering_window: u64,
|
current_rendering_window: u64,
|
||||||
windows_stack: Vec<u64>,
|
windows_stack: Vec<u64>,
|
||||||
current_window: u64,
|
|
||||||
is_desktop: bool,
|
is_desktop: bool,
|
||||||
|
|
||||||
/// Written to during the frame.
|
/// Written to during the frame.
|
||||||
@@ -968,7 +967,10 @@ impl Context {
|
|||||||
/// (this will work on `eframe`).
|
/// (this will work on `eframe`).
|
||||||
pub fn request_repaint(&self) {
|
pub fn request_repaint(&self) {
|
||||||
// request two frames of repaint, just to cover some corner cases (frame delays):
|
// request two frames of repaint, just to cover some corner cases (frame delays):
|
||||||
self.write(|ctx| ctx.repaint.request_repaint(ctx.current_window));
|
self.write(|ctx| {
|
||||||
|
ctx.repaint
|
||||||
|
.request_repaint(ctx.windows_stack.last().cloned().unwrap_or(0))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request repaint after at most the specified duration elapses.
|
/// Request repaint after at most the specified duration elapses.
|
||||||
@@ -1274,9 +1276,14 @@ impl Context {
|
|||||||
|
|
||||||
let mut windows = Vec::new();
|
let mut windows = Vec::new();
|
||||||
self.write(|ctx| {
|
self.write(|ctx| {
|
||||||
ctx.windows.retain(|d, (builder, id, used)| {
|
ctx.windows.retain(|_, (builder, id, parent, used)| {
|
||||||
let out = *used;
|
let out = *used;
|
||||||
*used = false;
|
if ctx.current_rendering_window == *parent || ctx.current_rendering_window == *id {
|
||||||
|
// WARNING NOT IMPLEMENTED BECAUSE THE WINDOW ONLY RENDER WHEN THE CURRENT WINDOW FRAME IS BIGGER THEN THE CURRENT FRAME
|
||||||
|
// I DONT KNOW WHY
|
||||||
|
*used = true;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
windows.push((*id, builder.clone()));
|
windows.push((*id, builder.clone()));
|
||||||
out
|
out
|
||||||
})
|
})
|
||||||
@@ -1903,7 +1910,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_window(&self) -> u64 {
|
pub fn current_window(&self) -> u64 {
|
||||||
self.read(|ctx| ctx.current_window)
|
self.read(|ctx| ctx.windows_stack.last().cloned().unwrap_or(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_desktop(&self) -> bool {
|
pub fn is_desktop(&self) -> bool {
|
||||||
@@ -1922,13 +1929,21 @@ impl Context {
|
|||||||
let id = self.write(|ctx| {
|
let id = self.write(|ctx| {
|
||||||
if ctx.is_desktop {
|
if ctx.is_desktop {
|
||||||
if let Some(window) = ctx.windows.get_mut(&window_builder.title) {
|
if let Some(window) = ctx.windows.get_mut(&window_builder.title) {
|
||||||
window.2 = true;
|
window.2 = *ctx.windows_stack.last().unwrap_or(&0);
|
||||||
|
window.3 = true;
|
||||||
window.1
|
window.1
|
||||||
} else {
|
} else {
|
||||||
let id = ctx.window_counter + 1;
|
let id = ctx.window_counter + 1;
|
||||||
ctx.window_counter = id;
|
ctx.window_counter = id;
|
||||||
ctx.windows
|
ctx.windows.insert(
|
||||||
.insert(window_builder.title.clone(), (window_builder, id, true));
|
window_builder.title.clone(),
|
||||||
|
(
|
||||||
|
window_builder,
|
||||||
|
id,
|
||||||
|
*ctx.windows_stack.last().unwrap_or(&0),
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
);
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1937,13 +1952,11 @@ impl Context {
|
|||||||
});
|
});
|
||||||
let should_render = self.write(|ctx| {
|
let should_render = self.write(|ctx| {
|
||||||
ctx.windows_stack.push(id);
|
ctx.windows_stack.push(id);
|
||||||
ctx.current_window = id;
|
ctx.windows_stack.last().cloned().unwrap_or(0) == ctx.current_rendering_window
|
||||||
ctx.current_window == ctx.current_rendering_window
|
|
||||||
});
|
});
|
||||||
let out = if should_render { Some(func(id)) } else { None };
|
let out = if should_render { Some(func(id)) } else { None };
|
||||||
self.write(|ctx| {
|
self.write(|ctx| {
|
||||||
ctx.windows_stack.pop();
|
ctx.windows_stack.pop();
|
||||||
ctx.current_window = ctx.windows_stack.pop().unwrap_or(0);
|
|
||||||
});
|
});
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,24 @@ fn main() -> Result<(), eframe::Error> {
|
|||||||
egui::Window::new("Test1")
|
egui::Window::new("Test1")
|
||||||
.embedded(window1_embedded)
|
.embedded(window1_embedded)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.checkbox(&mut window1_embedded, "Should embedd?")
|
ui.checkbox(&mut window1_embedded, "Should embedd?");
|
||||||
|
ui.label(format!(
|
||||||
|
"Current window: {}, Current rendering window: {}",
|
||||||
|
ctx.current_window(),
|
||||||
|
ctx.current_rendering_window()
|
||||||
|
));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
egui::CollapsingHeader::new("Shout Test2").show(ui, |ui| {
|
egui::CollapsingHeader::new("Shout Test2").show(ui, |ui| {
|
||||||
egui::Window::new("Test2")
|
egui::Window::new("Test2")
|
||||||
.embedded(window2_embedded)
|
.embedded(window2_embedded)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.checkbox(&mut window2_embedded, "Should embedd?")
|
ui.checkbox(&mut window2_embedded, "Should embedd?");
|
||||||
|
ui.label(format!(
|
||||||
|
"Current window: {}, Current rendering window: {}",
|
||||||
|
ctx.current_window(),
|
||||||
|
ctx.current_rendering_window()
|
||||||
|
));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user