[app] Give apps the ability to resize integration
This commit is contained in:
parent
ba7f3572a0
commit
c364403d44
3 changed files with 17 additions and 1 deletions
|
@ -56,6 +56,9 @@ pub struct AppOutput {
|
||||||
/// This does nothing for web apps.
|
/// This does nothing for web apps.
|
||||||
pub quit: bool,
|
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.
|
/// If the app sets this, change the `pixels_per_point` of Egui to this next frame.
|
||||||
pub pixels_per_point: Option<f32>,
|
pub pixels_per_point: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,13 +88,25 @@ pub fn run(
|
||||||
{
|
{
|
||||||
let egui::app::AppOutput {
|
let egui::app::AppOutput {
|
||||||
quit,
|
quit,
|
||||||
|
window_size,
|
||||||
pixels_per_point,
|
pixels_per_point,
|
||||||
} = app_output;
|
} = app_output;
|
||||||
|
|
||||||
if let Some(pixels_per_point) = pixels_per_point {
|
if let Some(pixels_per_point) = pixels_per_point {
|
||||||
// User changed GUI scale
|
// User changed GUI scale
|
||||||
raw_input.pixels_per_point = Some(pixels_per_point);
|
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 {
|
*control_flow = if quit {
|
||||||
glutin::event_loop::ControlFlow::Exit
|
glutin::event_loop::ControlFlow::Exit
|
||||||
} else if egui_output.needs_repaint {
|
} else if egui_output.needs_repaint {
|
||||||
|
|
|
@ -170,7 +170,8 @@ impl AppRunner {
|
||||||
|
|
||||||
{
|
{
|
||||||
let egui::app::AppOutput {
|
let egui::app::AppOutput {
|
||||||
quit: _,
|
quit: _, // Can't quit a web page
|
||||||
|
window_size: _, // Can't resize a web page
|
||||||
pixels_per_point,
|
pixels_per_point,
|
||||||
} = app_output;
|
} = app_output;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue