mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Fix some warnings
This commit is contained in:
@@ -284,7 +284,7 @@ pub fn run_simple_native(
|
|||||||
if ctx.get_viewport_id() == ViewportId::MAIN {
|
if ctx.get_viewport_id() == ViewportId::MAIN {
|
||||||
(self.update_fun)(ctx, frame);
|
(self.update_fun)(ctx, frame);
|
||||||
} else if let Some(render_function) = render {
|
} else if let Some(render_function) = render {
|
||||||
render_function(ctx)
|
render_function(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use raw_window_handle::{HasRawDisplayHandle as _, HasRawWindowHandle as _};
|
|||||||
|
|
||||||
#[cfg(feature = "accesskit")]
|
#[cfg(feature = "accesskit")]
|
||||||
use egui::accesskit;
|
use egui::accesskit;
|
||||||
use egui::{Context, NumExt as _, ViewportBuilder, ViewportId, ViewportRender};
|
use egui::{NumExt as _, ViewportBuilder, ViewportId, ViewportRender};
|
||||||
#[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};
|
||||||
|
|||||||
@@ -234,8 +234,7 @@ fn run_and_return(
|
|||||||
window_id,
|
window_id,
|
||||||
windows_next_repaint_times
|
windows_next_repaint_times
|
||||||
.get(&window_id)
|
.get(&window_id)
|
||||||
.map(|last| (*last).min(repaint_time))
|
.map_or(repaint_time, |last| (*last).min(repaint_time)),
|
||||||
.unwrap_or(repaint_time),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
EventResult::Exit => {
|
EventResult::Exit => {
|
||||||
@@ -248,7 +247,7 @@ fn run_and_return(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut next_repaint_time = Option::<Instant>::None;
|
let mut next_repaint_time = Option::<Instant>::None;
|
||||||
for (window_id, repaint_time) in windows_next_repaint_times.clone().iter() {
|
for (window_id, repaint_time) in &windows_next_repaint_times.clone() {
|
||||||
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) {
|
||||||
window.read().request_redraw();
|
window.read().request_redraw();
|
||||||
@@ -259,11 +258,8 @@ fn run_and_return(
|
|||||||
control_flow.set_wait();
|
control_flow.set_wait();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next_repaint_time = Some(
|
next_repaint_time =
|
||||||
next_repaint_time
|
Some(next_repaint_time.map_or(*repaint_time, |last| last.min(*repaint_time)));
|
||||||
.map(|last| last.min(*repaint_time))
|
|
||||||
.unwrap_or(*repaint_time),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,8 +368,7 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
window_id,
|
window_id,
|
||||||
windows_next_repaint_times
|
windows_next_repaint_times
|
||||||
.get(&window_id)
|
.get(&window_id)
|
||||||
.map(|last| (*last).min(repaint_time))
|
.map_or(repaint_time, |last| (*last).min(repaint_time)),
|
||||||
.unwrap_or(repaint_time),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
EventResult::Exit => {
|
EventResult::Exit => {
|
||||||
@@ -386,7 +381,7 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut next_repaint_time = Option::<Instant>::None;
|
let mut next_repaint_time = Option::<Instant>::None;
|
||||||
for (window_id, repaint_time) in windows_next_repaint_times.clone().iter() {
|
for (window_id, repaint_time) in &windows_next_repaint_times.clone() {
|
||||||
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");
|
log::trace!("request_redraw");
|
||||||
@@ -395,11 +390,8 @@ fn run_and_exit(event_loop: EventLoop<UserEvent>, mut winit_app: impl WinitApp +
|
|||||||
}
|
}
|
||||||
control_flow.set_poll();
|
control_flow.set_poll();
|
||||||
} else {
|
} else {
|
||||||
next_repaint_time = Some(
|
next_repaint_time =
|
||||||
next_repaint_time
|
Some(next_repaint_time.map_or(*repaint_time, |last| last.min(*repaint_time)));
|
||||||
.map(|last| last.min(*repaint_time))
|
|
||||||
.unwrap_or(*repaint_time),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +420,6 @@ mod glow_integration {
|
|||||||
prelude::{GlDisplay, NotCurrentGlContextSurfaceAccessor, PossiblyCurrentGlContext},
|
prelude::{GlDisplay, NotCurrentGlContextSurfaceAccessor, PossiblyCurrentGlContext},
|
||||||
surface::GlSurface,
|
surface::GlSurface,
|
||||||
};
|
};
|
||||||
use winit::{dpi::PhysicalSize, window::ResizeDirection};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -642,7 +633,7 @@ mod glow_integration {
|
|||||||
/// we presently assume that we will
|
/// we presently assume that we will
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn on_resume(&mut self, event_loop: &EventLoopWindowTarget<UserEvent>) -> Result<()> {
|
fn on_resume(&mut self, event_loop: &EventLoopWindowTarget<UserEvent>) -> Result<()> {
|
||||||
for (_, win) in self.windows.iter_mut() {
|
for win in self.windows.values_mut() {
|
||||||
let mut win = win.write();
|
let mut win = win.write();
|
||||||
if win.gl_surface.is_some() {
|
if win.gl_surface.is_some() {
|
||||||
continue;
|
continue;
|
||||||
@@ -727,7 +718,7 @@ mod glow_integration {
|
|||||||
/// only applies for android. but we basically drop surface + window and make context not current
|
/// only applies for android. but we basically drop surface + window and make context not current
|
||||||
fn on_suspend(&mut self) -> Result<()> {
|
fn on_suspend(&mut self) -> Result<()> {
|
||||||
log::debug!("received suspend event. dropping window and surface");
|
log::debug!("received suspend event. dropping window and surface");
|
||||||
for (_, window) in self.windows.iter_mut() {
|
for window in self.windows.values() {
|
||||||
let mut window = window.write();
|
let mut window = window.write();
|
||||||
window.gl_surface.take();
|
window.gl_surface.take();
|
||||||
window.window.take();
|
window.window.take();
|
||||||
@@ -744,7 +735,7 @@ mod glow_integration {
|
|||||||
fn window(&self, viewport_id: ViewportId) -> Arc<RwLock<Window>> {
|
fn window(&self, viewport_id: ViewportId) -> Arc<RwLock<Window>> {
|
||||||
self.windows
|
self.windows
|
||||||
.get(&viewport_id)
|
.get(&viewport_id)
|
||||||
.map(|w| w.clone())
|
.cloned()
|
||||||
.expect("winit window doesn't exist")
|
.expect("winit window doesn't exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,7 +748,7 @@ mod glow_integration {
|
|||||||
let height = std::num::NonZeroU32::new(physical_size.height.at_least(1)).unwrap();
|
let height = std::num::NonZeroU32::new(physical_size.height.at_least(1)).unwrap();
|
||||||
|
|
||||||
if let Some(window) = self.windows.get(&viewport_id) {
|
if let Some(window) = self.windows.get(&viewport_id) {
|
||||||
let mut window = window.write();
|
let window = window.read();
|
||||||
if let Some(gl_surface) = &window.gl_surface {
|
if let Some(gl_surface) = &window.gl_surface {
|
||||||
self.current_gl_context = Some(
|
self.current_gl_context = Some(
|
||||||
self.current_gl_context
|
self.current_gl_context
|
||||||
@@ -859,7 +850,7 @@ mod glow_integration {
|
|||||||
.unwrap_or(&self.app_name),
|
.unwrap_or(&self.app_name),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (mut gl_window, gl) = Self::create_glutin_windowed_context(
|
let (gl_window, gl) = Self::create_glutin_windowed_context(
|
||||||
event_loop,
|
event_loop,
|
||||||
storage.as_deref(),
|
storage.as_deref(),
|
||||||
&self.app_name,
|
&self.app_name,
|
||||||
@@ -1068,7 +1059,7 @@ mod glow_integration {
|
|||||||
break 'try_render;
|
break 'try_render;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::process_viewport_builders(glutin.clone(), output.viewports);
|
Self::process_viewport_builders(&glutin, output.viewports);
|
||||||
egui_winit::process_viewport_commands(
|
egui_winit::process_viewport_commands(
|
||||||
output.viewport_commands,
|
output.viewport_commands,
|
||||||
*focused.read(),
|
*focused.read(),
|
||||||
@@ -1099,7 +1090,7 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process_viewport_builders(
|
fn process_viewport_builders(
|
||||||
glutin_ctx: Arc<RwLock<GlutinWindowContext>>,
|
glutin_ctx: &Arc<RwLock<GlutinWindowContext>>,
|
||||||
mut viewports: Vec<(
|
mut viewports: Vec<(
|
||||||
ViewportId,
|
ViewportId,
|
||||||
ViewportId,
|
ViewportId,
|
||||||
@@ -1210,11 +1201,11 @@ mod glow_integration {
|
|||||||
self.running
|
self.running
|
||||||
.read()
|
.read()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|r| r.glutin_ctx.read().window_maps.get(id).cloned())
|
.and_then(|r| r.glutin_ctx.read().window_maps.get(id).copied())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_and_destroy(&mut self) {
|
fn save_and_destroy(&mut self) {
|
||||||
if let Some(mut running) = self.running.write().take() {
|
if let Some(running) = self.running.write().take() {
|
||||||
running.integration.write().save(
|
running.integration.write().save(
|
||||||
running.app.write().as_mut(),
|
running.app.write().as_mut(),
|
||||||
&running
|
&running
|
||||||
@@ -1242,8 +1233,6 @@ mod glow_integration {
|
|||||||
puffin::GlobalProfiler::lock().new_frame();
|
puffin::GlobalProfiler::lock().new_frame();
|
||||||
crate::profile_scope!("frame");
|
crate::profile_scope!("frame");
|
||||||
|
|
||||||
let running = self.running.clone();
|
|
||||||
|
|
||||||
let integration = self.running.read().as_ref().unwrap().integration.clone();
|
let integration = self.running.read().as_ref().unwrap().integration.clone();
|
||||||
let app = self.running.read().as_ref().unwrap().app.clone();
|
let app = self.running.read().as_ref().unwrap().app.clone();
|
||||||
let glutin_ctx = self.running.read().as_ref().unwrap().glutin_ctx.clone();
|
let glutin_ctx = self.running.read().as_ref().unwrap().glutin_ctx.clone();
|
||||||
@@ -1255,17 +1244,16 @@ mod glow_integration {
|
|||||||
let win = glutin_ctx.read().windows.get(&viewport_id).unwrap().clone();
|
let win = glutin_ctx.read().windows.get(&viewport_id).unwrap().clone();
|
||||||
if win.read().render.is_none() && viewport_id != ViewportId::MAIN {
|
if win.read().render.is_none() && viewport_id != ViewportId::MAIN {
|
||||||
if let Some(win) = glutin_ctx.read().windows.get(&win.read().parent_id) {
|
if let Some(win) = glutin_ctx.read().windows.get(&win.read().parent_id) {
|
||||||
win.read()
|
if let Some(w) = win.read().window.as_ref() {
|
||||||
.window
|
w.read().request_redraw();
|
||||||
.as_ref()
|
}
|
||||||
.map(|w| w.read().request_redraw());
|
|
||||||
}
|
}
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut window_map = HashMap::default();
|
let mut window_map = HashMap::default();
|
||||||
for (id, window) in glutin_ctx.read().windows.iter() {
|
for (id, window) in &glutin_ctx.read().windows {
|
||||||
if let Some(win) = &window.read().window {
|
if let Some(win) = &window.read().window {
|
||||||
window_map.insert(*id, win.read().id());
|
window_map.insert(*id, win.read().id());
|
||||||
}
|
}
|
||||||
@@ -1276,7 +1264,7 @@ mod glow_integration {
|
|||||||
repaint_after,
|
repaint_after,
|
||||||
textures_delta,
|
textures_delta,
|
||||||
shapes,
|
shapes,
|
||||||
mut viewports,
|
viewports,
|
||||||
viewport_commands,
|
viewport_commands,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1418,7 +1406,7 @@ mod glow_integration {
|
|||||||
} else {
|
} else {
|
||||||
repaint_after
|
repaint_after
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|(id, time)| {
|
.filter_map(|(id, time)| {
|
||||||
if time.is_zero() {
|
if time.is_zero() {
|
||||||
window_map.get(&id).map(|id| EventResult::RepaintNext(*id))
|
window_map.get(&id).map(|id| EventResult::RepaintNext(*id))
|
||||||
} else if let Some(repaint_after_instant) =
|
} else if let Some(repaint_after_instant) =
|
||||||
@@ -1453,7 +1441,7 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::process_viewport_builders(glutin_ctx.clone(), viewports);
|
Self::process_viewport_builders(&glutin_ctx, viewports);
|
||||||
|
|
||||||
egui_winit::process_viewport_commands(
|
egui_winit::process_viewport_commands(
|
||||||
viewport_commands,
|
viewport_commands,
|
||||||
@@ -1556,7 +1544,7 @@ mod glow_integration {
|
|||||||
.write()
|
.write()
|
||||||
.window_maps
|
.window_maps
|
||||||
.get(window_id)
|
.get(window_id)
|
||||||
.cloned()
|
.copied()
|
||||||
})
|
})
|
||||||
.flatten();
|
.flatten();
|
||||||
}
|
}
|
||||||
@@ -1589,7 +1577,7 @@ mod glow_integration {
|
|||||||
.write()
|
.write()
|
||||||
.windows
|
.windows
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|(_, window)| {
|
.filter_map(|(_, window)| {
|
||||||
if let Some(win) = window.read().window.as_ref() {
|
if let Some(win) = window.read().window.as_ref() {
|
||||||
let win = win.read();
|
let win = win.read();
|
||||||
if win.id() == *window_id {
|
if win.id() == *window_id {
|
||||||
@@ -1601,7 +1589,7 @@ mod glow_integration {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.flat_map(|id| {
|
.filter_map(|id| {
|
||||||
if id == ViewportId::MAIN {
|
if id == ViewportId::MAIN {
|
||||||
Some(())
|
Some(())
|
||||||
} else {
|
} else {
|
||||||
@@ -1621,7 +1609,7 @@ mod glow_integration {
|
|||||||
let event_response = 'res: {
|
let event_response = 'res: {
|
||||||
let glutin_ctx = running.glutin_ctx.read();
|
let glutin_ctx = running.glutin_ctx.read();
|
||||||
if let Some(viewport_id) =
|
if let Some(viewport_id) =
|
||||||
glutin_ctx.window_maps.get(window_id).cloned()
|
glutin_ctx.window_maps.get(window_id).copied()
|
||||||
{
|
{
|
||||||
if let Some(viewport) =
|
if let Some(viewport) =
|
||||||
glutin_ctx.windows.get(&viewport_id).cloned()
|
glutin_ctx.windows.get(&viewport_id).cloned()
|
||||||
@@ -1665,14 +1653,14 @@ mod glow_integration {
|
|||||||
)) => {
|
)) => {
|
||||||
if let Some(running) = self.running.read().as_ref() {
|
if let Some(running) = self.running.read().as_ref() {
|
||||||
let glutin_ctx = running.glutin_ctx.read();
|
let glutin_ctx = running.glutin_ctx.read();
|
||||||
if let Some(viewport_id) = glutin_ctx.window_maps.get(window_id).cloned() {
|
if let Some(viewport_id) = glutin_ctx.window_maps.get(window_id).copied() {
|
||||||
if let Some(viewport) = glutin_ctx.windows.get(&viewport_id).cloned() {
|
if let Some(viewport) = glutin_ctx.windows.get(&viewport_id).cloned() {
|
||||||
let mut viewport = viewport.write();
|
let mut viewport = viewport.write();
|
||||||
running.integration.write().on_accesskit_action_request(
|
running.integration.write().on_accesskit_action_request(
|
||||||
request.clone(),
|
request.clone(),
|
||||||
window_id,
|
window_id,
|
||||||
viewport.egui_winit.as_mut().unwrap(),
|
viewport.egui_winit.as_mut().unwrap(),
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// As a form of user input, accessibility actions should
|
// As a form of user input, accessibility actions should
|
||||||
@@ -1828,13 +1816,14 @@ mod wgpu_integration {
|
|||||||
|
|
||||||
for (id, (window, state, _, _, builder)) in running.windows.write().iter_mut() {
|
for (id, (window, state, _, _, builder)) in running.windows.write().iter_mut() {
|
||||||
if window.is_none() {
|
if window.is_none() {
|
||||||
if let Ok(new_window) = create_winit_window_builder(&builder).build(event_loop)
|
if let Ok(new_window) = create_winit_window_builder(builder).build(event_loop) {
|
||||||
{
|
|
||||||
running.windows_id.insert(new_window.id(), *id);
|
running.windows_id.insert(new_window.id(), *id);
|
||||||
|
|
||||||
pollster::block_on(
|
if let Err(err) = pollster::block_on(
|
||||||
running.painter.write().set_window(*id, Some(&new_window)),
|
running.painter.write().set_window(*id, Some(&new_window)),
|
||||||
);
|
) {
|
||||||
|
log::error!("on set_window: viewport_id {id} {err}");
|
||||||
|
}
|
||||||
*window = Some(Arc::new(RwLock::new(new_window)));
|
*window = Some(Arc::new(RwLock::new(new_window)));
|
||||||
*state.write() = Some(egui_winit::State::new(event_loop));
|
*state.write() = Some(egui_winit::State::new(event_loop));
|
||||||
}
|
}
|
||||||
@@ -1844,10 +1833,10 @@ mod wgpu_integration {
|
|||||||
|
|
||||||
fn set_window(&mut self, id: ViewportId) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
fn set_window(&mut self, id: ViewportId) -> std::result::Result<(), egui_wgpu::WgpuError> {
|
||||||
if let Some(running) = &mut self.running {
|
if let Some(running) = &mut self.running {
|
||||||
if let Some((window, _, _, _, _)) = running.windows.read().get(&id) {
|
if let Some((Some(window), _, _, _, _)) = running.windows.read().get(&id) {
|
||||||
window.as_ref().map(|w| {
|
return pollster::block_on(
|
||||||
pollster::block_on(running.painter.write().set_window(id, Some(&w.read())))
|
running.painter.write().set_window(id, Some(&window.read())),
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1994,9 +1983,11 @@ mod wgpu_integration {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
pollster::block_on(
|
if let Err(err) = pollster::block_on(
|
||||||
_painter.write().set_window(viewport_id, Some(&win)),
|
_painter.write().set_window(viewport_id, Some(&win)),
|
||||||
);
|
){
|
||||||
|
log::error!("when rendering viewport_id: {viewport_id}, set_window Error {err}");
|
||||||
|
}
|
||||||
|
|
||||||
let clipped_primitives = egui_ctx.tessellate(output.shapes);
|
let clipped_primitives = egui_ctx.tessellate(output.shapes);
|
||||||
_painter.write().paint_and_update_textures(
|
_painter.write().paint_and_update_textures(
|
||||||
@@ -2024,12 +2015,12 @@ mod wgpu_integration {
|
|||||||
let mut viewports = output.viewports;
|
let mut viewports = output.viewports;
|
||||||
let mut active_viewports_ids = vec![ViewportId::MAIN];
|
let mut active_viewports_ids = vec![ViewportId::MAIN];
|
||||||
|
|
||||||
viewports.retain_mut(|(id, parent, builder, render)| {
|
viewports.retain_mut(|(id, parent, _builder, render)| {
|
||||||
if let Some(w) = _windows.write().get_mut(id) {
|
if let Some(w) = _windows.write().get_mut(id) {
|
||||||
w.2 = render.clone();
|
w.2 = render.clone();
|
||||||
w.3 = *parent;
|
w.3 = *parent;
|
||||||
active_viewports_ids.push(*id);
|
active_viewports_ids.push(*id);
|
||||||
return false;
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -2075,10 +2066,8 @@ mod wgpu_integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_focused(&self, window_id: winit::window::WindowId) -> bool {
|
fn is_focused(&self, window_id: winit::window::WindowId) -> bool {
|
||||||
if let Some(focus) = self.is_focused.read().clone() {
|
if let Some(focus) = *self.is_focused.read() {
|
||||||
self.get_window_id(&window_id)
|
self.get_window_id(&window_id).map_or(false, |i| i == focus)
|
||||||
.map(|i| i == focus)
|
|
||||||
.unwrap_or(false)
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -2119,7 +2108,7 @@ mod wgpu_integration {
|
|||||||
running
|
running
|
||||||
.integration
|
.integration
|
||||||
.write()
|
.write()
|
||||||
.save(running.app.as_mut(), &*window.read());
|
.save(running.app.as_mut(), &window.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
@@ -2159,7 +2148,9 @@ mod wgpu_integration {
|
|||||||
// This is used to not render a viewport if is sync
|
// This is used to not render a viewport if is sync
|
||||||
if viewport_id != ViewportId::MAIN && render.is_none() {
|
if viewport_id != ViewportId::MAIN && render.is_none() {
|
||||||
if let Some(window) = running.windows.read().get(&parent_viewport_id) {
|
if let Some(window) = running.windows.read().get(&parent_viewport_id) {
|
||||||
window.0.as_ref().map(|w| w.read().request_redraw());
|
if let Some(w) = window.0.as_ref() {
|
||||||
|
w.read().request_redraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
@@ -2179,7 +2170,7 @@ mod wgpu_integration {
|
|||||||
viewport_commands,
|
viewport_commands,
|
||||||
} = integration.write().update(
|
} = integration.write().update(
|
||||||
app.as_mut(),
|
app.as_mut(),
|
||||||
&*window.read(),
|
&window.read(),
|
||||||
state.write().as_mut().unwrap(),
|
state.write().as_mut().unwrap(),
|
||||||
render.clone(),
|
render.clone(),
|
||||||
viewport_id,
|
viewport_id,
|
||||||
@@ -2217,12 +2208,12 @@ mod wgpu_integration {
|
|||||||
|
|
||||||
let mut active_viewports_ids = vec![ViewportId::MAIN];
|
let mut active_viewports_ids = vec![ViewportId::MAIN];
|
||||||
|
|
||||||
viewports.retain_mut(|(id, parent, builder, render)| {
|
viewports.retain_mut(|(id, parent, _builder, render)| {
|
||||||
if let Some(w) = windows.write().get_mut(id) {
|
if let Some(w) = windows.write().get_mut(id) {
|
||||||
w.2 = render.clone();
|
w.2 = render.clone();
|
||||||
w.3 = *parent;
|
w.3 = *parent;
|
||||||
active_viewports_ids.push(*id);
|
active_viewports_ids.push(*id);
|
||||||
return false;
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -2308,7 +2299,7 @@ mod wgpu_integration {
|
|||||||
winit::event::Event::Resumed => {
|
winit::event::Event::Resumed => {
|
||||||
if let Some(running) = &self.running {
|
if let Some(running) = &self.running {
|
||||||
if running.windows.read().get(&ViewportId::MAIN).is_none() {
|
if running.windows.read().get(&ViewportId::MAIN).is_none() {
|
||||||
let window = Self::create_window(
|
let _ = Self::create_window(
|
||||||
event_loop,
|
event_loop,
|
||||||
running.integration.read().frame.storage(),
|
running.integration.read().frame.storage(),
|
||||||
&self.app_name,
|
&self.app_name,
|
||||||
@@ -2382,7 +2373,7 @@ mod wgpu_integration {
|
|||||||
// See: https://github.com/rust-windowing/winit/issues/208
|
// See: https://github.com/rust-windowing/winit/issues/208
|
||||||
// This solves an issue where the app would panic when minimizing on Windows.
|
// This solves an issue where the app would panic when minimizing on Windows.
|
||||||
if let Some(viewport_id) =
|
if let Some(viewport_id) =
|
||||||
running.windows_id.get(window_id).cloned()
|
running.windows_id.get(window_id).copied()
|
||||||
{
|
{
|
||||||
if physical_size.width > 0 && physical_size.height > 0 {
|
if physical_size.width > 0 && physical_size.height > 0 {
|
||||||
running.painter.write().on_window_resized(
|
running.painter.write().on_window_resized(
|
||||||
@@ -2398,7 +2389,7 @@ mod wgpu_integration {
|
|||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(viewport_id) =
|
if let Some(viewport_id) =
|
||||||
running.windows_id.get(window_id).cloned()
|
running.windows_id.get(window_id).copied()
|
||||||
{
|
{
|
||||||
repaint_asap = true;
|
repaint_asap = true;
|
||||||
running.painter.write().on_window_resized(
|
running.painter.write().on_window_resized(
|
||||||
@@ -2488,7 +2479,7 @@ mod wgpu_integration {
|
|||||||
fn get_window_id(&self, id: &winit::window::WindowId) -> Option<ViewportId> {
|
fn get_window_id(&self, id: &winit::window::WindowId) -> Option<ViewportId> {
|
||||||
self.running
|
self.running
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|r| r.windows_id.get(id).cloned())
|
.and_then(|r| r.windows_id.get(id).copied())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2542,7 +2533,7 @@ fn create_winit_window_builder(builder: &ViewportBuilder) -> winit::window::Wind
|
|||||||
.with_fullscreen(
|
.with_fullscreen(
|
||||||
builder
|
builder
|
||||||
.fullscreen
|
.fullscreen
|
||||||
.then(|| winit::window::Fullscreen::Borderless(None)),
|
.then_some(winit::window::Fullscreen::Borderless(None)),
|
||||||
)
|
)
|
||||||
.with_enabled_buttons(
|
.with_enabled_buttons(
|
||||||
WindowButtons::MAXIMIZE
|
WindowButtons::MAXIMIZE
|
||||||
@@ -2580,7 +2571,7 @@ fn create_winit_window_builder(builder: &ViewportBuilder) -> winit::window::Wind
|
|||||||
rgba: icon.2,
|
rgba: icon.2,
|
||||||
width: icon.0,
|
width: icon.0,
|
||||||
height: icon.1,
|
height: icon.1,
|
||||||
}))
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
window_builder
|
window_builder
|
||||||
|
|||||||
@@ -920,7 +920,8 @@ pub fn process_viewport_commands(
|
|||||||
// if this is not checked on x11 the input will be permanently taken until the app is killed!
|
// if this is not checked on x11 the input will be permanently taken until the app is killed!
|
||||||
if let Some(focus) = focused {
|
if let Some(focus) = focused {
|
||||||
if focus == viewport_id {
|
if focus == viewport_id {
|
||||||
win.drag_window();
|
// TODO possibile return the error to `egui::Context`
|
||||||
|
let _ = win.drag_window();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -930,10 +931,10 @@ pub fn process_viewport_commands(
|
|||||||
win.set_inner_size(PhysicalSize::new(width, height));
|
win.set_inner_size(PhysicalSize::new(width, height));
|
||||||
}
|
}
|
||||||
egui::ViewportCommand::Resize(top, bottom, right, left) => {
|
egui::ViewportCommand::Resize(top, bottom, right, left) => {
|
||||||
win.drag_resize_window(match (top, bottom, right, left) {
|
// TODO posibile return the error to `egui::Context`
|
||||||
|
let _ = win.drag_resize_window(match (top, bottom, right, left) {
|
||||||
(true, false, false, false) => ResizeDirection::North,
|
(true, false, false, false) => ResizeDirection::North,
|
||||||
(false, true, false, false) => ResizeDirection::South,
|
(false, true, false, false) => ResizeDirection::South,
|
||||||
(false, false, true, false) => ResizeDirection::East,
|
|
||||||
(false, false, false, true) => ResizeDirection::West,
|
(false, false, false, true) => ResizeDirection::West,
|
||||||
(true, false, true, false) => ResizeDirection::NorthEast,
|
(true, false, true, false) => ResizeDirection::NorthEast,
|
||||||
(false, true, true, false) => ResizeDirection::SouthEast,
|
(false, true, true, false) => ResizeDirection::SouthEast,
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ impl<'open> Window<'open> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn show_async(self, ctx: &Context, add_contents: impl Fn(&mut Ui) + Send + Sync + 'static) {
|
pub fn show_async(self, ctx: &Context, add_contents: impl Fn(&mut Ui) + Send + Sync + 'static) {
|
||||||
self.show_dyn_async(ctx, Box::new(add_contents))
|
self.show_dyn_async(ctx, Box::new(add_contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_dyn<'a, R>(
|
fn show_dyn<'a, R>(
|
||||||
@@ -447,12 +447,9 @@ impl<'open> Window<'open> {
|
|||||||
area_id.with("frame_resize"),
|
area_id.with("frame_resize"),
|
||||||
last_frame_outer_rect,
|
last_frame_outer_rect,
|
||||||
)
|
)
|
||||||
.and_then(|window_interaction| {
|
.map(|window_interaction| {
|
||||||
// Calculate roughly how much larger the window size is compared to the inner rect
|
// Calculate roughly how much larger the window size is compared to the inner rect
|
||||||
|
|
||||||
let pointer_pos = ctx.input(|i| i.pointer.interact_pos())?;
|
|
||||||
let mut rect = window_interaction.start_rect; // prevent drift
|
|
||||||
|
|
||||||
window_interaction.set_cursor(ctx);
|
window_interaction.set_cursor(ctx);
|
||||||
if window_interaction.is_resize() {
|
if window_interaction.is_resize() {
|
||||||
ctx.viewport_command(
|
ctx.viewport_command(
|
||||||
@@ -464,12 +461,11 @@ impl<'open> Window<'open> {
|
|||||||
window_interaction.left,
|
window_interaction.left,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else if ctx.input(|i| i.pointer.primary_pressed()) {
|
||||||
if ctx.input(|i| i.pointer.primary_pressed()) {}
|
|
||||||
}
|
}
|
||||||
ctx.memory_mut(|mem| mem.areas.move_to_top(area_layer_id));
|
ctx.memory_mut(|mem| mem.areas.move_to_top(area_layer_id));
|
||||||
|
|
||||||
Some(window_interaction)
|
window_interaction
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -488,8 +484,6 @@ impl<'open> Window<'open> {
|
|||||||
let mut frame = frame.begin(&mut area_content_ui);
|
let mut frame = frame.begin(&mut area_content_ui);
|
||||||
|
|
||||||
let title_bar = if with_title_bar {
|
let title_bar = if with_title_bar {
|
||||||
let mut tmp_embedded = is_embedded;
|
|
||||||
|
|
||||||
let title_bar = show_title_bar(
|
let title_bar = show_title_bar(
|
||||||
&mut frame.content_ui,
|
&mut frame.content_ui,
|
||||||
title,
|
title,
|
||||||
@@ -499,11 +493,6 @@ impl<'open> Window<'open> {
|
|||||||
area_id,
|
area_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if tmp_embedded != is_embedded {
|
|
||||||
area_content_ui.data_mut(|data| {
|
|
||||||
data.insert_persisted(area_id.with("_embedded"), tmp_embedded)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
resize.min_size.x = resize.min_size.x.at_least(title_bar.rect.width()); // Prevent making window smaller than title bar width
|
resize.min_size.x = resize.min_size.x.at_least(title_bar.rect.width()); // Prevent making window smaller than title bar width
|
||||||
Some(title_bar)
|
Some(title_bar)
|
||||||
} else {
|
} else {
|
||||||
@@ -526,7 +515,7 @@ impl<'open> Window<'open> {
|
|||||||
})
|
})
|
||||||
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
||||||
if let Some(content_response) = &content_response {
|
if let Some(content_response) = &content_response {
|
||||||
size = content_response.rect.size()
|
size = content_response.rect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
let outer_rect = frame.end(&mut area_content_ui).rect;
|
let outer_rect = frame.end(&mut area_content_ui).rect;
|
||||||
@@ -605,12 +594,11 @@ impl<'open> Window<'open> {
|
|||||||
ctx.request_repaint_viewport(ctx.get_parent_viewport_id());
|
ctx.request_repaint_viewport(ctx.get_parent_viewport_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(InnerResponse {
|
Some(InnerResponse {
|
||||||
inner: content_inner,
|
inner: content_inner,
|
||||||
response: full_response,
|
response: full_response,
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let frame = frame.unwrap_or_else(|| Frame::window(&ctx.style()));
|
let frame = frame.unwrap_or_else(|| Frame::window(&ctx.style()));
|
||||||
@@ -680,8 +668,6 @@ impl<'open> Window<'open> {
|
|||||||
let mut frame = frame.begin(&mut area_content_ui);
|
let mut frame = frame.begin(&mut area_content_ui);
|
||||||
|
|
||||||
let title_bar = if with_title_bar {
|
let title_bar = if with_title_bar {
|
||||||
let mut tmp_embedded = is_embedded;
|
|
||||||
|
|
||||||
let title_bar = show_title_bar(
|
let title_bar = show_title_bar(
|
||||||
&mut frame.content_ui,
|
&mut frame.content_ui,
|
||||||
title,
|
title,
|
||||||
@@ -713,7 +699,7 @@ impl<'open> Window<'open> {
|
|||||||
})
|
})
|
||||||
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
||||||
if let Some(content_response) = &content_response {
|
if let Some(content_response) = &content_response {
|
||||||
size = content_response.rect.size()
|
size = content_response.rect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
let outer_rect = frame.end(&mut area_content_ui).rect;
|
let outer_rect = frame.end(&mut area_content_ui).rect;
|
||||||
@@ -771,7 +757,7 @@ impl<'open> Window<'open> {
|
|||||||
Some(inner_response)
|
Some(inner_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_dyn_async<'a>(self, ctx: &Context, add_contents: Box<dyn Fn(&mut Ui) + Send + Sync>) {
|
fn show_dyn_async(self, ctx: &Context, add_contents: Box<dyn Fn(&mut Ui) + Send + Sync>) {
|
||||||
let Window {
|
let Window {
|
||||||
title,
|
title,
|
||||||
mut open,
|
mut open,
|
||||||
@@ -915,12 +901,9 @@ impl<'open> Window<'open> {
|
|||||||
area_id.with("frame_resize"),
|
area_id.with("frame_resize"),
|
||||||
last_frame_outer_rect,
|
last_frame_outer_rect,
|
||||||
)
|
)
|
||||||
.and_then(|window_interaction| {
|
.map(|window_interaction| {
|
||||||
// Calculate roughly how much larger the window size is compared to the inner rect
|
// Calculate roughly how much larger the window size is compared to the inner rect
|
||||||
|
|
||||||
let pointer_pos = ctx.input(|i| i.pointer.interact_pos())?;
|
|
||||||
let mut rect = window_interaction.start_rect; // prevent drift
|
|
||||||
|
|
||||||
window_interaction.set_cursor(ctx);
|
window_interaction.set_cursor(ctx);
|
||||||
if window_interaction.is_resize() {
|
if window_interaction.is_resize() {
|
||||||
ctx.viewport_command(
|
ctx.viewport_command(
|
||||||
@@ -932,12 +915,11 @@ impl<'open> Window<'open> {
|
|||||||
window_interaction.left,
|
window_interaction.left,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else if ctx.input(|i| i.pointer.primary_pressed()) {
|
||||||
if ctx.input(|i| i.pointer.primary_pressed()) {}
|
|
||||||
}
|
}
|
||||||
ctx.memory_mut(|mem| mem.areas.move_to_top(area_layer_id));
|
ctx.memory_mut(|mem| mem.areas.move_to_top(area_layer_id));
|
||||||
|
|
||||||
Some(window_interaction)
|
window_interaction
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -950,7 +932,7 @@ impl<'open> Window<'open> {
|
|||||||
|
|
||||||
let mut size = Vec2::new(1.0, 1.0);
|
let mut size = Vec2::new(1.0, 1.0);
|
||||||
|
|
||||||
let content_inner = {
|
let _content_inner = {
|
||||||
// BEGIN FRAME --------------------------------
|
// BEGIN FRAME --------------------------------
|
||||||
let frame_stroke = frame.stroke;
|
let frame_stroke = frame.stroke;
|
||||||
let mut frame = frame.begin(&mut area_content_ui);
|
let mut frame = frame.begin(&mut area_content_ui);
|
||||||
@@ -979,15 +961,15 @@ impl<'open> Window<'open> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if scroll.has_any_bar() {
|
if scroll.has_any_bar() {
|
||||||
scroll.show(ui, |ui| add_contents(ui)).inner
|
scroll.show(ui, |ui| add_contents(ui));
|
||||||
} else {
|
} else {
|
||||||
add_contents(ui)
|
add_contents(ui);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
||||||
if let Some(content_response) = &content_response {
|
if let Some(content_response) = &content_response {
|
||||||
size = content_response.rect.size()
|
size = content_response.rect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
let outer_rect = frame.end(&mut area_content_ui).rect;
|
let outer_rect = frame.end(&mut area_content_ui).rect;
|
||||||
@@ -1159,15 +1141,15 @@ impl<'open> Window<'open> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if scroll.has_any_bar() {
|
if scroll.has_any_bar() {
|
||||||
scroll.show(ui, |ui| add_contents(ui)).inner
|
scroll.show(ui, |ui| add_contents(ui));
|
||||||
} else {
|
} else {
|
||||||
add_contents(ui)
|
add_contents(ui);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
||||||
if let Some(content_response) = &content_response {
|
if let Some(content_response) = &content_response {
|
||||||
size = content_response.rect.size()
|
size = content_response.rect.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
let outer_rect = frame.end(&mut area_content_ui).rect;
|
let outer_rect = frame.end(&mut area_content_ui).rect;
|
||||||
@@ -1218,7 +1200,7 @@ impl<'open> Window<'open> {
|
|||||||
let full_response = area.end(ctx, area_content_ui);
|
let full_response = area.end(ctx, area_content_ui);
|
||||||
ctx.data_mut(|data| data.insert_temp(area_id.with("size"), size));
|
ctx.data_mut(|data| data.insert_temp(area_id.with("size"), size));
|
||||||
|
|
||||||
let inner_response = InnerResponse {
|
let _inner_response = InnerResponse {
|
||||||
inner: content_inner,
|
inner: content_inner,
|
||||||
response: full_response,
|
response: full_response,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ impl Repaint {
|
|||||||
< self
|
< self
|
||||||
.repaint_after
|
.repaint_after
|
||||||
.get(&viewport_id)
|
.get(&viewport_id)
|
||||||
.cloned()
|
.copied()
|
||||||
.unwrap_or(std::time::Duration::MAX)
|
.unwrap_or(std::time::Duration::MAX)
|
||||||
{
|
{
|
||||||
self.repaint_after.insert(viewport_id, after);
|
self.repaint_after.insert(viewport_id, after);
|
||||||
@@ -130,14 +130,14 @@ impl Repaint {
|
|||||||
fn end_frame(
|
fn end_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
viewport_id: ViewportId,
|
viewport_id: ViewportId,
|
||||||
viewports: Vec<ViewportId>,
|
viewports: &[ViewportId],
|
||||||
) -> Vec<(ViewportId, std::time::Duration)> {
|
) -> Vec<(ViewportId, std::time::Duration)> {
|
||||||
// if repaint_requests is greater than zero. just set the duration to zero for immediate
|
// if repaint_requests is greater than zero. just set the duration to zero for immediate
|
||||||
// repaint. if there's no repaint requests, then we can use the actual repaint_after instead.
|
// repaint. if there's no repaint requests, then we can use the actual repaint_after instead.
|
||||||
let repaint_after = if self
|
let repaint_after = if self
|
||||||
.repaint_requests
|
.repaint_requests
|
||||||
.get(&viewport_id)
|
.get(&viewport_id)
|
||||||
.cloned()
|
.copied()
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
> 0
|
> 0
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ impl Repaint {
|
|||||||
} else {
|
} else {
|
||||||
self.repaint_after
|
self.repaint_after
|
||||||
.get(&viewport_id)
|
.get(&viewport_id)
|
||||||
.cloned()
|
.copied()
|
||||||
.unwrap_or(std::time::Duration::MAX)
|
.unwrap_or(std::time::Duration::MAX)
|
||||||
};
|
};
|
||||||
self.repaint_after.insert(viewport_id, repaint_after);
|
self.repaint_after.insert(viewport_id, repaint_after);
|
||||||
@@ -385,14 +385,14 @@ impl ContextImpl {
|
|||||||
//
|
//
|
||||||
// In the case of this viewport is the main viewport will be `ViewportId::MAIN`
|
// In the case of this viewport is the main viewport will be `ViewportId::MAIN`
|
||||||
pub(crate) fn get_viewport_id(&self) -> ViewportId {
|
pub(crate) fn get_viewport_id(&self) -> ViewportId {
|
||||||
self.frame_stack.last().cloned().unwrap_or_default().0
|
self.frame_stack.last().copied().unwrap_or_default().0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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`
|
// In the case of this viewport is the main viewport will be `ViewportId::MAIN`
|
||||||
pub(crate) fn get_parent_viewport_id(&self) -> ViewportId {
|
pub(crate) fn get_parent_viewport_id(&self) -> ViewportId {
|
||||||
self.frame_stack.last().cloned().unwrap_or_default().1
|
self.frame_stack.last().copied().unwrap_or_default().1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +471,7 @@ impl Default for Context {
|
|||||||
s.write(|ctx| {
|
s.write(|ctx| {
|
||||||
ctx.render_sync = Some(Arc::new(Box::new(
|
ctx.render_sync = Some(Arc::new(Box::new(
|
||||||
move |_builder, _viewport_id, _parent_viewport_id, render| render(&clone),
|
move |_builder, _viewport_id, _parent_viewport_id, render| render(&clone),
|
||||||
)))
|
)));
|
||||||
});
|
});
|
||||||
|
|
||||||
s
|
s
|
||||||
@@ -1133,7 +1133,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_repaint_viewport(&self, id: ViewportId) {
|
pub fn request_repaint_viewport(&self, id: ViewportId) {
|
||||||
self.write(|ctx| ctx.repaint.request_repaint(id))
|
self.write(|ctx| ctx.repaint.request_repaint(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request repaint after at most the specified duration elapses.
|
/// Request repaint after at most the specified duration elapses.
|
||||||
@@ -1169,12 +1169,12 @@ impl Context {
|
|||||||
// Maybe we can check if duration is ZERO, and call self.request_repaint()?
|
// Maybe we can check if duration is ZERO, and call self.request_repaint()?
|
||||||
self.write(|ctx| {
|
self.write(|ctx| {
|
||||||
ctx.repaint
|
ctx.repaint
|
||||||
.request_repaint_after(duration, ctx.get_viewport_id())
|
.request_repaint_after(duration, ctx.get_viewport_id());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_repaint_viewport_after(&self, duration: std::time::Duration, id: ViewportId) {
|
pub fn request_repaint_viewport_after(&self, duration: std::time::Duration, id: ViewportId) {
|
||||||
self.write(|ctx| ctx.repaint.request_repaint_after(duration, id))
|
self.write(|ctx| ctx.repaint.request_repaint_after(duration, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For integrations: this callback will be called when an egui user calls [`Self::request_repaint`].
|
/// For integrations: this callback will be called when an egui user calls [`Self::request_repaint`].
|
||||||
@@ -1473,14 +1473,14 @@ impl Context {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let repaint_after =
|
let repaint_after =
|
||||||
self.write(|ctx| ctx.repaint.end_frame(ctx.get_viewport_id(), viewports));
|
self.write(|ctx| ctx.repaint.end_frame(ctx.get_viewport_id(), &viewports));
|
||||||
let shapes = self.drain_paint_lists();
|
let shapes = self.drain_paint_lists();
|
||||||
|
|
||||||
// This is used for,
|
// This is used for,
|
||||||
// If there are no viewport that contains the current viewpor that viewport needs to be destroyed!
|
// If there are no viewport that contains the current viewpor that viewport needs to be destroyed!
|
||||||
let avalibile_viewports = self.read(|ctx| {
|
let avalibile_viewports = self.read(|ctx| {
|
||||||
let mut avalibile_viewports = vec![ViewportId::MAIN];
|
let mut avalibile_viewports = vec![ViewportId::MAIN];
|
||||||
for (_, (_, id, _, _, _)) in ctx.viewports.iter() {
|
for (_, id, _, _, _) in ctx.viewports.values() {
|
||||||
avalibile_viewports.push(*id);
|
avalibile_viewports.push(*id);
|
||||||
}
|
}
|
||||||
avalibile_viewports
|
avalibile_viewports
|
||||||
@@ -1499,7 +1499,7 @@ impl Context {
|
|||||||
|
|
||||||
viewports.push((*id, *parent, builder.clone(), render.clone()));
|
viewports.push((*id, *parent, builder.clone(), render.clone()));
|
||||||
(out || viewport_id != *parent) && avalibile_viewports.contains(parent)
|
(out || viewport_id != *parent) && avalibile_viewports.contains(parent)
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// This is used to resume the last frame!
|
// This is used to resume the last frame!
|
||||||
@@ -1514,7 +1514,7 @@ impl Context {
|
|||||||
ctx.layer_rects_prev_viewports.remove(&viewport_id).unwrap();
|
ctx.layer_rects_prev_viewports.remove(&viewport_id).unwrap();
|
||||||
ctx.layer_rects_this_frame =
|
ctx.layer_rects_this_frame =
|
||||||
ctx.layer_rects_this_viewports.remove(&viewport_id).unwrap();
|
ctx.layer_rects_this_viewports.remove(&viewport_id).unwrap();
|
||||||
ctx.memory.resume_frame(viewport_id)
|
ctx.memory.resume_frame(viewport_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
FullOutput {
|
FullOutput {
|
||||||
@@ -2184,11 +2184,11 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_desktop(&self, value: bool) {
|
pub fn set_desktop(&self, value: bool) {
|
||||||
self.write(|ctx| ctx.is_desktop = value)
|
self.write(|ctx| ctx.is_desktop = value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn viewport_command(&self, id: ViewportId, command: ViewportCommand) {
|
pub fn viewport_command(&self, id: ViewportId, command: ViewportCommand) {
|
||||||
self.write(|ctx| ctx.viewport_commands.push((id, command)))
|
self.write(|ctx| ctx.viewport_commands.push((id, command)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_viewport(
|
pub fn create_viewport(
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ pub enum Event {
|
|||||||
WindowEvent(WindowEvent),
|
WindowEvent(WindowEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum WindowEvent {
|
pub enum WindowEvent {
|
||||||
CloseRequested,
|
CloseRequested,
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ impl ViewportBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum ViewportCommand {
|
pub enum ViewportCommand {
|
||||||
Drag,
|
Drag,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ pub mod syntax_highlighting;
|
|||||||
|
|
||||||
pub use color_test::ColorTest;
|
pub use color_test::ColorTest;
|
||||||
pub use demo::DemoWindows;
|
pub use demo::DemoWindows;
|
||||||
|
#[cfg(test)]
|
||||||
use egui::ViewportId;
|
use egui::ViewportId;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ impl eframe::App for MyApp {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
if self.allowed_to_close {
|
if self.allowed_to_close {
|
||||||
frame.close()
|
frame.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ fn main() {
|
|||||||
ui.label(format!("Value: {value}"));
|
ui.label(format!("Value: {value}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
egui::CollapsingHeader::new("Show Test1").show(ui, |ui| {
|
egui::CollapsingHeader::new("Show Test1").show(ui, |_ui| {
|
||||||
egui::Window::new("Test1")
|
egui::Window::new("Test1")
|
||||||
.default_embedded(false)
|
.default_embedded(false)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
@@ -86,7 +86,7 @@ fn main() {
|
|||||||
data.insert_persisted(
|
data.insert_persisted(
|
||||||
Id::new("Test1").with("_embedded"),
|
Id::new("Test1").with("_embedded"),
|
||||||
embedded,
|
embedded,
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if to_repair {
|
if to_repair {
|
||||||
@@ -103,12 +103,12 @@ fn main() {
|
|||||||
ctx.viewport_command(
|
ctx.viewport_command(
|
||||||
ctx.get_viewport_id(),
|
ctx.get_viewport_id(),
|
||||||
egui::ViewportCommand::Drag,
|
egui::ViewportCommand::Drag,
|
||||||
)
|
);
|
||||||
} else {
|
} else {
|
||||||
ctx.memory_mut(|mem| {
|
ctx.memory_mut(|mem| {
|
||||||
mem.set_dragged_id(
|
mem.set_dragged_id(
|
||||||
egui::Id::new("Test1").with("frame_resize"),
|
egui::Id::new("Test1").with("frame_resize"),
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ fn main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
egui::CollapsingHeader::new("Async Test2").show(ui, |ui| {
|
egui::CollapsingHeader::new("Async Test2").show(ui, |_ui| {
|
||||||
egui::Window::new("Test2").show_async(ctx, move |ui| {
|
egui::Window::new("Test2").show_async(ctx, move |ui| {
|
||||||
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
||||||
|
|
||||||
@@ -138,16 +138,16 @@ fn main() {
|
|||||||
ctx.viewport_command(
|
ctx.viewport_command(
|
||||||
ctx.get_viewport_id(),
|
ctx.get_viewport_id(),
|
||||||
egui::ViewportCommand::Drag,
|
egui::ViewportCommand::Drag,
|
||||||
)
|
);
|
||||||
} else {
|
} else {
|
||||||
ctx.memory_mut(|mem| {
|
ctx.memory_mut(|mem| {
|
||||||
mem.set_dragged_id(egui::Id::new("Test2").with("frame_resize"))
|
mem.set_dragged_id(egui::Id::new("Test2").with("frame_resize"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
egui::CollapsingHeader::new("Async Test3").show(ui, |ui| {
|
egui::CollapsingHeader::new("Async Test3").show(ui, |_ui| {
|
||||||
egui::Window::new("Test3").show_async(ctx, move |ui| {
|
egui::Window::new("Test3").show_async(ctx, move |ui| {
|
||||||
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
|
||||||
let ctx = ui.ctx().clone();
|
let ctx = ui.ctx().clone();
|
||||||
@@ -161,10 +161,10 @@ fn main() {
|
|||||||
ctx.viewport_command(
|
ctx.viewport_command(
|
||||||
ctx.get_viewport_id(),
|
ctx.get_viewport_id(),
|
||||||
egui::ViewportCommand::Drag,
|
egui::ViewportCommand::Drag,
|
||||||
)
|
);
|
||||||
} else {
|
} else {
|
||||||
ctx.memory_mut(|mem| {
|
ctx.memory_mut(|mem| {
|
||||||
mem.set_dragged_id(egui::Id::new("Test3").with("frame_resize"))
|
mem.set_dragged_id(egui::Id::new("Test3").with("frame_resize"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user