1
0
Fork 0

Fix clippy lints

This commit is contained in:
Robbert van der Helm 2022-04-06 13:33:01 +02:00
parent 0cf8bdfed6
commit af44796056

View file

@ -97,42 +97,37 @@ impl Model for ParamModel {
impl Model for WindowModel { impl Model for WindowModel {
fn event(&mut self, cx: &mut vizia::Context, event: &mut vizia::Event) { fn event(&mut self, cx: &mut vizia::Context, event: &mut vizia::Event) {
if let Some(window_event) = event.message.downcast() { // This gets fired whenever the inner window gets resized
match *window_event { if let Some(WindowEvent::WindowResize) = event.message.downcast() {
// This gets fired whenever the inner window gets resized let logical_size = (cx.window_size.width, cx.window_size.height);
WindowEvent::WindowResize => { let old_logical_size @ (old_logical_width, old_logical_height) =
let logical_size = (cx.window_size.width, cx.window_size.height); self.vizia_state.size.load();
let old_logical_size @ (old_logical_width, old_logical_height) = let scale_factor = cx.user_scale_factor;
self.vizia_state.size.load(); let old_user_scale_factor = self.vizia_state.scale_factor.load();
let scale_factor = cx.user_scale_factor;
let old_user_scale_factor = self.vizia_state.scale_factor.load();
// Don't do anything if the current size already matches the new size, this // Don't do anything if the current size already matches the new size, this
// could otherwise also cause a feedback loop on resize failure // could otherwise also cause a feedback loop on resize failure
if logical_size == old_logical_size && scale_factor == old_user_scale_factor { if logical_size == old_logical_size && scale_factor == old_user_scale_factor {
return; return;
} }
// Our embedded baseview window will have already been resized. If the host does // Our embedded baseview window will have already been resized. If the host does
// not accept our new size, then we'll try to undo that // not accept our new size, then we'll try to undo that
self.vizia_state.size.store(logical_size); self.vizia_state.size.store(logical_size);
self.vizia_state.scale_factor.store(scale_factor); self.vizia_state.scale_factor.store(scale_factor);
if !self.context.request_resize() { if !self.context.request_resize() {
self.vizia_state.size.store(old_logical_size); self.vizia_state.size.store(old_logical_size);
self.vizia_state.scale_factor.store(old_user_scale_factor); self.vizia_state.scale_factor.store(old_user_scale_factor);
// This will cause the window's size to be reverted on the next event loop // This will cause the window's size to be reverted on the next event loop
cx.window_size.width = old_logical_width; cx.window_size.width = old_logical_width;
cx.window_size.height = old_logical_height; cx.window_size.height = old_logical_height;
cx.user_scale_factor = old_user_scale_factor; cx.user_scale_factor = old_user_scale_factor;
}
}
_ => (),
} }
} }
} }
} }
impl<P: Param> From<ParamEvent<'_, P>> for RawParamEvent { impl<P: Param> From<ParamEvent<'_, P>> for RawParamEvent {
fn from(event: ParamEvent<'_, P>) -> Self { fn from(event: ParamEvent<'_, P>) -> Self {
match event { match event {