Revision: 16617
http://sourceforge.net/p/skim-app/code/16617
Author: hofman
Date: 2026-10-06 17:10:51 +0000 (Tue, 06 Oct 2026)
Log Message:
-----------
ignore double points for freehand note drawing, remember previous point soe we
don't have to get it from the path
Modified Paths:
--------------
trunk/SKPDFView.m
trunk/SKPresentationView.m
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2026-10-05 17:26:17 UTC (rev 16616)
+++ trunk/SKPDFView.m 2026-10-06 17:10:51 UTC (rev 16617)
@@ -4242,6 +4242,7 @@
- (void)doDrawFreehandNoteWithEvent:(NSEvent *)theEvent {
NSPoint point = NSZeroPoint;
PDFPage *page = [self pageAndPoint:&point forEvent:theEvent nearest:YES];
+ NSPoint prevPoint = point;
NSWindow *window = [self window];
BOOL wasMouseCoalescingEnabled = [NSEvent isMouseCoalescingEnabled];
BOOL isOption = ([theEvent modifierFlags] & NSEventModifierFlagOption) !=
0;
@@ -4248,7 +4249,6 @@
BOOL wasOption = NO;
BOOL wantsBreak = isOption;
NSBezierPath *bezierPath = nil;
- CGMutablePathRef cgPath = NULL;
CGFloat scale = [self scaleFactor];
CAShapeLayer *layer = nil;
NSRect boxBounds = NSIntersectionRect([page boundsForBox:[self
displayBox]], [self convertRect:[self unobscuredContentRect] toPage:page]);
@@ -4306,22 +4306,27 @@
} else if ([theEvent type] == NSEventTypeLeftMouseDragged) {
- if (bezierPath == nil) {
- bezierPath = [NSBezierPath bezierPath];
- [bezierPath moveToPoint:point];
- } else if (wantsBreak && NO == NSEqualPoints(point, [bezierPath
associatedPointForElementAtIndex:[bezierPath elementCount] - 2])) {
- [PDFAnnotation addPoint:point toSkimNotesPath:bezierPath];
- }
-
+ NSPoint oldPrevPoint = prevPoint;
+ prevPoint = point;
point = [self convertPoint:[self convertPoint:[theEvent
locationInWindow] fromView:nil] toPage:page];
- if (isOption && wantsBreak == NO) {
+ if (NSEqualPoints(point, prevPoint)) {
+ prevPoint = oldPrevPoint;
+ continue;
+ } else if (isOption && wantsBreak == NO) {
NSInteger eltCount = [bezierPath elementCount];
NSPoint points[3] = {point, point, point};
+ prevPoint = oldPrevPoint;
if (NSCurveToBezierPathElement == [bezierPath
elementAtIndex:eltCount - 1])
- points[0] = [bezierPath
associatedPointForElementAtIndex:eltCount - 2];
+ points[0] = prevPoint;
[bezierPath setAssociatedPoints:points atIndex:eltCount - 1];
} else {
+ if (bezierPath == nil) {
+ bezierPath = [NSBezierPath bezierPath];
+ [bezierPath moveToPoint:point];
+ } else if (wantsBreak && NO == NSEqualPoints(point,
oldPrevPoint)) {
+ [PDFAnnotation addPoint:point toSkimNotesPath:bezierPath];
+ }
[PDFAnnotation addPoint:point toSkimNotesPath:bezierPath];
}
@@ -4328,7 +4333,7 @@
wasOption = isOption;
wantsBreak = NO;
- cgPath = CGPathCreateMutable();
+ CGMutablePathRef cgPath = CGPathCreateMutable();
[bezierPath addToCGPath:cgPath transform:&t];
[layer setPath:cgPath];
CGPathRelease(cgPath);
Modified: trunk/SKPresentationView.m
===================================================================
--- trunk/SKPresentationView.m 2026-10-05 17:26:17 UTC (rev 16616)
+++ trunk/SKPresentationView.m 2026-10-06 17:10:51 UTC (rev 16617)
@@ -951,6 +951,7 @@
[transform translateXBy:-NSMidX(bounds) yBy:-NSMidY(bounds)];
NSPoint point = [transform transformPoint:[self convertPoint:[theEvent
locationInWindow] fromView:nil]];
+ NSPoint prevPoint = point;
NSWindow *window = [self window];
BOOL wasMouseCoalescingEnabled = [NSEvent isMouseCoalescingEnabled];
BOOL isOption = ([theEvent modifierFlags] & NSEventModifierFlagOption) !=
0;
@@ -957,7 +958,6 @@
BOOL wasOption = NO;
BOOL wantsBreak = isOption;
NSBezierPath *bezierPath = nil;
- CGMutablePathRef cgPath = NULL;
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
CAShapeLayer *layer = nil;
NSRect boxBounds = pvFlags.autoScales ? pageBounds :
NSIntersectionRect(pageBounds, SKTransformRect(transform, bounds));
@@ -999,25 +999,27 @@
} else if ([theEvent type] == NSEventTypeLeftMouseDragged) {
- if (bezierPath == nil) {
- bezierPath = [NSBezierPath bezierPath];
- [bezierPath moveToPoint:point];
- } else if (wantsBreak && NO == NSEqualPoints(point, [bezierPath
associatedPointForElementAtIndex:[bezierPath elementCount] - 2])) {
- [PDFAnnotation addPoint:point toSkimNotesPath:bezierPath];
- }
-
+ NSPoint oldPrevPoint = prevPoint;
+ prevPoint = point;
point = [transform transformPoint:[self convertPoint:[theEvent
locationInWindow] fromView:nil]];
- if (isOption && wantsBreak == NO) {
+ if (NSEqualPoints(point, prevPoint)) {
+ prevPoint = oldPrevPoint;
+ continue;
+ } else if (isOption && wantsBreak == NO) {
NSInteger eltCount = [bezierPath elementCount];
NSPoint points[3] = {point, point, point};
- if (NSCurveToBezierPathElement == [bezierPath
elementAtIndex:eltCount - 1]) {
- points[0] = [bezierPath
associatedPointForElementAtIndex:eltCount - 2];
- points[0].x += ( point.x - points[0].x ) / 3.0;
- points[0].y += ( point.y - points[0].y ) / 3.0;
- }
+ prevPoint = oldPrevPoint;
+ if (NSCurveToBezierPathElement == [bezierPath
elementAtIndex:eltCount - 1])
+ points[0] = prevPoint;
[bezierPath setAssociatedPoints:points atIndex:eltCount - 1];
} else {
+ if (bezierPath == nil) {
+ bezierPath = [NSBezierPath bezierPath];
+ [bezierPath moveToPoint:prevPoint];
+ } else if (wantsBreak && NO == NSEqualPoints(prevPoint,
oldPrevPoint)) {
+ [PDFAnnotation addPoint:prevPoint
toSkimNotesPath:bezierPath];
+ }
[PDFAnnotation addPoint:point toSkimNotesPath:bezierPath];
}
@@ -1024,7 +1026,7 @@
wasOption = isOption;
wantsBreak = NO;
- cgPath = CGPathCreateMutable();
+ CGMutablePathRef cgPath = CGPathCreateMutable();
[bezierPath addToCGPath:cgPath transform:&t];
[layer setPath:cgPath];
CGPathRelease(cgPath);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit