@@ -1592,35 +1592,35 @@ def draw(self, renderer):
1592
1592
1593
1593
class DraggableBase :
1594
1594
"""
1595
- helper code for a draggable artist (legend, offsetbox)
1596
- The derived class must override following two method.
1595
+ Helper base class for a draggable artist (legend, offsetbox).
1597
1596
1598
- def save_offset(self):
1599
- pass
1597
+ Derived classes must override the following methods::
1600
1598
1601
- def update_offset(self, dx, dy):
1602
- pass
1599
+ def save_offset(self):
1600
+ '''
1601
+ Called when the object is picked for dragging; should save the
1602
+ reference position of the artist.
1603
+ '''
1603
1604
1604
- *save_offset* is called when the object is picked for dragging and it
1605
- is meant to save reference position of the artist.
1605
+ def update_offset(self, dx, dy):
1606
+ '''
1607
+ Called during the dragging; (*dx*, *dy*) is the pixel offset from
1608
+ the point where the mouse drag started.
1609
+ '''
1606
1610
1607
- *update_offset* is called during the dragging. dx and dy is the pixel
1608
- offset from the point where the mouse drag started.
1611
+ Optionally, you may override the following methods::
1609
1612
1610
- Optionally you may override following two methods.
1613
+ def artist_picker(self, artist, evt):
1614
+ '''The picker method that will be used.'''
1615
+ return self.ref_artist.contains(evt)
1611
1616
1612
- def artist_picker (self, artist, evt ):
1613
- return self.ref_artist.contains(evt)
1617
+ def finalize_offset (self):
1618
+ '''Called when the mouse is released.'''
1614
1619
1615
- def finalize_offset(self):
1616
- pass
1617
-
1618
- *artist_picker* is a picker method that will be
1619
- used. *finalize_offset* is called when the mouse is released. In
1620
- current implementation of DraggableLegend and DraggableAnnotation,
1621
- *update_offset* places the artists simply in display
1622
- coordinates. And *finalize_offset* recalculate their position in
1623
- the normalized axes coordinate and set a relevant attribute.
1620
+ In the current implementation of `DraggableLegend` and
1621
+ `DraggableAnnotation`, `update_offset` places the artists in display
1622
+ coordinates, and `finalize_offset` recalculates their position in axes
1623
+ coordinate and set a relevant attribute.
1624
1624
"""
1625
1625
1626
1626
def __init__ (self , ref_artist , use_blit = False ):
@@ -1690,7 +1690,7 @@ def _check_still_parented(self):
1690
1690
return True
1691
1691
1692
1692
def disconnect (self ):
1693
- """disconnect the callbacks"""
1693
+ """Disconnect the callbacks. """
1694
1694
for cid in self .cids :
1695
1695
self .canvas .mpl_disconnect (cid )
1696
1696
try :
@@ -1731,13 +1731,11 @@ def update_offset(self, dx, dy):
1731
1731
self .offsetbox .set_offset (loc_in_canvas )
1732
1732
1733
1733
def get_loc_in_canvas (self ):
1734
-
1735
1734
offsetbox = self .offsetbox
1736
1735
renderer = offsetbox .figure ._cachedRenderer
1737
1736
w , h , xd , yd = offsetbox .get_extent (renderer )
1738
1737
ox , oy = offsetbox ._offset
1739
1738
loc_in_canvas = (ox - xd , oy - yd )
1740
-
1741
1739
return loc_in_canvas
1742
1740
1743
1741
0 commit comments