@@ -9,7 +9,6 @@ use graphene::document::Document;
99use graphene:: Operation as DocumentOperation ;
1010use serde:: { Deserialize , Serialize } ;
1111use std:: collections:: { HashMap , VecDeque } ;
12- use std:: fs:: OpenOptions ;
1312
1413struct Selected < ' a > {
1514 pub selected : Vec < Vec < LayerId > > ,
@@ -291,14 +290,17 @@ pub enum TransformLayerMessage {
291290 ConstrainY ,
292291
293292 MouseMove ,
293+
294+ SetSlow ( bool ) ,
295+ SetSnap ( bool ) ,
294296}
295297
296298#[ derive( Debug , Clone , Default , PartialEq ) ]
297299pub struct TransformLayerMessageHandler {
298300 operation : Operation ,
299301
300- shift_down : bool ,
301- ctrl_down : bool ,
302+ slow : bool ,
303+ snap : bool ,
302304 typing : Typing ,
303305
304306 mouse_pos : ViewportPosition ,
@@ -345,7 +347,8 @@ impl MessageHandler<TransformLayerMessage, (&mut HashMap<Vec<LayerId>, LayerData
345347 Operation :: None => unreachable ! ( ) ,
346348 Operation :: Translating ( translation) => {
347349 self . operation . apply_operation ( & mut selected, true ) ;
348- self . operation = Operation :: Translating ( translation. increment_amount ( delta_pos) ) ;
350+ let change = if self . slow { delta_pos / 10. } else { delta_pos } ;
351+ self . operation = Operation :: Translating ( translation. increment_amount ( change) ) ;
349352 self . operation . apply_operation ( & mut selected, false ) ;
350353 }
351354 Operation :: Rotating ( r) => {
@@ -356,7 +359,8 @@ impl MessageHandler<TransformLayerMessage, (&mut HashMap<Vec<LayerId>, LayerData
356359 let end_vec = ipp. mouse . position - selected_mid;
357360 start_vec. angle_between ( end_vec)
358361 } ;
359- self . operation = Operation :: Rotating ( r. increment_amount ( rotation) ) ;
362+ let change = if self . slow { rotation / 10. } else { rotation } ;
363+ self . operation = Operation :: Rotating ( r. increment_amount ( change) ) ;
360364 self . operation . apply_operation ( & mut selected, false ) ;
361365 }
362366 Operation :: Scaling ( s) => {
@@ -368,6 +372,7 @@ impl MessageHandler<TransformLayerMessage, (&mut HashMap<Vec<LayerId>, LayerData
368372 let start_transform_dist = ( self . start_mouse - selected_mid) . length ( ) ;
369373 ( current_frame_dist - previous_frame_dist) / start_transform_dist
370374 } ;
375+ let change = if self . slow { change / 10. } else { change } ;
371376 self . operation = Operation :: Scaling ( s. increment_amount ( change) ) ;
372377 self . operation . apply_operation ( & mut selected, false ) ;
373378 }
@@ -380,6 +385,8 @@ impl MessageHandler<TransformLayerMessage, (&mut HashMap<Vec<LayerId>, LayerData
380385 TypeDecimalPoint => self . operation . handle_typed ( self . typing . type_decimal ( ) , & mut selected) ,
381386 ConstrainX => self . operation . constrain_axis ( Axis :: X , & mut selected) ,
382387 ConstrainY => self . operation . constrain_axis ( Axis :: Y , & mut selected) ,
388+ SetSlow ( new) => self . slow = new,
389+ SetSnap ( new) => self . snap = new,
383390 }
384391 }
385392 fn actions ( & self ) -> ActionList {
@@ -399,6 +406,8 @@ impl MessageHandler<TransformLayerMessage, (&mut HashMap<Vec<LayerId>, LayerData
399406 TypeDecimalPoint ,
400407 ConstrainX ,
401408 ConstrainY ,
409+ SetSlow ,
410+ SetSnap ,
402411 ) ;
403412 common. extend ( active) ;
404413 }
0 commit comments