@@ -376,72 +376,86 @@ def mouseMoveEvent(self, event):
376
376
377
377
# Determine if cursor is over a handle
378
378
if self .transform .mapToPolygon (self .topRightHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
379
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_bdiag' ), rotation , shear_x , shear_y ))
379
+ if not self .transform_mode or self .transform_mode == 'scale_top_right' :
380
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_bdiag' ), rotation , shear_x , shear_y ))
380
381
# Set the transform mode
381
382
if self .mouse_dragging and not self .transform_mode :
382
383
self .transform_mode = 'scale_top_right'
383
384
elif self .transform .mapToPolygon (self .topHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
384
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_y' ), rotation , shear_x , shear_y ))
385
+ if not self .transform_mode or self .transform_mode == 'scale_top' :
386
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_y' ), rotation , shear_x , shear_y ))
385
387
# Set the transform mode
386
388
if self .mouse_dragging and not self .transform_mode :
387
389
self .transform_mode = 'scale_top'
388
390
elif self .transform .mapToPolygon (self .topLeftHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
389
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_fdiag' ), rotation , shear_x , shear_y ))
391
+ if not self .transform_mode or self .transform_mode == 'scale_top_left' :
392
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_fdiag' ), rotation , shear_x , shear_y ))
390
393
# Set the transform mode
391
394
if self .mouse_dragging and not self .transform_mode :
392
395
self .transform_mode = 'scale_top_left'
393
396
elif self .transform .mapToPolygon (self .leftHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
394
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_x' ), rotation , shear_x , shear_y ))
397
+ if not self .transform_mode or self .transform_mode == 'scale_left' :
398
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_x' ), rotation , shear_x , shear_y ))
395
399
# Set the transform mode
396
400
if self .mouse_dragging and not self .transform_mode :
397
401
self .transform_mode = 'scale_left'
398
402
elif self .transform .mapToPolygon (self .rightHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
399
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_x' ), rotation , shear_x , shear_y ))
403
+ if not self .transform_mode or self .transform_mode == 'scale_right' :
404
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_x' ), rotation , shear_x , shear_y ))
400
405
# Set the transform mode
401
406
if self .mouse_dragging and not self .transform_mode :
402
407
self .transform_mode = 'scale_right'
403
408
elif self .transform .mapToPolygon (self .bottomLeftHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
404
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_bdiag' ), rotation , shear_x , shear_y ))
409
+ if not self .transform_mode or self .transform_mode == 'scale_bottom_left' :
410
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_bdiag' ), rotation , shear_x , shear_y ))
405
411
# Set the transform mode
406
412
if self .mouse_dragging and not self .transform_mode :
407
413
self .transform_mode = 'scale_bottom_left'
408
414
elif self .transform .mapToPolygon (self .bottomHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
409
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_y' ), rotation , shear_x , shear_y ))
415
+ if not self .transform_mode or self .transform_mode == 'scale_bottom' :
416
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_y' ), rotation , shear_x , shear_y ))
410
417
# Set the transform mode
411
418
if self .mouse_dragging and not self .transform_mode :
412
419
self .transform_mode = 'scale_bottom'
413
420
elif self .transform .mapToPolygon (self .bottomRightHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
414
- self .setCursor (self .rotateCursor (self .cursors .get ('resize_fdiag' ), rotation , shear_x , shear_y ))
421
+ if not self .transform_mode or self .transform_mode == 'scale_bottom_right' :
422
+ self .setCursor (self .rotateCursor (self .cursors .get ('resize_fdiag' ), rotation , shear_x , shear_y ))
415
423
# Set the transform mode
416
424
if self .mouse_dragging and not self .transform_mode :
417
425
self .transform_mode = 'scale_bottom_right'
418
426
elif self .transform .mapToPolygon (self .topShearHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
419
- self .setCursor (self .rotateCursor (self .cursors .get ('shear_x' ), rotation , shear_x , shear_y ))
427
+ if not self .transform_mode or self .transform_mode == 'shear_top' :
428
+ self .setCursor (self .rotateCursor (self .cursors .get ('shear_x' ), rotation , shear_x , shear_y ))
420
429
# Set the transform mode
421
430
if self .mouse_dragging and not self .transform_mode :
422
431
self .transform_mode = 'shear_top'
423
432
elif self .transform .mapToPolygon (self .leftShearHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
424
- self .setCursor (self .rotateCursor (self .cursors .get ('shear_y' ), rotation , shear_x , shear_y ))
433
+ if not self .transform_mode or self .transform_mode == 'shear_left' :
434
+ self .setCursor (self .rotateCursor (self .cursors .get ('shear_y' ), rotation , shear_x , shear_y ))
425
435
# Set the transform mode
426
436
if self .mouse_dragging and not self .transform_mode :
427
437
self .transform_mode = 'shear_left'
428
438
elif self .transform .mapToPolygon (self .rightShearHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
429
- self .setCursor (self .rotateCursor (self .cursors .get ('shear_y' ), rotation , shear_x , shear_y ))
439
+ if not self .transform_mode or self .transform_mode == 'shear_right' :
440
+ self .setCursor (self .rotateCursor (self .cursors .get ('shear_y' ), rotation , shear_x , shear_y ))
430
441
# Set the transform mode
431
442
if self .mouse_dragging and not self .transform_mode :
432
443
self .transform_mode = 'shear_right'
433
444
elif self .transform .mapToPolygon (self .bottomShearHandle .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
434
- self .setCursor (self .rotateCursor (self .cursors .get ('shear_x' ), rotation , shear_x , shear_y ))
445
+ if not self .transform_mode or self .transform_mode == 'shear_bottom' :
446
+ self .setCursor (self .rotateCursor (self .cursors .get ('shear_x' ), rotation , shear_x , shear_y ))
435
447
# Set the transform mode
436
448
if self .mouse_dragging and not self .transform_mode :
437
449
self .transform_mode = 'shear_bottom'
438
450
elif self .transform .mapToPolygon (self .clipBounds .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
439
- self .setCursor (self .rotateCursor (self .cursors .get ('move' ), rotation , shear_x , shear_y ))
451
+ if not self .transform_mode or self .transform_mode == 'location' :
452
+ self .setCursor (self .rotateCursor (self .cursors .get ('move' ), rotation , shear_x , shear_y ))
440
453
# Set the transform mode
441
454
if self .mouse_dragging and not self .transform_mode :
442
455
self .transform_mode = 'location'
443
456
elif not self .transform .mapToPolygon (self .clipBounds .toRect ()).containsPoint (event .pos (), Qt .OddEvenFill ):
444
- self .setCursor (self .rotateCursor (self .cursors .get ('rotate' ), rotation , shear_x , shear_y ))
457
+ if not self .transform_mode or self .transform_mode == 'rotation' :
458
+ self .setCursor (self .rotateCursor (self .cursors .get ('rotate' ), rotation , shear_x , shear_y ))
445
459
# Set the transform mode
446
460
if self .mouse_dragging and not self .transform_mode :
447
461
self .transform_mode = 'rotation'
@@ -457,24 +471,26 @@ def mouseMoveEvent(self, event):
457
471
location_y = raw_properties .get ('location_y' ).get ('value' )
458
472
459
473
# Calculate new location coordinates
460
- location_x += (event .pos ().x () - self .mouse_position .x ()) / self . clipBounds .width ()
461
- location_y += (event .pos ().y () - self .mouse_position .y ()) / self . clipBounds .height ()
474
+ location_x += (event .pos ().x () - self .mouse_position .x ()) / viewport_rect .width ()
475
+ location_y += (event .pos ().y () - self .mouse_position .y ()) / viewport_rect .height ()
462
476
463
477
# Update keyframe value (or create new one)
464
- self .updateProperty (self .transforming_clip .id , clip_frame_number , 'location_x' , location_x )
478
+ self .updateProperty (self .transforming_clip .id , clip_frame_number , 'location_x' , location_x , refresh = False )
465
479
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'location_y' , location_y )
466
480
467
481
elif self .transform_mode == 'shear_top' :
468
482
# Get current keyframe shear value
469
483
shear_x = raw_properties .get ('shear_x' ).get ('value' )
484
+ scale_x = raw_properties .get ('scale_x' ).get ('value' )
470
485
location_x = raw_properties .get ('location_x' ).get ('value' )
471
486
472
487
# Calculate new location coordinates
488
+ aspect_ratio = self .clipBounds .width () / self .clipBounds .height ()
473
489
shear_x -= (event .pos ().x () - self .mouse_position .x ()) / self .clipBounds .width ()
474
- location_x += (event .pos ().x () - self .mouse_position .x ()) / (self . clipBounds . width () * 2.0 )
490
+ location_x += (event .pos ().x () - self .mouse_position .x ()) / (( viewport_rect . width () * aspect_ratio ) / scale_x )
475
491
476
492
# Update keyframe value (or create new one)
477
- self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_x' , shear_x )
493
+ self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_x' , shear_x , refresh = False )
478
494
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'location_x' , location_x )
479
495
480
496
elif self .transform_mode == 'shear_bottom' :
@@ -490,14 +506,16 @@ def mouseMoveEvent(self, event):
490
506
elif self .transform_mode == 'shear_left' :
491
507
# Get current keyframe shear value
492
508
shear_y = raw_properties .get ('shear_y' ).get ('value' )
509
+ scale_y = raw_properties .get ('scale_y' ).get ('value' )
493
510
location_y = raw_properties .get ('location_y' ).get ('value' )
494
511
495
512
# Calculate new location coordinates
513
+ aspect_ratio = self .clipBounds .height () / self .clipBounds .width ()
496
514
shear_y -= (event .pos ().y () - self .mouse_position .y ()) / self .clipBounds .height ()
497
- location_y += (event .pos ().y () - self .mouse_position .y ()) / self . clipBounds . height ()
515
+ location_y += (event .pos ().y () - self .mouse_position .y ()) / (( viewport_rect . height () * aspect_ratio ) / scale_y )
498
516
499
517
# Update keyframe value (or create new one)
500
- self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_y' , shear_y )
518
+ self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_y' , shear_y , refresh = False )
501
519
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'location_y' , location_y )
502
520
503
521
elif self .transform_mode == 'shear_right' :
@@ -567,8 +585,9 @@ def mouseMoveEvent(self, event):
567
585
scale_y = scale_x
568
586
569
587
# Update keyframe value (or create new one)
588
+ both_scaled = scale_x != 0.001 and scale_y != 0.001
570
589
if scale_x != 0.001 :
571
- self .updateProperty (self .transforming_clip .id , clip_frame_number , 'scale_x' , scale_x )
590
+ self .updateProperty (self .transforming_clip .id , clip_frame_number , 'scale_x' , scale_x , refresh = ( not both_scaled ) )
572
591
if scale_y != 0.001 :
573
592
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'scale_y' , scale_y )
574
593
@@ -580,7 +599,7 @@ def mouseMoveEvent(self, event):
580
599
581
600
self .mutex .unlock ()
582
601
583
- def updateProperty (self , id , frame_number , property_key , new_value ):
602
+ def updateProperty (self , id , frame_number , property_key , new_value , refresh = True ):
584
603
"""Update a keyframe property to a new value, adding or updating keyframes as needed"""
585
604
found_point = False
586
605
clip_updated = False
@@ -613,7 +632,8 @@ def updateProperty(self, id, frame_number, property_key, new_value):
613
632
c .save ()
614
633
615
634
# Update the preview
616
- get_app ().window .refreshFrameSignal .emit ()
635
+ if refresh :
636
+ get_app ().window .refreshFrameSignal .emit ()
617
637
618
638
def refreshTriggered (self ):
619
639
"""Signal to refresh viewport (i.e. a property might have changed that effects the preview)"""
0 commit comments