11use futures:: executor:: block_on;
22use ouroboros:: self_referencing;
3+ use shared:: ShaderConstants ;
34use std:: error:: Error ;
45use std:: time:: Instant ;
56use wgpu:: { self , InstanceDescriptor } ;
@@ -10,7 +11,6 @@ use winit::event::{ElementState, MouseButton, WindowEvent};
1011use winit:: event_loop:: { ActiveEventLoop , ControlFlow , EventLoop } ;
1112use winit:: keyboard:: NamedKey ;
1213use winit:: window:: { Window , WindowAttributes , WindowId } ;
13- use shared:: ShaderConstants ;
1414
1515#[ self_referencing]
1616struct WindowSurface {
@@ -110,7 +110,10 @@ impl ShaderToyApp {
110110 const MAX_PUSH_CONSTANT_SIZE : u32 = {
111111 let v = size_of :: < ShaderConstants > ( ) ;
112112 // Not sure if this is portable on Metal or DX12 in the first place...
113- assert ! ( v <= 128 , "Push constant larger than the minimum that Vulkan requires, may not be portable!" ) ;
113+ assert ! (
114+ v <= 128 ,
115+ "Push constant larger than the minimum that Vulkan requires, may not be portable!"
116+ ) ;
114117 v as u32
115118 } ;
116119 let required_limits = wgpu:: Limits {
@@ -302,26 +305,32 @@ impl ApplicationHandler for ShaderToyApp {
302305 self . drag_end_y = self . cursor_y ;
303306 }
304307 }
305- WindowEvent :: MouseInput { state, button, .. } => {
306- if button == MouseButton :: Left {
307- self . mouse_left_pressed = state == ElementState :: Pressed ;
308- if self . mouse_left_pressed {
309- self . drag_start_x = self . cursor_x ;
310- self . drag_start_y = self . cursor_y ;
311- self . drag_end_x = self . cursor_x ;
312- self . drag_end_y = self . cursor_y ;
313- self . mouse_left_clicked = true ;
314- }
308+ WindowEvent :: MouseInput {
309+ state,
310+ button : MouseButton :: Left ,
311+ ..
312+ } => {
313+ self . mouse_left_pressed = state == ElementState :: Pressed ;
314+ if self . mouse_left_pressed {
315+ self . drag_start_x = self . cursor_x ;
316+ self . drag_start_y = self . cursor_y ;
317+ self . drag_end_x = self . cursor_x ;
318+ self . drag_end_y = self . cursor_y ;
319+ self . mouse_left_clicked = true ;
315320 }
316321 }
317- WindowEvent :: MouseWheel { delta : winit:: event:: MouseScrollDelta :: LineDelta ( x, y) , .. } => {
322+ WindowEvent :: MouseWheel {
323+ delta : winit:: event:: MouseScrollDelta :: LineDelta ( x, y) ,
324+ ..
325+ } => {
318326 self . drag_end_x = x * 0.1 ;
319327 self . drag_end_y = y * 0.1 ;
320328 }
321- WindowEvent :: KeyboardInput { event, .. } => {
322- if event. logical_key == NamedKey :: Escape && event. state == ElementState :: Pressed {
323- self . close_requested = true ;
324- }
329+ WindowEvent :: KeyboardInput { event, .. }
330+ if event. logical_key == NamedKey :: Escape
331+ && event. state == ElementState :: Pressed =>
332+ {
333+ self . close_requested = true ;
325334 }
326335 WindowEvent :: RedrawRequested => self . render ( ) ,
327336 _ => { }
0 commit comments