Handle ScaleFactorChanged
in iced_winit
This commit is contained in:
parent
da5da3958e
commit
4030326a35
@ -360,6 +360,18 @@ pub fn handle_window_event(
|
|||||||
);
|
);
|
||||||
*resized = true;
|
*resized = true;
|
||||||
}
|
}
|
||||||
|
WindowEvent::ScaleFactorChanged {
|
||||||
|
scale_factor: new_scale_factor,
|
||||||
|
new_inner_size,
|
||||||
|
} => {
|
||||||
|
let size = Size::new(new_inner_size.width, new_inner_size.height);
|
||||||
|
|
||||||
|
*viewport = Viewport::with_physical_size(
|
||||||
|
size,
|
||||||
|
new_scale_factor * scale_factor,
|
||||||
|
);
|
||||||
|
*resized = true;
|
||||||
|
}
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
*control_flow = ControlFlow::Exit;
|
*control_flow = ControlFlow::Exit;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,14 @@ pub fn window_event(
|
|||||||
height: logical_size.height,
|
height: logical_size.height,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
|
||||||
|
let logical_size = new_inner_size.to_logical(scale_factor);
|
||||||
|
|
||||||
|
Some(Event::Window(window::Event::Resized {
|
||||||
|
width: logical_size.width,
|
||||||
|
height: logical_size.height,
|
||||||
|
}))
|
||||||
|
}
|
||||||
WindowEvent::CursorMoved { position, .. } => {
|
WindowEvent::CursorMoved { position, .. } => {
|
||||||
let position = position.to_logical::<f64>(scale_factor);
|
let position = position.to_logical::<f64>(scale_factor);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user