Repository navigation
Implement FigureManager.resize for macosx backend - #16992
Conversation
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. |
|
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] |
|
@dstansby We currently expect figures to have a finite height and width. However that may change, see #17093 (comment). |
|
In other backends (WebAgg, specifically), there are minimum sizes on the window so you can't do that. |
|
Yeah, I'm guessing the backend should enforce >0 figure height and width. |
|
So is that a requested change on this PR? |
|
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. |
|
@tacaswell Should be no interaction between this and either of those other two. @timhoffm To be clear, this PR does not make the (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. |
efiring
left a comment
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.
|
I'm going to merge then; finite size requirements can be a separate new PR. |
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.dpichanges in #16971 or #16972.