File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -1330,7 +1330,18 @@ -(void)drawRect:(NSRect)rect
1330
1330
goto exit ;
1331
1331
}
1332
1332
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 ];
1334
1345
}
1335
1346
1336
1347
exit :
@@ -1526,9 +1537,11 @@ - (void)otherMouseDragged:(NSEvent *)event { [self mouseDragged: event]; }
1526
1537
1527
1538
- (void )setRubberband : (NSRect )rect
1528
1539
{
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 )];
1530
1544
rubberband = rect;
1531
- [self setNeedsDisplayInRect: rubberband];
1532
1545
}
1533
1546
1534
1547
- (void )removeRubberband
You can’t perform that action at this time.
0 commit comments