mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
[app] Give apps the ability to resize integration
This commit is contained in:
@@ -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<crate::Vec2>,
|
||||
|
||||
/// If the app sets this, change the `pixels_per_point` of Egui to this next frame.
|
||||
pub pixels_per_point: Option<f32>,
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user