8000 Merge pull request #16108 from anntzer/on_motion_blit · matplotlib/matplotlib@db64f43 · GitHub
[go: up one dir, main page]

Skip to content

Commit db64f43

Browse files
authored
Merge pull request #16108 from anntzer/on_motion_blit
Deprecate DraggableBase.on_motion_blit.
2 parents 266d797 + 3f6a3b1 commit db64f43

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,8 @@ Not passing the *renderer* parameter to `.Axes.draw` is deprecated. Use
259259
These changes make the signature of the ``draw`` (``artist.draw(renderer)``)
260260
method consistent across all artists; thus, additional parameters to
261261
`.Artist.draw` are deprecated.
262+
263+
``DraggableBase.on_motion_blit``
264+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
265+
This method is deprecated. `.DraggableBase.on_motion` now handles both the
266+
blitting and the non-blitting cases.

lib/matplotlib/offsetbox.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,8 +1734,14 @@ def on_motion(self, evt):
17341734
dx = evt.x - self.mouse_x
17351735
dy = evt.y - self.mouse_y
17361736
self.update_offset(dx, dy)
1737-
self.canvas.draw()
1737+
if self._use_blit:
1738+
self.canvas.restore_region(self.background)
1739+
self.ref_artist.draw(self.ref_artist.figure._cachedRenderer)
1740+
self.canvas.blit()
1741+
else:
1742+
self.canvas.draw()
17381743

1744+
@cbook.deprecated("3.3", alternative="self.on_motion")
17391745
def on_motion_blit(self, evt):
17401746
if self._check_still_parented() and self.got_artist:
17411747
dx = evt.x - self.mouse_x
@@ -1747,23 +1753,18 @@ def on_motion_blit(self, evt):
17471753

17481754
def on_pick(self, evt):
17491755
if self._check_still_parented() and evt.artist == self.ref_artist:
1750-
17511756
self.mouse_x = evt.mouseevent.x
17521757
self.mouse_y = evt.mouseevent.y
17531758
self.got_artist = True
1754-
17551759
if self._use_blit:
17561760
self.ref_artist.set_animated(True)
17571761
self.canvas.draw()
1758-
self.background = self.canvas.copy_from_bbox(
1759-
self.ref_artist.figure.bbox)
1762+
self.background = \
1763+
self.canvas.copy_from_bbox(self.ref_artist.figure.bbox)
17601764
self.ref_artist.draw(self.ref_artist.figure._cachedRenderer)
17611765
self.canvas.blit()
1762-
self._c1 = self.canvas.mpl_connect('motion_notify_event',
1763-
self.on_motion_blit)
1764-
else:
1765-
self._c1 = self.canvas.mpl_connect('motion_notify_event',
1766-
self.on_motion)
1766+
self._c1 = self.canvas.mpl_connect(
1767+
"motion_notify_event", self.on_motion)
17671768
self.save_offset()
17681769

17691770
def on_release(self, event):

0 commit comments

Comments
 (0)
0