Revision: 7675
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7675&view=rev
Author:   hofman
Date:     2012-03-01 18:09:15 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
Allow displayrect for note to depend on line width, used for ink and line. Use 
that when bounds or line width changes so we can redraw.

Modified Paths:
--------------
    trunk/PDFAnnotationInk_SKExtensions.m
    trunk/PDFAnnotationLine_SKExtensions.m
    trunk/PDFAnnotationMarkup_SKExtensions.m
    trunk/PDFAnnotation_SKExtensions.h
    trunk/PDFAnnotation_SKExtensions.m
    trunk/PDFView_SKExtensions.m
    trunk/SKMainWindowController.m
    trunk/SKPDFView.m
    trunk/SKSnapshotWindowController.m

Modified: trunk/PDFAnnotationInk_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationInk_SKExtensions.m       2012-02-28 18:20:10 UTC (rev 
7674)
+++ trunk/PDFAnnotationInk_SKExtensions.m       2012-03-01 18:09:15 UTC (rev 
7675)
@@ -163,13 +163,12 @@
     return NO;
 }
 
-- (NSRect)displayRectForBounds:(NSRect)bounds {
-    CGFloat lineWidth = [self lineWidth];
+- (NSRect)displayRectForBounds:(NSRect)bounds lineWidth:(CGFloat)lineWidth {
     NSRect rect = NSZeroRect;
     for (NSBezierPath *path in [self paths])
         rect = NSUnionRect(rect, NSInsetRect([path nonEmptyBounds], 
-lineWidth, -lineWidth));
     rect.origin = SKAddPoints(rect.origin, bounds.origin);
-    return NSUnionRect([super displayRectForBounds:bounds], 
NSIntegralRect(rect));
+    return NSUnionRect([super displayRectForBounds:bounds 
lineWidth:lineWidth], NSIntegralRect(rect));
 }
 
 - (NSArray *)pointLists {

Modified: trunk/PDFAnnotationLine_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationLine_SKExtensions.m      2012-02-28 18:20:10 UTC (rev 
7674)
+++ trunk/PDFAnnotationLine_SKExtensions.m      2012-03-01 18:09:15 UTC (rev 
7675)
@@ -108,10 +108,11 @@
     return SKPointNearLineFromPointToPoint(SKSubstractPoints(point, [self 
bounds].origin), [self startPoint], [self endPoint], delta);
 }
 
-- (NSRect)displayRectForBounds:(NSRect)bounds {
-    bounds = [super displayRectForBounds:bounds];
-    // need a large padding amount for large line width and cap changes, we 
may have this depend on the line width
-    return NSInsetRect(bounds, -16.0, -16.0);
+- (NSRect)displayRectForBounds:(NSRect)bounds lineWidth:(CGFloat)lineWidth {
+    bounds = [super displayRectForBounds:bounds lineWidth:lineWidth];
+    // need a large padding amount for large line width and cap changes
+    CGFloat delta = ceil(fmax(2.0 * lineWidth, 2.0));
+    return NSInsetRect(bounds, -delta, -delta);
 }
 
 - (SKRectEdges)resizeHandleForPoint:(NSPoint)point 
scaleFactor:(CGFloat)scaleFactor {

Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m    2012-02-28 18:20:10 UTC (rev 
7674)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m    2012-03-01 18:09:15 UTC (rev 
7675)
@@ -286,8 +286,8 @@
     return isContained;
 }
 
-- (NSRect)displayRectForBounds:(NSRect)bounds {
-    bounds = [super displayRectForBounds:bounds];
+- (NSRect)displayRectForBounds:(NSRect)bounds lineWidth:(CGFloat)lineWidth {
+    bounds = [super displayRectForBounds:bounds lineWidth:lineWidth];
     if ([self markupType] == kPDFMarkupTypeHighlight) {
         CGFloat delta = 0.03 * NSHeight(bounds);
         bounds.origin.y -= delta;

Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h  2012-02-28 18:20:10 UTC (rev 7674)
+++ trunk/PDFAnnotation_SKExtensions.h  2012-03-01 18:09:15 UTC (rev 7675)
@@ -82,7 +82,8 @@
 
 - (BOOL)hitTest:(NSPoint)point;
 
-- (NSRect)displayRectForBounds:(NSRect)bounds;
+- (NSRect)displayRectForBounds:(NSRect)bounds lineWidth:(CGFloat)lineWidth;
+- (NSRect)displayRect;
 
 - (SKRectEdges)resizeHandleForPoint:(NSPoint)point 
scaleFactor:(CGFloat)scaleFactor;
 

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2012-02-28 18:20:10 UTC (rev 7674)
+++ trunk/PDFAnnotation_SKExtensions.m  2012-03-01 18:09:15 UTC (rev 7675)
@@ -167,7 +167,7 @@
 }
 
 - (CGFloat)lineWidth {
-    return [[self border] lineWidth];
+    return [self border] ? [[self border] lineWidth] : 0.0;
 }
 
 - (void)setLineWidth:(CGFloat)width {
@@ -235,10 +235,14 @@
     return [self shouldDisplay] ? NSPointInRect(point, [self bounds]) : NO;
 }
 
-- (NSRect)displayRectForBounds:(NSRect)bounds {
+- (NSRect)displayRectForBounds:(NSRect)bounds lineWidth:(CGFloat)lineWidth {
     return bounds;
 }
 
+- (NSRect)displayRect {
+    return [self displayRectForBounds:[self bounds] lineWidth:[self 
lineWidth]];
+}
+
 - (SKRectEdges)resizeHandleForPoint:(NSPoint)point 
scaleFactor:(CGFloat)scaleFactor {
     return [self isResizable] ? SKResizeHandleForPointFromRect(point, [self 
bounds], 4.0 / scaleFactor) : 0;
 }

Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m        2012-02-28 18:20:10 UTC (rev 7674)
+++ trunk/PDFView_SKExtensions.m        2012-03-01 18:09:15 UTC (rev 7675)
@@ -79,7 +79,7 @@
 }
 
 - (void)setNeedsDisplayForAnnotation:(PDFAnnotation *)annotation 
onPage:(PDFPage *)page {
-    [self setNeedsDisplayInRect:[annotation displayRectForBounds:[annotation 
bounds]] ofPage:page];
+    [self setNeedsDisplayInRect:[annotation displayRect] ofPage:page];
     [self annotationsChangedOnPage:page];
 }
 

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2012-02-28 18:20:10 UTC (rev 7674)
+++ trunk/SKMainWindowController.m      2012-03-01 18:09:15 UTC (rev 7675)
@@ -2250,11 +2250,10 @@
                 PDFPage *page = [note page];
                 NSRect oldRect = NSZeroRect;
                 if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey] && 
[oldValue isEqual:[NSNull null]] == NO) {
-                    oldRect = [note displayRectForBounds:[oldValue rectValue]];
-                } else if ([[note type] isEqualToString:SKNInkString] && 
[keyPath isEqualToString:SKNPDFAnnotationBorderKey] && [oldValue 
isEqual:[NSNull null]] == NO) {
-                    CGFloat dw = [oldValue lineWidth] - ([oldValue 
isEqual:[NSNull null]] ? 0.0 : [newValue lineWidth]);
-                    if (dw > 0.0)
-                        oldRect = NSInsetRect([note displayRectForBounds:[note 
bounds]], -dw, -dw);
+                    oldRect = [note displayRectForBounds:[oldValue rectValue] 
lineWidth:[note lineWidth]];
+                } else if ([keyPath isEqualToString:SKNPDFAnnotationBorderKey] 
&& [oldValue isEqual:[NSNull null]] == NO) {
+                    if ([oldValue lineWidth] > [note lineWidth])
+                        oldRect = [note displayRectForBounds:[note bounds] 
lineWidth:[oldValue lineWidth]];
                 }
                 
                 [self updateThumbnailAtPageIndex:[note pageIndex]];

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2012-02-28 18:20:10 UTC (rev 7674)
+++ trunk/SKPDFView.m   2012-03-01 18:09:15 UTC (rev 7675)
@@ -4231,7 +4231,7 @@
 }
 
 - (void)setNeedsDisplayForAnnotation:(PDFAnnotation *)annotation 
onPage:(PDFPage *)page {
-    NSRect rect = [annotation displayRectForBounds:[annotation bounds]];
+    NSRect rect = [annotation displayRect];
     if (annotation == activeAnnotation && [annotation isResizable]) {
         CGFloat margin = 4.0 / [self scaleFactor];
         rect = NSInsetRect(rect, -margin, -margin);

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2012-02-28 18:20:10 UTC (rev 7674)
+++ trunk/SKSnapshotWindowController.m  2012-03-01 18:09:15 UTC (rev 7675)
@@ -127,7 +127,7 @@
 }
 
 - (void)setNeedsDisplayForAnnotation:(PDFAnnotation *)annotation 
onPage:(PDFPage *)page {
-    [self setNeedsDisplayInRect:[annotation displayRectForBounds:[annotation 
bounds]] ofPage:page];
+    [self setNeedsDisplayInRect:[annotation displayRect] ofPage:page];
 }
 
 - (void)redisplay {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to