Skip to content

STY: Update macosx zoom rect styling #24367

New issue

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

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

greglucas
Copy link
Contributor

PR Summary

Match the zoom box styling of the other backends with alternating white/black paths.

closes #23777

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (and pytest passes).
  • [N/A] Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [N/A] New plotting related features are documented with examples.

Release Notes

  • [N/A] New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • [N/A] API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • [N/A] Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@greglucas greglucas added this to the v3.7.0 milestone Nov 4, 2022
@greglucas greglucas marked this pull request as ready for review November 4, 2022 20:16
@greglucas greglucas force-pushed the macosx-zoom-box-style branch from 24dd283 to 50f25ed Compare November 5, 2022 15:55
src/_macosx.m Outdated
// in phase.
NSBezierPath *white_path = [NSBezierPath bezierPathWithRect: rubberband];
NSBezierPath *black_path = [NSBezierPath bezierPathWithRect: rubberband];
double dash_pattern[2] = {3, 3};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be CGFloat technically.

Suggested change
double dash_pattern[2] = {3, 3};
CGFloat dash_pattern[2] = {3, 3};

@@ -1526,9 +1537,11 @@ - (void)otherMouseDragged:(NSEvent *)event { [self mouseDragged: event]; }

- (void)setRubberband:(NSRect)rect
{
if (!NSIsEmptyRect(rubberband)) { [self setNeedsDisplayInRect: rubberband]; }
// The space we want to redraw is a union of the previous rubberband
// with the new rubberband and then expanded (negative inset) by one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking if this is in logical space or physical space (i.e., should be one or one * display ratio)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On HiDPI, this still clears the region and I'm not sure we want to bring in the deviceScale/contextRegion if we don't absolutely need to here. The linewidth is drawn in points and centered on the rectangle area, so the default linewidth of 1 expands 0.5 points on either side of the rect. (linewidth section from here
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Paths/Paths.html#//apple_ref/doc/uid/TP40003290-CH206-BBCDEJGD)

@oscargus
Copy link
Member

oscargus commented Nov 8, 2022

Two things (I cannot test or judge the code...):

  1. The (some) other backends draw one solid line and one dashed on top. It may be worth checking if that improves or degrades performance. (It is primarily done because it was hard to get an offset in those, though.)
  2. This can possibly go in 3.6.3 as it is in some sense a bug fix. The other backends went into 3.6.2.

Match the zoom box styling of the other backends with alternating
white/black paths.
@greglucas greglucas force-pushed the macosx-zoom-box-style branch from 50f25ed to cb68ffd Compare November 8, 2022 15:42
@greglucas
Copy link
Contributor Author

The (some) other backends draw one solid line and one dashed on top. It may be worth checking if that improves or degrades performance. (It is primarily done because it was hard to get an offset in those, though.)

This is already so fast I don't think it is worth worrying about performance. I also don't want to overlap if we can avoid it so we don't have any additional weird aliasing / blending going on for the overlapping regions.

This can possibly go in 3.6.3 as it is in some sense a bug fix. The other backends went into 3.6.2.

I see this as an enhancement/improvement and not a bugfix. I really don't think these should be backported, but rather if we want it in sooner, a new minor release should happen sooner. The cursor styling and other aesthetic changes like that should be in minor versions not patch IMO.

@oscargus
Copy link
Member

oscargus commented Nov 8, 2022

OK! Makes sense. I was under the impression that something had changed in recent versions, but maybe it is just a consequence of more and more people using dark themes that we get those bug reports now...

@greglucas
Copy link
Contributor Author

ping for a macosx user to review this. It'd be nice to get in for the 3.7 release to keep the backends consistent in their styling.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me. The dashes are a bit small on my hiDPI screen compared to a zoom rectangle in Preview.app, but not crazy different. I'm a little surprised there is not an API for a rubberband already, but this seems to work.

@tacaswell
Copy link
Member

Confirmed that this looks good axes with white, black, and "0.5" patch colors.

@tacaswell tacaswell merged commit e0d65b6 into matplotlib:main Dec 13, 2022
@greglucas greglucas deleted the macosx-zoom-box-style branch December 13, 2022 00:10
@greglucas
Copy link
Contributor Author

The dashes are a bit small on my hiDPI screen compared to a zoom rectangle in Preview.app, but not crazy different

I think the lines should be the same thickness as before, just dashed now. It is easy enough to increase the thickness if desired too. On preview for me, the dash pattern actually rotates around.

@jklymak
Copy link
Member

jklymak commented Dec 13, 2022

On preview for me, the dash pattern actually rotates around.

Yes, but I wasn't going to ask you to do that. However, that is what made me think there must be a selector API

@QuLogic
Copy link
Member

QuLogic commented Dec 13, 2022

On preview for me, the dash pattern actually rotates around.

What do you mean by rotates around?

@jklymak
Copy link
Member

jklymak commented Dec 13, 2022

The dash pattern precesses around the selection in a clockwise manner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH] Interactive Zoom Rectangle Color Review for MACOSX backend
5 participants