FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

STY: Update macosx zoom rect styling by greglucas · Pull Request #24367 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .m  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 16 additions & 3 deletions src/_macosx.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,18 @@ -(void)drawRect:(NSRect)rect
goto exit;
}
if (!NSIsEmptyRect(rubberband)) {
NSFrameRect(rubberband);
// We use bezier paths so we can stroke the outside with a dash
// pattern alternating white/black with two separate paths offset
// in phase.
NSBezierPath *white_path = [NSBezierPath bezierPathWithRect: rubberband];
NSBezierPath *black_path = [NSBezierPath bezierPathWithRect: rubberband];
CGFloat dash_pattern[2] = {3, 3};
[white_path setLineDash: dash_pattern count: 2 phase: 0];
[black_path setLineDash: dash_pattern count: 2 phase: 3];
[[NSColor whiteColor] setStroke];
[white_path stroke];
[[NSColor blackColor] setStroke];
[black_path stroke];
}

exit:
Expand Down Expand Up @@ -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
Copy Markdown
Member

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 Quality

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

Copy link
Copy Markdown
Contributor Author

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 Quality

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)

// in each direction to account for the stroke linewidth.
[self setNeedsDisplayInRect: NSInsetRect(NSUnionRect(rect, rubberband), -1, -1)];
rubberband = rect;
[self setNeedsDisplayInRect: rubberband];
}

- (void)removeRubberband
Expand Down

Back | FazBrowse Home | New Git URL