Revision: 2734
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2734&view=rev
Author:   hofman
Date:     2007-08-27 12:29:56 -0700 (Mon, 27 Aug 2007)

Log Message:
-----------
use some more geometry convenience methods.

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

Modified: trunk/NSGeometry_SKExtensions.h
===================================================================
--- trunk/NSGeometry_SKExtensions.h     2007-08-27 18:42:57 UTC (rev 2733)
+++ trunk/NSGeometry_SKExtensions.h     2007-08-27 19:29:56 UTC (rev 2734)
@@ -71,6 +71,10 @@
     return NSMakePoint(NSMidX(rect), NSMidY(rect));
 }
 
+static inline NSPoint SKMakeSquareSize(float width) {
+    return NSMakeSize(width, width);
+}
+
 static inline NSRect SKRectFromPoints(NSPoint aPoint, NSPoint bPoint) {
     NSRect rect;
     rect.origin.x = fmin(aPoint.x, bPoint.x);

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2007-08-27 18:42:57 UTC (rev 2733)
+++ trunk/SKPDFView.m   2007-08-27 19:29:56 UTC (rev 2734)
@@ -823,7 +823,7 @@
                // Convert to "page space".
                center = SKIntegralPoint([self convertPoint: center toPage: 
page]);
         
-        NSSize defaultSize = isAlternate ? NSMakeSize(16.0, 16.0) : ([page 
rotation] % 180 == 90) ? NSMakeSize(64.0, 128.0) : NSMakeSize(128.0, 64.0);
+        NSSize defaultSize = isAlternate ? SKMakeSquareSize(16.0) : ([page 
rotation] % 180 == 90) ? NSMakeSize(64.0, 128.0) : NSMakeSize(128.0, 64.0);
         NSRect bounds = SKRectFromCenterAndSize(center, defaultSize);
         
         bounds = SKConstrainRect(bounds, [page boundsForBox:[self 
displayBox]]);
@@ -1678,7 +1678,7 @@
         if (annotationType == SKCircleNote || annotationType == SKSquareNote)
             bounds = NSInsetRect(bounds, -5.0, -5.0);
     } else {
-        NSSize defaultSize = (annotationType == SKAnchoredNote) ? 
NSMakeSize(16.0, 16.0) : ([page rotation] % 180 == 90) ? NSMakeSize(64.0, 
128.0) : NSMakeSize(128.0, 64.0);
+        NSSize defaultSize = (annotationType == SKAnchoredNote) ? 
SKMakeSquareSize(16.0) : ([page rotation] % 180 == 90) ? NSMakeSize(64.0, 
128.0) : NSMakeSize(128.0, 64.0);
         
         point = [self convertPoint:point toPage:page];
         bounds = NSMakeRect(point.x - 0.5 * defaultSize.width, point.y - 0.5 * 
defaultSize.height, defaultSize.width, defaultSize.height);
@@ -1710,7 +1710,7 @@
         NSBeep();
         return;
     } else {
-        NSSize defaultSize = (annotationType == SKAnchoredNote) ? 
NSMakeSize(16.0, 16.0) : NSMakeSize(128.0, 64.0);
+        NSSize defaultSize = (annotationType == SKAnchoredNote) ? 
SKMakeSquareSize(16.0) : NSMakeSize(128.0, 64.0);
                // First try the current mouse position
         NSPoint center = [self convertPoint:[[self window] 
mouseLocationOutsideOfEventStream] fromView:nil];
         
@@ -1728,7 +1728,7 @@
                center = SKIntegralPoint([self convertPoint: center toPage: 
page]);
         if ([page rotation] % 180 == 90)
             defaultSize = NSMakeSize(defaultSize.height, defaultSize.width);
-        bounds = NSMakeRect(center.x - 0.5 * defaultSize.width, center.y - 0.5 
* defaultSize.height, defaultSize.width, defaultSize.height);
+        bounds = SKRectfromCenterAndSize(center, defaultSize);
         
         // Make sure it fits in the page
         bounds = SKConstrainRect(bounds, [page boundsForBox:[self 
displayBox]]);
@@ -2046,7 +2046,7 @@
     if (pageIndex < [[self document] pageCount]) {
         PDFPage *page = [[self document] pageAtIndex:pageIndex];
         PDFSelection *sel = [page selectionForLineAtPoint:point];
-        NSRect rect = sel ? [sel boundsForPage:page] : NSMakeRect(point.x - 
5.0, point.y - 5.0, 10.0, 10.0);
+        NSRect rect = sel ? [sel boundsForPage:page] : 
SKRectFromCenterAndSize(point, SKMakeSquareSize(10.0));
         
         if (sel)
             [self setCurrentSelection:sel];
@@ -2207,7 +2207,7 @@
 @implementation SKPDFView (Private)
 
 - (NSRect)resizeThumbForRect:(NSRect)rect rotation:(int)rotation {
-    NSSize size = NSMakeSize(8.0, 8.0);
+    NSSize size = SKMakeSquareSize(8.0);
        NSRect thumb = rect;
     
     thumb.size = size;
@@ -2232,7 +2232,7 @@
 }
 
 - (NSRect)resizeThumbForRect:(NSRect)rect point:(NSPoint)point {
-    NSSize size = NSMakeSize(8.0, 8.0);
+    NSSize size = SKMakeSquareSize(8.0);
        NSRect thumb = SKRectFromCenterAndSize(SKAddPoints(rect.origin, point), 
size);
     
     thumb.origin.x =  point.x > 0.5 * NSWidth(rect) ? floorf(NSMinX(thumb)) : 
ceilf(NSMinX(thumb));


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to