Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0d65b6

Browse files
authored
Merge pull request #24367 from greglucas/macosx-zoom-box-style
STY: Update macosx zoom rect styling
2 parents a86b4f6 + cb68ffd commit e0d65b6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/_macosx.m

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,18 @@ -(void)drawRect:(NSRect)rect
13301330
goto exit;
13311331
}
13321332
if (!NSIsEmptyRect(rubberband)) {
1333-
NSFrameRect(rubberband);
1333+
// We use bezier paths so we can stroke the outside with a dash
1334+
// pattern alternating white/black with two separate paths offset
1335+
// in phase.
1336+
NSBezierPath *white_path = [NSBezierPath bezierPathWithRect: rubberband];
1337+
NSBezierPath *black_path = [NSBezierPath bezierPathWithRect: rubberband];
1338+
CGFloat dash_pattern[2] = {3, 3};
1339+
[white_path setLineDash: dash_pattern count: 2 phase: 0];
1340+
[black_path setLineDash: dash_pattern count: 2 phase: 3];
1341+
[[NSColor whiteColor] setStroke];
1342+
[white_path stroke];
1343+
[[NSColor blackColor] setStroke];
1344+
[black_path stroke];
13341345
}
13351346

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

15271538
- (void)setRubberband:(NSRect)rect
15281539
{
1529-
if (!NSIsEmptyRect(rubberband)) { [self setNeedsDisplayInRect: rubberband]; }
1540+
// The space we want to redraw is a union of the previous rubberband
1541+
// with the new rubberband and then expanded (negative inset) by one
1542+
// in each direction to account for the stroke linewidth.
1543+
[self setNeedsDisplayInRect: NSInsetRect(NSUnionRect(rect, rubberband), -1, -1)];
15301544
rubberband = rect;
1531-
[self setNeedsDisplayInRect: rubberband];
15321545
}
15331546

15341547
- (void)removeRubberband

0 commit comments

Comments
 (0)