@@ -2778,13 +2778,13 @@ def __init__(self, ax, onselect, drawtype='box',
2778
2778
'markeredgecolor' : (props or {}).get ('edgecolor' , 'black' ),
2779
2779
** cbook .normalize_kwargs (handle_props , Line2D ._alias_map )}
2780
2780
2781
- self ._corner_order = ['NW ' , 'NE ' , 'SE ' , 'SW ' ]
2781
+ self ._corner_order = ['SW ' , 'SE ' , 'NE ' , 'NW ' ]
2782
2782
xc , yc = self .corners
2783
2783
self ._corner_handles = ToolHandles (self .ax , xc , yc ,
2784
2784
marker_props = handle_props ,
2785
2785
useblit = self .useblit )
2786
2786
2787
- self ._edge_order = ['W' , 'N ' , 'E' , 'S ' ]
2787
+ self ._edge_order = ['W' , 'S ' , 'E' , 'N ' ]
2788
2788
xe , ye = self .edge_centers
2789
2789
self ._edge_handles = ToolHandles (self .ax , xe , ye , marker = 's' ,
2790
2790
marker_props = handle_props ,
@@ -2824,6 +2824,7 @@ def _press(self, event):
2824
2824
# button, ...
2825
2825
if self ._interactive and self ._to_draw .get_visible ():
2826
2826
self ._set_active_handle (event )
2827
+ self ._extents_on_press = self .extents
2827
2828
else :
2828
2829
self ._active_handle = None
2829
2830
@@ -2889,22 +2890,31 @@ def _release(self, event):
2889
2890
2890
2891
self .update ()
2891
2892
self ._active_handle = None
2893
+ self ._extents_on_press = None
2892
2894
2893
2895
return False
2894
2896
2895
2897
def _onmove (self , event ):
2896
2898
"""Motion notify event handler."""
2899
+
2900
+
2897
2901
# resize an existing shape
2898
2902
if self ._active_handle and self ._active_handle != 'C' :
2899
2903
x0 , x1 , y0 , y1 = self ._extents_on_press
2904
+ # Switch variables so that only x1 and/or y1 are updated on move.
2905
+ if self ._active_handle in ['W' , 'SW' , 'NW' ]:
2906
+ x0 , x1 = x1 , event .xdata
2907
+ if self ._active_handle in ['S' , 'SW' , 'SE' ]:
2908
+ y0 , y1 = y1 , event .ydata
2909
+
2900
2910
if self ._active_handle in ['E' , 'W' ] + self ._corner_order :
2901
2911
x1 = event .xdata
2902
2912
if self ._active_handle in ['N' , 'S' ] + self ._corner_order :
2903
2913
y1 = event .ydata
2904
2914
2905
2915
# move existing shape
2906
- elif (( 'move' in self . _state or self ._active_handle == 'C' or
2907
- (self .drag_from_anywhere and self ._contains (event ) )) and
2916
+ elif (self ._active_handle == 'C' or
2917
+ (self .drag_from_anywhere and self ._contains (event )) and
2908
2918
self ._extents_on_press is not None ):
2909
2919
x0 , x1 , y0 , y1 = self ._extents_on_press
2910
2920
dx = event .xdata - self ._eventpress .xdata
@@ -3041,7 +3051,6 @@ def _set_active_handle(self, event):
3041
3051
3042
3052
if 'move' in self ._state :
3043
3053
self ._active_handle = 'C'
3044
- self ._extents_on_press = self .extents
3045
3054
# Set active handle as closest handle, if mouse click is close enough.
3046
3055
elif m_dist < self .grab_range * 2 :
3047
3056
# Prioritise center handle over other handles
@@ -3052,7 +3061,6 @@ def _set_active_handle(self, event):
3052
3061
if self .drag_from_anywhere and self ._contains (event ):
3053
3062
# Check if we've clicked inside the region
3054
3063
self ._active_handle = 'C'
3055
- self ._extents_on_press = self .extents
3056
3064
else :
3057
3065
self ._active_handle = None
3058
3066
return
@@ -3063,15 +3071,6 @@ def _set_active_handle(self, event):
3063
3071
# Closest to an edge handle
3064
3072
self ._active_handle = self ._edge_order [e_idx ]
3065
3073
3066
- # Save coordinates of rectangle at the start of handle movement.
3067
- x0 , x1 , y0 , y1 = self .extents
3068
- # Switch variables so that only x1 and/or y1 are updated on move.
3069
- if self ._active_handle in ['W' , 'SW' , 'NW' ]:
3070
- x0 , x1 = x1 , event .xdata
3071
- if self ._active_handle in ['N' , 'NW' , 'NE' ]:
3072
- y0 , y1 = y1 , event .ydata
3073
- self ._extents_on_press = x0 , x1 , y0 , y1
3074
-
3075
3074
def _contains (self , event ):
3076
3075
"""Return True if event is within the patch."""
3077
3076
return self ._to_draw .contains (event , radius = 0 )[0 ]
0 commit comments