@@ -198,9 +198,10 @@ def paintEvent(self, event, *args):
198
198
shear_y = raw_properties .get ('shear_y' ).get ('value' )
199
199
origin_x = raw_properties .get ('origin_x' ).get ('value' )
200
200
origin_y = raw_properties .get ('origin_y' ).get ('value' )
201
+ origin_x_value = scaled_source_width * origin_x
202
+ origin_y_value = scaled_source_height * origin_y
203
+ self .originHandle = QPointF (x + origin_x_value , y + origin_y_value )
201
204
if rotation or shear_x or shear_y :
202
- origin_x_value = scaled_source_width * origin_x
203
- origin_y_value = scaled_source_height * origin_y
204
205
self .transform .translate (origin_x_value , origin_y_value )
205
206
self .transform .rotate (rotation )
206
207
self .transform .shear (shear_x , shear_y )
@@ -516,8 +517,8 @@ def mouseMoveEvent(self, event):
516
517
scale_x = raw_properties .get ('scale_x' ).get ('value' )
517
518
518
519
# Calculate new location coordinates
519
- clip_aspect_ratio = self .clipBounds .width () / self .clipBounds .height ()
520
- shear_x -= (event .pos ().x () - self .mouse_position .x ()) / ((self .clipBounds .width () * scale_x ) / clip_aspect_ratio )
520
+ aspect_ratio = ( self .clipBounds .width () / self .clipBounds .height ()) * 2.0
521
+ shear_x -= (event .pos ().x () - self .mouse_position .x ()) / ((self .clipBounds .width () * scale_x ) / aspect_ratio )
521
522
522
523
# Update keyframe value (or create new one)
523
524
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_x' , shear_x )
@@ -528,8 +529,8 @@ def mouseMoveEvent(self, event):
528
529
shear_x = raw_properties .get ('shear_x' ).get ('value' )
529
530
530
531
# Calculate new location coordinates
531
- clip_aspect_ratio = self .clipBounds .width () / self .clipBounds .height ()
532
- shear_x += (event .pos ().x () - self .mouse_position .x ()) / ((self .clipBounds .width () * scale_x ) / clip_aspect_ratio )
532
+ aspect_ratio = ( self .clipBounds .width () / self .clipBounds .height ()) * 2.0
533
+ shear_x += (event .pos ().x () - self .mouse_position .x ()) / ((self .clipBounds .width () * scale_x ) / aspect_ratio )
533
534
534
535
# Update keyframe value (or create new one)
535
536
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_x' , shear_x )
@@ -540,41 +541,43 @@ def mouseMoveEvent(self, event):
540
541
scale_y = raw_properties .get ('scale_y' ).get ('value' )
541
542
542
543
# Calculate new location coordinates
543
- clip_aspect_ratio = self .clipBounds .height () / self .clipBounds .width ()
544
- shear_y -= (event .pos ().y () - self .mouse_position .y ()) / (( self .clipBounds .height () * scale_y ) / clip_aspect_ratio )
544
+ aspect_ratio = ( self .clipBounds .height () / self .clipBounds .width ()) * 2.0
545
+ shear_y -= (event .pos ().y () - self .mouse_position .y ()) / (self .clipBounds .height () * scale_y / aspect_ratio )
545
546
546
547
# Update keyframe value (or create new one)
547
548
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_y' , shear_y )
548
549
549
550
elif self .transform_mode == 'shear_right' :
550
551
# Get current keyframe shear value
551
- clip_aspect_ratio = self .clipBounds .height () / self .clipBounds .width ()
552
552
scale_y = raw_properties .get ('scale_y' ).get ('value' )
553
553
shear_y = raw_properties .get ('shear_y' ).get ('value' )
554
554
555
555
# Calculate new location coordinates
556
- shear_y += (event .pos ().y () - self .mouse_position .y ()) / ((self .clipBounds .height () * scale_y ) / clip_aspect_ratio )
556
+ aspect_ratio = (self .clipBounds .height () / self .clipBounds .width ()) * 2.0
557
+ shear_y += (event .pos ().y () - self .mouse_position .y ()) / (self .clipBounds .height () * scale_y / aspect_ratio )
557
558
558
559
# Update keyframe value (or create new one)
559
560
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'shear_y' , shear_y )
560
561
561
562
elif self .transform_mode == 'rotation' :
562
563
# Get current rotation keyframe value
563
564
rotation = raw_properties .get ('rotation' ).get ('value' )
565
+ scale_x = max (float (raw_properties .get ('scale_x' ).get ('value' )), 0.001 )
566
+ scale_y = max (float (raw_properties .get ('scale_y' ).get ('value' )), 0.001 )
564
567
565
568
# Calculate new location coordinates
566
- is_on_left = event .pos ().x () < ( viewport_rect . width () / 2.0 )
567
- is_on_top = event .pos ().y () < ( viewport_rect . height () / 2.0 )
569
+ is_on_left = event .pos ().x () < self . originHandle . x ( )
570
+ is_on_top = event .pos ().y () < self . originHandle . y ( )
568
571
569
572
if is_on_top :
570
- rotation += (event .pos ().x () - self .mouse_position .x ()) / (self .clipBounds .width () / 90 )
573
+ rotation += (event .pos ().x () - self .mouse_position .x ()) / (( self .clipBounds .width () * scale_x ) / 90 )
571
574
else :
572
- rotation -= (event .pos ().x () - self .mouse_position .x ()) / (self .clipBounds .width () / 90 )
575
+ rotation -= (event .pos ().x () - self .mouse_position .x ()) / (( self .clipBounds .width () * scale_x ) / 90 )
573
576
574
577
if is_on_left :
575
- rotation -= (event .pos ().y () - self .mouse_position .y ()) / (self .clipBounds .height () / 90 )
578
+ rotation -= (event .pos ().y () - self .mouse_position .y ()) / (( self .clipBounds .height () * scale_y ) / 90 )
576
579
else :
577
- rotation += (event .pos ().y () - self .mouse_position .y ()) / (self .clipBounds .height () / 90 )
580
+ rotation += (event .pos ().y () - self .mouse_position .y ()) / (( self .clipBounds .height () * scale_y ) / 90 )
578
581
579
582
# Update keyframe value (or create new one)
580
583
self .updateProperty (self .transforming_clip .id , clip_frame_number , 'rotation' , rotation )
@@ -786,6 +789,7 @@ def __init__(self, *args):
786
789
self .rightHandle = None
787
790
self .centerHandle = None
788
791
self .clipBounds = None
792
+ self .originHandle = None
789
793
self .mouse_pressed = False
790
794
self .mouse_dragging = False
791
795
self .mouse_position = None
0 commit comments