11use crate :: {
22 image:: grammar:: Image ,
33 renderer:: {
4- camera:: Camera ,
54 draw_uniform:: DrawUniform ,
65 effect_pipeline:: EffectPipeline ,
76 feature_uniform:: { FeatureUniform , TransformAction } ,
@@ -12,6 +11,9 @@ use crate::{
1211 shape_uniform:: { CircleData , ShapeUniform , MAX_CIRCLES } ,
1312 } ,
1413} ;
14+
15+ #[ cfg( feature = "camera" ) ]
16+ use crate :: renderer:: camera:: Camera ;
1517use anyhow:: Result ;
1618use winit:: {
1719 dpi:: PhysicalSize ,
@@ -31,6 +33,7 @@ pub struct AppState<'a> {
3133
3234 pub feature_uniform : FeatureUniform ,
3335 pub draw_uniform : DrawUniform ,
36+ #[ cfg( feature = "camera" ) ]
3437 pub camera : Camera ,
3538 pub mouse_state : MouseState ,
3639 pub editor_state : EditorState ,
@@ -63,6 +66,7 @@ impl<'a> AppState<'a> {
6366 let draw_uniform_resource =
6467 gpu_allocator. create_uniform_resource ( "draw_uniform" , draw_uniform) ?;
6568
69+ #[ cfg( feature = "camera" ) ]
6670 let camera = Camera :: new ( ) ;
6771
6872 let shape_render_texture =
@@ -151,6 +155,7 @@ impl<'a> AppState<'a> {
151155 size,
152156 feature_uniform,
153157 draw_uniform,
158+ #[ cfg( feature = "camera" ) ]
154159 camera,
155160 mouse_state,
156161 editor_state,
@@ -194,11 +199,10 @@ impl<'a> AppState<'a> {
194199 self . modifiers . state ( ) . control_key ( )
195200 } ;
196201
197- let mut draw_mode = draw_uniform. crosshair ( ) ;
198-
199202 // some global rules
200203 // maybe keep a stack of actions?
201- draw_mode = if super_key_pressed { false } else { draw_mode } ;
204+
205+ let draw_mode = if super_key_pressed { false } else { draw_uniform. crosshair ( ) } ;
202206
203207 match event {
204208 WindowEvent :: MouseInput { state, button, .. } => {
@@ -208,7 +212,9 @@ impl<'a> AppState<'a> {
208212 . set_pressed ( matches ! ( state, ElementState :: Pressed ) ) ;
209213
210214 // camera panning
211- if super_key_pressed && !draw_mode {
215+ #[ cfg( feature = "camera" ) ]
216+ if super_key_pressed {
217+ dbg ! ( "pressed" ) ;
212218 self . window . set_cursor_icon ( CursorIcon :: Grab ) ;
213219
214220 match ( prev_state, self . mouse_state . pressed ( ) ) {
@@ -304,6 +310,7 @@ impl<'a> AppState<'a> {
304310 }
305311 }
306312 }
313+ #[ cfg( feature = "camera" ) ]
307314 WindowEvent :: MouseWheel { delta, .. } => {
308315 match delta {
309316 MouseScrollDelta :: LineDelta ( _, y) => {
@@ -335,6 +342,7 @@ impl<'a> AppState<'a> {
335342 WindowEvent :: CursorMoved { position, .. } => {
336343 let ( x, y) = ( position. x as f32 , position. y as f32 ) ;
337344
345+ #[ cfg( feature = "camera" ) ]
338346 if super_key_pressed && self . mouse_state . pressed ( ) {
339347 if let Some ( ( start_x, start_y) ) = self . mouse_state . camera_pan_start ( ) {
340348 let delta_x = ( x - start_x) / ( self . size . width as f32 ) * 2.0 ;
@@ -482,6 +490,7 @@ impl<'a> AppState<'a> {
482490 }
483491 }
484492 }
493+ #[ cfg( feature = "camera" ) ]
485494 ( KeyCode :: KeyR , ElementState :: Pressed ) => {
486495 self . camera . reset ( ) ;
487496 }
@@ -503,6 +512,7 @@ impl<'a> AppState<'a> {
503512 ) ;
504513
505514 // Update camera in draw uniform
515+ #[ cfg( feature = "camera" ) ]
506516 self . draw_uniform
507517 . update_camera ( self . camera . view_projection_matrix ( ) ) ;
508518
0 commit comments