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

Skip to content

Commit 24dd283

Browse files
committed
STY: Update macosx zoom rect styling
Match the zoom box styling of the other backends with alternating white/black paths.
1 parent aca6e9d commit 24dd283

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/_macosx.m

Lines changed: 16 additions & 4 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+
double 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] set];
1342+
[white_path stroke];
1343+
[[NSColor blackColor] set];
1344+
[black_path stroke];
13341345
}
13351346

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

15271538
- (void)setRubberband:(NSRect)rect
15281539
{
1529-
if (!NSIsEmptyRect(rubberband)) { [self setNeedsDisplayInRect: rubberband]; }
15301540
rubberband = rect;
1531-
[self setNeedsDisplayInRect: rubberband];
1541+
// We can't just set DisplayInRect because the outer paths need to be removed
1542+
// when shrinking the zoom-box inwards
1543+
[self setNeedsDisplay: YES];
15321544
}
15331545

15341546
- (void)removeRubberband
15351547
{
15361548
if (NSIsEmptyRect(rubberband)) { return; }
1537-
[self setNeedsDisplayInRect: rubberband];
15381549
rubberband = NSZeroRect;
1550+
[self setNeedsDisplay: YES];
15391551
}
15401552

15411553
- (const char*)convertKeyEvent:(NSEvent*)event

0 commit comments

Comments
 (0)