Revision: 7242
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7242&view=rev
Author:   hofman
Date:     2011-05-16 13:14:09 +0000 (Mon, 16 May 2011)

Log Message:
-----------
convenience function for a square centered rect

Modified Paths:
--------------
    trunk/NSGeometry_SKExtensions.h
    trunk/SKNavigationWindow.m
    trunk/SKPDFView.m
    trunk/SKRemoteStateWindow.m

Modified: trunk/NSGeometry_SKExtensions.h
===================================================================
--- trunk/NSGeometry_SKExtensions.h     2011-05-16 11:24:49 UTC (rev 7241)
+++ trunk/NSGeometry_SKExtensions.h     2011-05-16 13:14:09 UTC (rev 7242)
@@ -119,6 +119,15 @@
     return rect;
 }
 
+static inline NSRect SKRectFromCenterAndSquareSize(NSPoint center, CGFloat 
size) {
+    NSRect rect;
+    rect.origin.x = center.x - 0.5 * size;
+    rect.origin.y = center.y - 0.5 * size;
+    rect.size.width = size;
+    rect.size.height = size;
+    return rect;
+}
+
 #pragma mark -
 
 extern NSPoint SKConstrainPointInRect(NSPoint point, NSRect boundary);

Modified: trunk/SKNavigationWindow.m
===================================================================
--- trunk/SKNavigationWindow.m  2011-05-16 11:24:49 UTC (rev 7241)
+++ trunk/SKNavigationWindow.m  2011-05-16 13:14:09 UTC (rev 7242)
@@ -548,7 +548,7 @@
         [[NSColor colorWithDeviceWhite:1.0 alpha:0.3] setFill];
     }
     
-    [[NSBezierPath 
bezierPathWithOvalInRect:SKRectFromCenterAndSize(SKCenterPoint(frame), 
SKMakeSquareSize(15.0))] fill];
+    [[NSBezierPath 
bezierPathWithOvalInRect:SKRectFromCenterAndSquareSize(SKCenterPoint(frame), 
15.0)] fill];
 }
 
 - (BOOL)_usesCustomTrackImage { return YES; }

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2011-05-16 11:24:49 UTC (rev 7241)
+++ trunk/SKPDFView.m   2011-05-16 13:14:09 UTC (rev 7242)
@@ -463,7 +463,7 @@
         }
         
         [[NSColor redColor] setFill];
-        [[NSBezierPath 
bezierPathWithOvalInRect:SKRectFromCenterAndSize(syncPoint, 
SKMakeSquareSize(s))] fill];
+        [[NSBezierPath 
bezierPathWithOvalInRect:SKRectFromCenterAndSquareSize(syncPoint, s)] fill];
         
         [NSGraphicsContext restoreGraphicsState];
     }
@@ -2199,7 +2199,7 @@
 
 - (void)removeSyncPoint:(NSTimer *)timer {
     if (syncPageIndex != NSNotFound)
-        [self setNeedsDisplayInRect:SKRectFromCenterAndSize(syncPoint, 
NSMakeSize(8.0, 8.0)) ofPage:[[self document] pageAtIndex:syncPageIndex]];
+        [self setNeedsDisplayInRect:SKRectFromCenterAndSquareSize(syncPoint, 
8.0) ofPage:[[self document] pageAtIndex:syncPageIndex]];
     syncPoint = NSZeroPoint;
     syncPageIndex = NSNotFound;
     [syncTimer invalidate];
@@ -2208,7 +2208,7 @@
 
 - (void)animateSyncPoint:(NSTimer *)timer {
     if (syncPageIndex != NSNotFound)
-        [self setNeedsDisplayInRect:SKRectFromCenterAndSize(syncPoint, 
NSMakeSize(20.0, 20.0)) ofPage:[[self document] pageAtIndex:syncPageIndex]];
+        [self setNeedsDisplayInRect:SKRectFromCenterAndSquareSize(syncPoint, 
20.0) ofPage:[[self document] pageAtIndex:syncPageIndex]];
     syncPhase += 0.1;
     if (syncPhase >= 1.0) {
         [syncTimer invalidate];
@@ -2221,7 +2221,7 @@
     if (pageIndex < [[self document] pageCount]) {
         PDFPage *page = [[self document] pageAtIndex:pageIndex];
         PDFSelection *sel = [page selectionForLineAtPoint:point];
-        NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] : 
SKRectFromCenterAndSize(point, SKMakeSquareSize(10.0));
+        NSRect rect = [sel hasCharacters] ? [sel boundsForPage:page] : 
SKRectFromCenterAndSquareSize(point, 10.0);
         
         if (interactionMode != SKPresentationMode) {
             if (showBar) {
@@ -3142,9 +3142,9 @@
     // Hit-test for resize box.
     dragMask = 0;
     if (isLine) {
-        if (NSPointInRect(pagePoint, 
SKRectFromCenterAndSize(SKAddPoints(originalBounds.origin, [(PDFAnnotationLine 
*)activeAnnotation endPoint]), SKMakeSquareSize(8.0))))
+        if (NSPointInRect(pagePoint, 
SKRectFromCenterAndSquareSize(SKAddPoints(originalBounds.origin, 
[(PDFAnnotationLine *)activeAnnotation endPoint]), 8.0)))
             dragMask = SKMaxXEdgeMask;
-        else if (NSPointInRect(pagePoint, 
SKRectFromCenterAndSize(SKAddPoints(originalBounds.origin, [(PDFAnnotationLine 
*)activeAnnotation startPoint]), SKMakeSquareSize(8.0))))
+        else if (NSPointInRect(pagePoint, 
SKRectFromCenterAndSquareSize(SKAddPoints(originalBounds.origin, 
[(PDFAnnotationLine *)activeAnnotation startPoint]), 8.0)))
             dragMask = SKMinXEdgeMask;
     }  else if ([activeAnnotation isResizable]) {
         if (NSWidth(originalBounds) < 2.0) {

Modified: trunk/SKRemoteStateWindow.m
===================================================================
--- trunk/SKRemoteStateWindow.m 2011-05-16 11:24:49 UTC (rev 7241)
+++ trunk/SKRemoteStateWindow.m 2011-05-16 13:14:09 UTC (rev 7242)
@@ -62,7 +62,7 @@
 }
 
 - (id)init {
-    NSRect contentRect = SKRectFromCenterAndSize(NSZeroPoint, 
SKMakeSquareSize(WINDOW_SIZE));
+    NSRect contentRect = SKRectFromCenterAndSquareSize(NSZeroPoint, 
WINDOW_SIZE);
     self = [super initWithContentRect:contentRect];
     if (self) {
         [self setIgnoresMouseEvents:YES];


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

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to