| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Instead of manually adding tracking rectangles and updating for resize (older API), use a "newer" API (added OSX 10.5) for tracking areas. With the right flags, these areas are automatically updated for resize.
Just set some resizing flags on the view. This allows us to avoid manually resizing the view.
We can just request these events from the tracking area rather than manually enabling/disabling mouse move/checking inside.
Rename _device_scale to _dpi_ratio, as expected by Figure.set_size_inches(). Also, make sure the value of _dpi_ratio on instances of FigureCanvasMac are updated *before* setting figure DPI so that the proper value is available for downstream code. This is part of the fix needed to make set_size_inches work on macosx.
This allows Figure.set_size_inches to work.
|
Tagging 3.3 since the underlying issue is tagged 3.3. Would be nice to get the issue closed. |
Sorry, something went wrong.
There was a problem hiding this comment.
This works and the code seems fine.
I have no idea what the Rect stuff is supposed to be doing, and seems unrelated. OTOH I couldn't see that it broke anything. Some explanation would be helpful.... OK< sorry this was in the commit message.
Sorry, something went wrong.
|
Just given this a spin and it seems to work well. The only thing I've noticed is if I resize the window to have zero height, I get a bunch of messages like: File "/Users/dstansby/github/matplotlib/lib/matplotlib/figure.py", line 879, in set_size_inches
raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [ 5.65 -0.34]
Traceback (most recent call last):
File "/Users/dstansby/github/matplotlib/lib/matplotlib/backends/backend_macosx.py", line 84, in resize
forward=False)
File "/Users/dstansby/github/matplotlib/lib/matplotlib/figure.py", line 879, in set_size_inches
raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [ 5.6 -0.19] |
Sorry, something went wrong.
|
@dstansby We currently expect figures to have a finite height and width. However that may change, see #17093 (comment). |
Sorry, something went wrong.
|
In other backends (WebAgg, specifically), there are minimum sizes on the window so you can't do that. |
Sorry, something went wrong.
|
Yeah, I'm guessing the backend should enforce >0 figure height and width. |
Sorry, something went wrong.
|
So is that a requested change on this PR? |
Sorry, something went wrong.
|
I think it would be good to enforce a finite size for this PR, so that we can get it still into 3.3. There are considerations elsewhere to drop that limitations, but that needs additional changes in the code. |
Sorry, something went wrong.
Sorry, something went wrong.
|
@tacaswell Should be no interaction between this and either of those other two. @timhoffm To be clear, this PR does not make the figure size must be positive finite messages newly possible. I can get those today with master just fine: Traceback (most recent call last):
File "/Users/rmay/repos/matplotlib/lib/matplotlib/backends/backend_macosx.py", line 80, in resize
self.figure.set_size_inches(width * self._device_scale,
File "/Users/rmay/repos/matplotlib/lib/matplotlib/figure.py", line 879, in set_size_inches
raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [ 0.73 -0.24]
Traceback (most recent call last):
File "/Users/rmay/repos/matplotlib/lib/matplotlib/backends/backend_macosx.py", line 80, in resize
self.figure.set_size_inches(width * self._device_scale,
File "/Users/rmay/repos/matplotlib/lib/matplotlib/figure.py", line 879, in set_size_inches
raise ValueError(f'figure size must be positive finite not {size}')
ValueError: figure size must be positive finite not [ 0.73 -0.35]
(just grab the upper right corner and drag down and to the left past the lower left corner.) I can do it if strictly necessary, but it's not a new issue introduced by this PR. |
Sorry, something went wrong.
There was a problem hiding this comment.
I can't judge the Objective C changes, but in a simple test, the code works for me and solves the original problem of the mismatch between window size and figure size.
Sorry, something went wrong.
|
I'm going to merge then; finite size requirements can be a separate new PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
PR Checklist
Fixes #15131. In addition to implementing the missing method there are also a few clean-ups here for the macosx backend. This also depends on fixing handling of Figure.dpi changes in #16971 or #16972.