8000 Deprecate DraggableBase.artist_picker. · matplotlib/matplotlib@2033ee7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2033ee7

Browse files
committed
Deprecate DraggableBase.artist_picker.
This method could previously be overridden in order to customize the artist's picker function when dragging it. However, the default picker of all artists is already checking whether the artist contain()s the event; moreover the picker is "global" for the artist so it stays set on it even after making it undraggable. Hence it is really just an artist's property and the user should just call artist.set_picker() if desired.
1 parent 3a2589b commit 2033ee7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,8 @@ The following parameters do not have any effect and are deprecated:
124124
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125125
This method is deprecated. Use
126126
``ax.dataLim.set(Bbox.union([ax.dataLim, bounds]))`` instead.
127+
128+
``DraggableBase.artist_picker``
129+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130+
This method is deprecated. If you previously reimplemented it in a subclass,
131+
set the artist's picker instead with `.Artist.set_picker`.

lib/matplotlib/offsetbox.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,11 +1697,7 @@ def update_offset(self, dx, dy):
16971697
the point where the mouse drag started.
16981698
'''
16991699
1700-
Optionally, you may override the following methods::
1701-
1702-
def artist_picker(self, artist, evt):
1703-
'''The picker method that will be used.'''
1704-
return self.ref_artist.contains(evt)
1700+
Optionally, you may override the following method::
17051701
17061702
def finalize_offset(self):
17071703
'''Called when the mouse is released.'''
@@ -1722,7 +1718,17 @@ def __init__(self, ref_artist, use_blit=False):
17221718
c2 = self.canvas.mpl_connect('pick_event', self.on_pick)
17231719
c3 = self.canvas.mpl_connect('button_release_event', self.on_release)
17241720

1725-
ref_artist.set_picker(self.artist_picker)
1721+
ref_artist.set_picker(True)
1722+
with cbook._suppress_matplotlib_deprecation_warning():
1723+
if self.artist_picker != DraggableBase.artist_picker.__get__(self):
1724+
overridden_picker = self.artist_picker
1725+
else:
1726+
overridden_picker = None
1727+
if overridden_picker is not None:
1728+
cbook.warn_deprecated(
1729+
"3.3", name="artist_picker", obj_type="method",
1730+
addendum="Directly set the artist's picker if desired.")
1731+
ref_artist.set_picker(overridden_picker)
17261732
self.cids = [c2, c3]
17271733

17281734
def on_motion(self, evt):
@@ -1789,6 +1795,7 @@ def disconnect(self):
17891795
else:
17901796
self.canvas.mpl_disconnect(c1)
17911797

1798+
@cbook.deprecated("3.3", alternative="self.ref_artist.contains")
17921799
def artist_picker(self, artist, evt):
17931800
return self.ref_artist.contains(evt)
17941801

0 commit comments

Comments
 (0)
0