|
@@ -3057,20 +3057,20 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
}
|
|
|
|
|
|
if (NSEqualPoints(startPoint, endPoint) == NO) {
|
|
|
- NSRect newBounds = CPDFListViewIntegralRectFromPoints(startPoint, endPoint);
|
|
|
-
|
|
|
- if (NSWidth(newBounds) < MIN_NOTE_SIZE) {
|
|
|
- newBounds.size.width = MIN_NOTE_SIZE;
|
|
|
- newBounds.origin.x = floor(0.5 * ((startPoint.x + endPoint.x) - MIN_NOTE_SIZE));
|
|
|
- }
|
|
|
- if (NSHeight(newBounds) < MIN_NOTE_SIZE) {
|
|
|
- newBounds.size.height = MIN_NOTE_SIZE;
|
|
|
- newBounds.origin.y = floor(0.5 * ((startPoint.y + endPoint.y) - MIN_NOTE_SIZE));
|
|
|
- }
|
|
|
-
|
|
|
+// NSRect newBounds = CPDFListViewIntegralRectFromPoints(startPoint, endPoint);
|
|
|
+//
|
|
|
+// if (NSWidth(newBounds) < MIN_NOTE_SIZE) {
|
|
|
+// newBounds.size.width = MIN_NOTE_SIZE;
|
|
|
+// newBounds.origin.x = floor(0.5 * ((startPoint.x + endPoint.x) - MIN_NOTE_SIZE));
|
|
|
+// }
|
|
|
+// if (NSHeight(newBounds) < MIN_NOTE_SIZE) {
|
|
|
+// newBounds.size.height = MIN_NOTE_SIZE;
|
|
|
+// newBounds.origin.y = floor(0.5 * ((startPoint.y + endPoint.y) - MIN_NOTE_SIZE));
|
|
|
+// }
|
|
|
+//
|
|
|
[(CPDFLineAnnotation *)activeAnnotation setObservedStartPoint:startPoint];
|
|
|
[(CPDFLineAnnotation *)activeAnnotation setObservedEndPoint:endPoint];
|
|
|
- [activeAnnotation setBounds:newBounds];
|
|
|
+// [activeAnnotation setBounds:newBounds];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4458,6 +4458,95 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
lineAnnotation.bounds = bound;
|
|
|
}
|
|
|
|
|
|
+- (void)doMoveAnnotation:(CPDFAnnotation *)activeAnnotation withEvent:(NSEvent *)theEvent boundOffset:(NSPoint)boundOffset offset:(NSPoint)offset{
|
|
|
+ // Move annotation.
|
|
|
+ [[[self scrollView] contentView] autoscroll:theEvent];
|
|
|
+
|
|
|
+ NSPoint point = NSZeroPoint;
|
|
|
+ CPDFPage *newActivePage = [self pageAndPoint:&point forEvent:theEvent nearest:YES];
|
|
|
+
|
|
|
+ if (newActivePage) { // newActivePage should never be nil, but just to be sure
|
|
|
+ if (newActivePage != [activeAnnotation page]) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSRect newBounds = [activeAnnotation bounds];
|
|
|
+ newBounds.origin = CPDFListViewIntegralPoint(CPDFListViewSubstractPoints(point, boundOffset));
|
|
|
+ // constrain bounds inside page bounds
|
|
|
+ newBounds = CPDFListViewConstrainRect(newBounds, [newActivePage boundsForBox:[self displayBox]],[CPDFListViewConfig defaultManager].annotationBorderOffset.floatValue);
|
|
|
+
|
|
|
+ if([activeAnnotation isKindOfClass:[CPDFLineAnnotation class]]) {
|
|
|
+ CPDFLineAnnotation *line = (CPDFLineAnnotation *)activeAnnotation;
|
|
|
+ NSPoint startPoint = [line startPoint];
|
|
|
+ NSPoint endPoint = [line endPoint];
|
|
|
+ CPDFDistanceMeasureInfo *me = [line measureInfo];
|
|
|
+
|
|
|
+ startPoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(startPoint, offset));
|
|
|
+ endPoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(endPoint, offset));
|
|
|
+
|
|
|
+ CGRect boderRect = [self borderRecctForSavePoints:[line pointsFromMeasureWithStartPoint:startPoint endPoint:endPoint]];
|
|
|
+ BOOL isContant = CGRectContainsRect([activeAnnotation.page boundsForBox:[self displayBox]], boderRect);
|
|
|
+ if (isContant) {
|
|
|
+ [line setStartPoint:startPoint];
|
|
|
+ [line setEndPoint:endPoint];
|
|
|
+ if(line.isMeasure) {
|
|
|
+ [activeAnnotation setBounds:newBounds];
|
|
|
+ [line setMeasureInfo:me];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if ([activeAnnotation isKindOfClass:[CPDFPolylineAnnotation class]]) {
|
|
|
+ CPDFPolylineAnnotation *line = (CPDFPolylineAnnotation *)activeAnnotation;
|
|
|
+
|
|
|
+ NSMutableArray<NSValue *> *savePoints = [NSMutableArray arrayWithArray:[line savePoints]];
|
|
|
+ CPDFPerimeterMeasureInfo *me = [line measureInfo];
|
|
|
+
|
|
|
+ NSMutableArray<NSValue *> *newSavePoints = [NSMutableArray array];
|
|
|
+ for (NSValue *saveValue in savePoints) {
|
|
|
+ NSPoint savePoint = [saveValue pointValue];
|
|
|
+ savePoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(savePoint, offset));
|
|
|
+ [newSavePoints addObject:[NSValue valueWithPoint:savePoint]];
|
|
|
+ }
|
|
|
+
|
|
|
+ CGRect boderRect = [self borderRecctForSavePoints:newSavePoints];
|
|
|
+ BOOL isContant = CGRectContainsRect([newActivePage boundsForBox:[self displayBox]], boderRect);
|
|
|
+
|
|
|
+ if (isContant) {
|
|
|
+ [(CPDFPolylineAnnotation *)activeAnnotation setSavePoints:newSavePoints];
|
|
|
+ if(line.isMeasure) {
|
|
|
+ [activeAnnotation setBounds:newBounds];
|
|
|
+ [line setMeasureInfo:me];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if ([activeAnnotation isKindOfClass:[CPDFPolygonAnnotation class]]) {
|
|
|
+ CPDFPolygonAnnotation *polygonAnnotation = (CPDFPolygonAnnotation *)activeAnnotation;
|
|
|
+
|
|
|
+ NSMutableArray<NSValue *> *savePoints = [NSMutableArray arrayWithArray:[polygonAnnotation savePoints]];
|
|
|
+ CPDFAreaMeasureInfo *me = [polygonAnnotation measureInfo];
|
|
|
+
|
|
|
+ NSMutableArray<NSValue *> *newSavePoints = [NSMutableArray array];
|
|
|
+ for (NSValue *saveValue in savePoints) {
|
|
|
+ NSPoint savePoint = [saveValue pointValue];
|
|
|
+ savePoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(savePoint, offset));
|
|
|
+ [newSavePoints addObject:[NSValue valueWithPoint:savePoint]];
|
|
|
+ }
|
|
|
+
|
|
|
+ CGRect boderRect = [self borderRecctForSavePoints:newSavePoints];
|
|
|
+ BOOL isContant = CGRectContainsRect([newActivePage boundsForBox:[self displayBox]], boderRect);
|
|
|
+
|
|
|
+ if (isContant) {
|
|
|
+ [polygonAnnotation setSavePoints:newSavePoints];
|
|
|
+ if(polygonAnnotation.isMeasure) {
|
|
|
+ [activeAnnotation setBounds:newBounds];
|
|
|
+ [polygonAnnotation setMeasureInfo:me];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ [activeAnnotation setBounds:newBounds];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)doMoveAnnotation:(CPDFAnnotation *)activeAnnotation withEvent:(NSEvent *)theEvent offset:(NSPoint)offset {
|
|
|
// Move annotation.
|
|
|
[[[self scrollView] contentView] autoscroll:theEvent];
|
|
@@ -4968,6 +5057,11 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
lastMouseEvent = theEvent;
|
|
|
draggedAnnotation = YES;
|
|
|
[self removeShapeLayer];
|
|
|
+
|
|
|
+ NSPoint currentPoint = NSZeroPoint;
|
|
|
+ [self pageAndPoint:¤tPoint forEvent:theEvent nearest:YES];
|
|
|
+ CGPoint offsetPoint = CGPointMake(currentPoint.x - pagePoint.x, currentPoint.y - pagePoint.y);
|
|
|
+
|
|
|
if(!isContains) {
|
|
|
|
|
|
CGRect borderRect = [newActiveAnnotation borderRecctForView:self];
|
|
@@ -4978,53 +5072,47 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
[self.selectAnnotations removeAllObjects];
|
|
|
[self.selectAnnotations addObject:newActiveAnnotation];
|
|
|
if(isLine) {
|
|
|
- NSPoint currentPoint = NSZeroPoint;
|
|
|
- [self pageAndPoint:¤tPoint forEvent:theEvent nearest:YES];
|
|
|
-
|
|
|
- CGPoint offsetPoint = CGPointMake(currentPoint.x - pagePoint.x, currentPoint.y - pagePoint.y);
|
|
|
- [self doMoveLineAnnotation:(CPDFLineAnnotation *)newActiveAnnotation offset:offsetPoint];
|
|
|
- pagePoint = currentPoint;
|
|
|
+ [self doMoveAnnotation:(CPDFLineAnnotation *)newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
|
|
|
+// [self doMoveAnnotation:(CPDFLineAnnotation *)newActiveAnnotation withEvent:theEvent offset:offsetPoint];
|
|
|
if (isMeasure) {
|
|
|
if (self.pdfListViewDelegate && [self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationMeasureInfoChange:withAnnotation:)]) {
|
|
|
[self.pdfListViewDelegate PDFListViewAnnotationMeasureInfoChange:self withAnnotation:newActiveAnnotation];
|
|
|
}
|
|
|
}
|
|
|
} else if (isPolyline || isPolygon || isSquarePolygon) {
|
|
|
- [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent offset:offset];
|
|
|
+ [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
|
|
|
if (isMeasure) {
|
|
|
|
|
|
if (self.pdfListViewDelegate && [self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationMeasureInfoChange:withAnnotation:)]) {
|
|
|
[self.pdfListViewDelegate PDFListViewAnnotationMeasureInfoChange:self withAnnotation:newActiveAnnotation];
|
|
|
}
|
|
|
}
|
|
|
- } else
|
|
|
- [self doMoveAnnotation:newActiveAnnotation withEvent:lastMouseEvent offset:offset];
|
|
|
+ } else {
|
|
|
+ [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
|
|
|
+ }
|
|
|
+ pagePoint = currentPoint;
|
|
|
} else {
|
|
|
if (resizeHandle == CEditInEdgeMask) {
|
|
|
if(isLine) {
|
|
|
- NSPoint currentPoint = NSZeroPoint;
|
|
|
- [self pageAndPoint:¤tPoint forEvent:theEvent nearest:YES];
|
|
|
-
|
|
|
- CGPoint offsetPoint = CGPointMake(currentPoint.x - pagePoint.x, currentPoint.y - pagePoint.y);
|
|
|
- [self doMoveLineAnnotation:(CPDFLineAnnotation *)newActiveAnnotation offset:offsetPoint];
|
|
|
- pagePoint = currentPoint;
|
|
|
+ [self doMoveAnnotation:(CPDFLineAnnotation *)newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
|
|
|
+// [self doMoveAnnotation:(CPDFLineAnnotation *)newActiveAnnotation withEvent:theEvent offset:offset];
|
|
|
if (isMeasure) {
|
|
|
if (self.pdfListViewDelegate && [self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationMeasureInfoChange:withAnnotation:)]) {
|
|
|
[self.pdfListViewDelegate PDFListViewAnnotationMeasureInfoChange:self withAnnotation:newActiveAnnotation];
|
|
|
}
|
|
|
}
|
|
|
} else if (isPolyline || isPolygon || isSquarePolygon) {
|
|
|
- [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent offset:offset];
|
|
|
-
|
|
|
+ [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
|
|
|
+
|
|
|
if (isMeasure) {
|
|
|
|
|
|
if (self.pdfListViewDelegate && [self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationMeasureInfoChange:withAnnotation:)]) {
|
|
|
[self.pdfListViewDelegate PDFListViewAnnotationMeasureInfoChange:self withAnnotation:newActiveAnnotation];
|
|
|
}
|
|
|
}
|
|
|
- } else
|
|
|
- [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent offset:offset];
|
|
|
-
|
|
|
+ } else {
|
|
|
+ [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
|
|
|
+ }
|
|
|
} else if (isLine) {
|
|
|
if (isMeasure) {
|
|
|
[self doResizeMeasureLineAnnotationWithEvent:lastMouseEvent fromPoint:pagePoint originalStartPoint:originalStartPoint originalEndPoint:originalEndPoint translatedOriginalStartPoint:translatedOriginalStartPoint translatedOriginalEndPoint:translatedOriginalEndPoint resizeHandle:resizeHandle];
|