diff --git a/egui/src/app.rs b/egui/src/app.rs index 4417180b..be79497d 100644 --- a/egui/src/app.rs +++ b/egui/src/app.rs @@ -56,6 +56,9 @@ pub struct AppOutput { /// This does nothing for web apps. pub quit: bool, + /// Set to some size to resize the outer window (e.g. glium window) to this size. + pub window_size: Option, + /// If the app sets this, change the `pixels_per_point` of Egui to this next frame. pub pixels_per_point: Option, } diff --git a/egui_glium/src/backend.rs b/egui_glium/src/backend.rs index be1a5a8f..82a2f4c4 100644 --- a/egui_glium/src/backend.rs +++ b/egui_glium/src/backend.rs @@ -88,13 +88,25 @@ pub fn run( { let egui::app::AppOutput { quit, + window_size, pixels_per_point, } = app_output; + if let Some(pixels_per_point) = pixels_per_point { // User changed GUI scale raw_input.pixels_per_point = Some(pixels_per_point); } + if let Some(window_size) = window_size { + display + .gl_window() + .window() + .set_inner_size(glutin::dpi::LogicalSize { + width: window_size.x, + height: window_size.y, + }); + } + *control_flow = if quit { glutin::event_loop::ControlFlow::Exit } else if egui_output.needs_repaint { diff --git a/egui_web/src/backend.rs b/egui_web/src/backend.rs index e26a5b00..cf040d2a 100644 --- a/egui_web/src/backend.rs +++ b/egui_web/src/backend.rs @@ -170,7 +170,8 @@ impl AppRunner { { let egui::app::AppOutput { - quit: _, + quit: _, // Can't quit a web page + window_size: _, // Can't resize a web page pixels_per_point, } = app_output;