| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ``Cursor`` and ``MultiCursor`` event handlers are now private | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Access to the event handlers for the `.Cursor` and `.MultiCursor` widgets is | ||
| now deprecated. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1600,8 +1600,8 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False, | |
| **lineprops): | ||
| super().__init__(ax) | ||
|
|
||
| self.connect_event('motion_notify_event', self.onmove) | ||
| self.connect_event('draw_event', self.clear) | ||
| self.connect_event('motion_notify_event', self._onmove) | ||
| self.connect_event('draw_event', self._clear) | ||
|
|
||
| self.visible = True | ||
| self.horizOn = horizOn | ||
| Expand All | @@ -1616,16 +1616,25 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False, | |
| self.background = None | ||
| self.needclear = False | ||
|
|
||
| @_api.deprecated('3.5') | ||
| def clear(self, event): | ||
| """Internal event handler to clear the cursor.""" | ||
| self._clear(event) | ||
| if self.ignore(event): | ||
| return | ||
| if self.useblit: | ||
| self.background = self.canvas.copy_from_bbox(self.ax.bbox) | ||
| self.linev.set_visible(False) | ||
| self.lineh.set_visible(False) | ||
|
|
||
| def onmove(self, event): | ||
| def _clear(self, event): | ||
| """Internal event handler to clear the cursor.""" | ||
| if self.ignore(event): | ||
| return | ||
| if self.useblit: | ||
| self.background = self.canvas.copy_from_bbox(self.ax.bbox) | ||
|
|
||
| onmove = _api.deprecate_privatize_attribute('3.5') | ||
|
|
||
| def _onmove(self, event): | ||
| """Internal event handler to draw the cursor when the mouse moves.""" | ||
| if self.ignore(event): | ||
| return | ||
| Expand All | @@ -1640,15 +1649,15 @@ def onmove(self, event): | |
| self.needclear = False | ||
| return | ||
| self.needclear = True | ||
| if not self.visible: | ||
| return | ||
|
|
||
| self.linev.set_xdata((event.xdata, event.xdata)) | ||
| self.linev.set_visible(self.visible and self.vertOn) | ||
|
|
||
| self.lineh.set_ydata((event.ydata, event.ydata)) | ||
| self.linev.set_visible(self.visible and self.vertOn) | ||
| self.lineh.set_visible(self.visible and self.horizOn) | ||
|
|
||
| self._update() | ||
| if self.visible and (self.vertOn or self.horizOn): | ||
| self._update() | ||
|
|
||
| def _update(self): | ||
| if self.useblit: | ||
| Expand Down Expand Up | @@ -1749,8 +1758,8 @@ def connect(self): | |
| """Connect events.""" | ||
| for canvas, info in self._canvas_infos.items(): | ||
| info["cids"] = [ | ||
| canvas.mpl_connect('motion_notify_event', self.onmove), | ||
| canvas.mpl_connect('draw_event', self.clear), | ||
| canvas.mpl_connect('motion_notify_event', self._onmove), | ||
| canvas.mpl_connect('draw_event', self._clear), | ||
| ] | ||
|
|
||
| def disconnect(self): | ||
| Expand All | @@ -1760,24 +1769,31 @@ def disconnect(self): | |
| canvas.mpl_disconnect(cid) | ||
| info["cids"].clear() | ||
|
|
||
| @_api.deprecated('3.5') | ||
| def clear(self, event): | ||
| """Clear the cursor.""" | ||
| if self.ignore(event): | ||
| return | ||
| self._clear(event) | ||
| for line in self.vlines + self.hlines: | ||
| line.set_visible(False) | ||
|
|
||
| def _clear(self, event): | ||
| """Clear the cursor.""" | ||
| if self.ignore(event): | ||
| return | ||
| if self.useblit: | ||
| for canvas, info in self._canvas_infos.items(): | ||
| info["background"] = canvas.copy_from_bbox(canvas.figure.bbox) | ||
| for line in self.vlines + self.hlines: | ||
| line.set_visible(False) | ||
|
|
||
| def onmove(self, event): | ||
| onmove = _api.deprecate_privatize_attribute('3.5') | ||
|
|
||
| def _onmove(self, event): | ||
| if (self.ignore(event) | ||
| or event.inaxes not in self.axes | ||
| or not event.canvas.widgetlock.available(self)): | ||
| return | ||
| self.needclear = True | ||
| if not self.visible: | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy drop this?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think we want to keep this short-circuit to avoid going to _update which avoids a draw_idle down the line.
Sorry, something went wrong.
ianhi reacted with thumbs up emoji
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIf that's the case, we might want to clarify that for our future selves with a comment.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWell, we want to remove it from here so that the later .set_visible is effective. I'll see if we can still skip the _update at least. Alternatively, we should turn the visibility attributes into property setters.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOh, I see now. We used to always make the lines not visible so if not self.visible we could safely bail. Do we need some more careful logic on this like to call self._update() if visible or just made invisible? I suspect there is now also some path where we can set self.vertOn or self.horizOn to False and then they never get removed?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI re-added a condition on the _update calls, which is hopefully sufficient.
Sorry, something went wrong.
All reactions
|
||
| return | ||
| if self.vertOn: | ||
| for line in self.vlines: | ||
| line.set_xdata((event.xdata, event.xdata)) | ||
| Expand All | @@ -1786,7 +1802,8 @@ def onmove(self, event): | |
| for line in self.hlines: | ||
| line.set_ydata((event.ydata, event.ydata)) | ||
| line.set_visible(self.visible) | ||
| self._update() | ||
| if self.visible and (self.vertOn or self.horizOn): | ||
| self._update() | ||
|
|
||
| def _update(self): | ||
| if self.useblit: | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySidenote but as far as I can tell self.needclear is never actually used in MultiCursor
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.