From 8bade3667d615c8e6c3baa063b98674cdd9d1157 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Mon, 20 Sep 2021 10:28:30 -0700 Subject: [PATCH] formatting and clippy fixes --- src/window/window_wrapper/mod.rs | 6 +++++- src/window/window_wrapper/mouse_manager.rs | 25 ++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/window/window_wrapper/mod.rs b/src/window/window_wrapper/mod.rs index 8ece69a..5d736a0 100644 --- a/src/window/window_wrapper/mod.rs +++ b/src/window/window_wrapper/mod.rs @@ -121,7 +121,11 @@ impl GlutinWindowWrapper { pub fn handle_event(&mut self, event: Event<()>, running: &Arc) { self.keyboard_manager.handle_event(&event); self.mouse_manager.handle_event( - &event, &self.keyboard_manager, &self.renderer, &self.windowed_context); + &event, + &self.keyboard_manager, + &self.renderer, + &self.windowed_context, + ); match event { Event::LoopDestroyed => { self.handle_quit(running); diff --git a/src/window/window_wrapper/mouse_manager.rs b/src/window/window_wrapper/mouse_manager.rs index b5c20e9..7a8f81e 100644 --- a/src/window/window_wrapper/mouse_manager.rs +++ b/src/window/window_wrapper/mouse_manager.rs @@ -8,10 +8,10 @@ use glutin::{ }; use skia_safe::Rect; +use super::keyboard_manager::KeyboardManager; use crate::bridge::UiCommand; use crate::channel_utils::LoggingTx; use crate::renderer::{Renderer, WindowDrawDetails}; -use super::keyboard_manager::KeyboardManager; fn clamp_position( position: PhysicalPosition, @@ -178,7 +178,12 @@ impl MouseManager { } } - fn handle_pointer_transition(&mut self, mouse_button: &MouseButton, down: bool, keyboard_manager: &KeyboardManager) { + fn handle_pointer_transition( + &mut self, + mouse_button: &MouseButton, + down: bool, + keyboard_manager: &KeyboardManager, + ) { // For some reason pointer down is handled differently from pointer up and drag. // Floating windows: relative coordinates are great. // Non floating windows: rather than global coordinates, relative are needed @@ -210,7 +215,7 @@ impl MouseManager { self.dragging = Some(button_text); - if !self.dragging.is_some() { + if self.dragging.is_none() { self.has_moved = false; } } @@ -282,9 +287,10 @@ impl MouseManager { keyboard_manager: &KeyboardManager, ) { self.handle_line_scroll( - pixel_x / font_width as f32, - pixel_y / font_height as f32, - keyboard_manager); + pixel_x / font_width as f32, + pixel_y / font_height as f32, + keyboard_manager, + ); } pub fn handle_event( @@ -329,9 +335,10 @@ impl MouseManager { event: WindowEvent::MouseInput { button, state, .. }, .. } => self.handle_pointer_transition( - button, - state == &ElementState::Pressed, - keyboard_manager), + button, + state == &ElementState::Pressed, + keyboard_manager, + ), _ => {} } }