Revision: 3061
http://skim-app.svn.sourceforge.net/skim-app/?rev=3061&view=rev
Author: hofman
Date: 2007-10-23 09:14:09 -0700 (Tue, 23 Oct 2007)
Log Message:
-----------
Rotate preview tooltips for rotated pages.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKPDFHoverWindow.m
trunk/SKPDFView.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/NSAffineTransform_SKExtensions.h
trunk/NSAffineTransform_SKExtensions.m
Added: trunk/NSAffineTransform_SKExtensions.h
===================================================================
--- trunk/NSAffineTransform_SKExtensions.h (rev 0)
+++ trunk/NSAffineTransform_SKExtensions.h 2007-10-23 16:14:09 UTC (rev
3061)
@@ -0,0 +1,44 @@
+//
+// NSAffineTransform_SKExtensions.h
+// Skim
+//
+// Created by Christiaan Hofman on 10/23/07.
+/*
+ This software is Copyright (c) 2007
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] NSAffineTransform (SKExtensions)
+- (NSRect)transformRect:(NSRect)aRect;
[EMAIL PROTECTED]
Added: trunk/NSAffineTransform_SKExtensions.m
===================================================================
--- trunk/NSAffineTransform_SKExtensions.m (rev 0)
+++ trunk/NSAffineTransform_SKExtensions.m 2007-10-23 16:14:09 UTC (rev
3061)
@@ -0,0 +1,68 @@
+//
+// NSAffineTransform_SKExtensions.m
+// Skim
+//
+// Created by Christiaan Hofman on 10/23/07.
+/*
+ This software is Copyright (c) 2007
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSAffineTransform_SKExtensions.h"
+#import "NSGeometry_SKExtensions.h"
+
+
[EMAIL PROTECTED] NSAffineTransform (SKExtensions)
+
+- (NSRect)transformRect:(NSRect)aRect {
+ NSPoint point, minPoint, maxPoint;
+
+ minPoint = maxPoint = [self transformPoint:SKBottomLeftPoint(aRect)];
+ point = [self transformPoint:SKBottomRightPoint(aRect)];
+ minPoint.x = fminf(minPoint.x, point.x);
+ minPoint.y = fminf(minPoint.y, point.y);
+ maxPoint.x = fmaxf(maxPoint.x, point.x);
+ maxPoint.y = fmaxf(maxPoint.y, point.y);
+ point = [self transformPoint:SKTopLeftPoint(aRect)];
+ minPoint.x = fminf(minPoint.x, point.x);
+ minPoint.y = fminf(minPoint.y, point.y);
+ maxPoint.x = fmaxf(maxPoint.x, point.x);
+ maxPoint.y = fmaxf(maxPoint.y, point.y);
+ point = [self transformPoint:SKTopRightPoint(aRect)];
+ minPoint.x = fminf(minPoint.x, point.x);
+ minPoint.y = fminf(minPoint.y, point.y);
+ maxPoint.x = fmaxf(maxPoint.x, point.x);
+ maxPoint.y = fmaxf(maxPoint.y, point.y);
+
+ return SKIntegralRectFromPoints(minPoint, maxPoint);
+}
+
[EMAIL PROTECTED]
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2007-10-23 10:05:57 UTC (rev 3060)
+++ trunk/SKMainWindowController.m 2007-10-23 16:14:09 UTC (rev 3061)
@@ -175,6 +175,8 @@
- (void)goToFindResults:(NSArray *)findResults;
+- (void)showHoverWindowForDestination:(PDFDestination *)dest;
+
- (void)updateNoteFilterPredicate;
- (void)replaceSideView:(NSView *)oldView withView:(NSView *)newView
animate:(BOOL)animate;
@@ -2831,6 +2833,31 @@
[wc showWindow:self];
}
+- (void)showHoverWindowForDestination:(PDFDestination *)dest {
+ PDFAnnotationLink *link = [[[PDFAnnotationLink alloc]
initWithBounds:NSZeroRect] autorelease];
+ NSPoint point = [dest point];
+ switch ([[dest page] rotation]) {
+ case 0:
+ point.x -= 50.0;
+ point.y += 20.0;
+ break;
+ case 90:
+ point.x -= 20.0;
+ point.y -= 50.0;
+ break;
+ case 180:
+ point.x += 50.0;
+ point.y -= 20.0;
+ break;
+ case 270:
+ point.x += 20.0;
+ point.y += 50.0;
+ break;
+ }
+ [link setDestination:[[[PDFDestination alloc] initWithPage:[dest page]
atPoint:point] autorelease]];
+ [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:link
atPoint:NSZeroPoint];
+}
+
#pragma mark Bookmarks
- (void)bookmarkSheetDidEnd:(SKBookmarkSheetController *)controller
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
@@ -3540,13 +3567,7 @@
- (void)outlineView:(NSOutlineView *)ov mouseEnteredTableColumn:(NSTableColumn
*)aTableColumn item:(id)item {
if ([ov isEqual:outlineView]) {
- PDFAnnotationLink *link = [[[PDFAnnotationLink alloc]
initWithBounds:NSZeroRect] autorelease];
- PDFDestination *dest = [item destination];
- NSPoint point = [dest point];
- point.x -= 50.0;
- point.y += 20.0;
- [link setDestination:[[[PDFDestination alloc] initWithPage:[dest page]
atPoint:point] autorelease]];
- [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:link
atPoint:NSZeroPoint];
+ [self showHoverWindowForDestination:[item destination]];
}
}
@@ -3773,13 +3794,8 @@
- (void)tableView:(NSTableView *)tv mouseEnteredTableColumn:(NSTableColumn
*)aTableColumn row:(int)row {
if ([tv isEqual:findTableView]) {
- PDFAnnotationLink *link = [[[PDFAnnotationLink alloc]
initWithBounds:NSZeroRect] autorelease];
PDFDestination *dest = [[[findArrayController arrangedObjects]
objectAtIndex:row] destination];
- NSPoint point = [dest point];
- point.x -= 50.0;
- point.y += 20.0;
- [link setDestination:[[[PDFDestination alloc] initWithPage:[dest page]
atPoint:point] autorelease]];
- [[SKPDFHoverWindow sharedHoverWindow] showForAnnotation:link
atPoint:NSZeroPoint];
+ [self showHoverWindowForDestination:dest];
}
}
Modified: trunk/SKPDFHoverWindow.m
===================================================================
--- trunk/SKPDFHoverWindow.m 2007-10-23 10:05:57 UTC (rev 3060)
+++ trunk/SKPDFHoverWindow.m 2007-10-23 16:14:09 UTC (rev 3061)
@@ -42,6 +42,7 @@
#import "NSBezierPath_BDSKExtensions.h"
#import "NSParagraphStyle_SKExtensions.h"
#import "NSGeometry_SKExtensions.h"
+#import "NSAffineTransform_SKExtensions.h"
#define WINDOW_OFFSET 20.0
#define TEXT_MARGIN_X 2.0
@@ -203,18 +204,36 @@
if (page) {
- NSImage *pageImage = [page image];
+ NSImage *pageImage = [page thumbnailWithSize:0.0
forBox:kPDFDisplayBoxCropBox shadowBlurRadius:0.0 shadowOffset:NSZeroSize
readingBarRect:NSZeroRect];
NSRect pageImageRect = {NSZeroPoint, [pageImage size]};
NSRect bounds = [page boundsForBox:kPDFDisplayBoxCropBox];
NSRect sourceRect = contentRect;
+ PDFSelection *selection = [page selectionForRect:bounds];
+ NSAffineTransform *transform = [NSAffineTransform transform];
- sourceRect.origin = [dest point];
- sourceRect.origin.x -= NSMinX(bounds);
- sourceRect.origin.y -= NSMinY(bounds) + NSHeight(sourceRect);
+ [transform rotateByDegrees:-[page rotation]];
+ switch ([page rotation]) {
+ case 0:
+ [transform translateXBy:-NSMinX(bounds)
yBy:-NSMinY(bounds)];
+ break;
+ case 90:
+ [transform translateXBy:-NSMaxX(bounds)
yBy:-NSMinY(bounds)];
+ break;
+ case 180:
+ [transform translateXBy:-NSMaxX(bounds)
yBy:-NSMaxY(bounds)];
+ break;
+ case 270:
+ [transform translateXBy:-NSMinX(bounds)
yBy:-NSMaxY(bounds)];
+ break;
+ }
- PDFSelection *selection = [page selectionForRect:bounds];
+ bounds = [transform transformRect:bounds];
+
+ sourceRect.origin = [transform transformPoint:[dest point]];
+ sourceRect.origin.y -= NSHeight(sourceRect);
+
if ([selection string]) {
- NSRect selBounds = [selection boundsForPage:page];
+ NSRect selBounds = [transform transformRect:[selection
boundsForPage:page]];
float top = ceilf(fmaxf(NSMaxY(selBounds), NSMinX(selBounds) +
NSHeight(sourceRect)));
float left = floorf(fminf(NSMinX(selBounds), NSMaxX(bounds) -
NSWidth(sourceRect)));
if (top < NSMaxY(sourceRect))
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2007-10-23 10:05:57 UTC (rev 3060)
+++ trunk/SKPDFView.m 2007-10-23 16:14:09 UTC (rev 3061)
@@ -57,6 +57,7 @@
#import "NSGeometry_SKExtensions.h"
#import "SKTypeSelectHelper.h"
#import "OBUtilities.h"
+#import "NSAffineTransform_SKExtensions.h"
NSString *SKPDFViewToolModeChangedNotification =
@"SKPDFViewToolModeChangedNotification";
NSString *SKPDFViewAnnotationModeChangedNotification =
@"SKPDFViewAnnotationModeChangedNotification";
@@ -702,16 +703,7 @@
break;
}
[transform rotateByDegrees:-[page rotation]];
- targetRect.origin = [transform transformPoint:targetRect.origin];
- targetRect.size = [transform transformSize:targetRect.size];
- if (NSWidth(targetRect) < 0.0) {
- targetRect.origin.x += NSWidth(targetRect);
- targetRect.size.width *= -1.0;
- }
- if (NSHeight(targetRect) < 0.0) {
- targetRect.origin.y += NSHeight(targetRect);
- targetRect.size.height *= -1.0;
- }
+ targetRect = [transform transformRect:targetRect];
}
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[page
dataRepresentation]];
@@ -1604,16 +1596,7 @@
break;
}
[transform rotateByDegrees:-[page rotation]];
- targetRect.origin = [transform
transformPoint:targetRect.origin];
- targetRect.size = [transform transformSize:targetRect.size];
- if (NSWidth(targetRect) < 0.0) {
- targetRect.origin.x += NSWidth(targetRect);
- targetRect.size.width *= -1.0;
- }
- if (NSHeight(targetRect) < 0.0) {
- targetRect.origin.y += NSHeight(targetRect);
- targetRect.size.height *= -1.0;
- }
+ targetRect = [transform transformRect:targetRect];
}
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[page
dataRepresentation]];
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2007-10-23 10:05:57 UTC (rev
3060)
+++ trunk/Skim.xcodeproj/project.pbxproj 2007-10-23 16:14:09 UTC (rev
3061)
@@ -187,6 +187,8 @@
CEBD51D70C9BF68100FBF6A4 /* ToolbarNewFolder.tiff in Resources
*/ = {isa = PBXBuildFile; fileRef = CEBD51D50C9BF68100FBF6A4 /*
ToolbarNewFolder.tiff */; };
CEBD51D80C9BF68100FBF6A4 /* ToolbarNewSeparator.tiff in
Resources */ = {isa = PBXBuildFile; fileRef = CEBD51D60C9BF68100FBF6A4 /*
ToolbarNewSeparator.tiff */; };
CEBD52ED0C9C0AE500FBF6A4 /* SKBookmark.m in Sources */ = {isa =
PBXBuildFile; fileRef = CEBD52EB0C9C0AE500FBF6A4 /* SKBookmark.m */; };
+ CEBF85E10CCE2DE70057A050 /* NSAffineTransform_SKExtensions.h in
CopyFiles */ = {isa = PBXBuildFile; fileRef = CEBF85DF0CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.h */; };
+ CEBF85E20CCE2DE70057A050 /* NSAffineTransform_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEBF85E00CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.m */; };
CECDC4FF0C5966A80026AAEC /* NSImage_SKExtensions.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CECDC4FD0C5966A80026AAEC /*
NSImage_SKExtensions.m */; };
CECDD2990C5B68580026AAEC /* SKCenteredTextFieldCell.m in
Sources */ = {isa = PBXBuildFile; fileRef = CECDD2970C5B68580026AAEC /*
SKCenteredTextFieldCell.m */; };
CECDDBAE0C5BB9600026AAEC /* SKFindTableView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CECDDBAC0C5BB95F0026AAEC /* SKFindTableView.m
*/; };
@@ -285,6 +287,7 @@
CE2BD8450BD4135600A5F4DB /* Sparkle.framework
in CopyFiles */,
CEAE39060CA43E7300849B0F /* SKSheetController.h
in CopyFiles */,
CE8978CD0CBFC70B00EA2D98 /* SKTag.h in
CopyFiles */,
+ CEBF85E10CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -622,6 +625,8 @@
CEBD51D60C9BF68100FBF6A4 /* ToolbarNewSeparator.tiff */ = {isa
= PBXFileReference; lastKnownFileType = image.tiff; name =
ToolbarNewSeparator.tiff; path = Images/ToolbarNewSeparator.tiff; sourceTree =
"<group>"; };
CEBD52EA0C9C0AE500FBF6A4 /* SKBookmark.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKBookmark.h; sourceTree = "<group>"; };
CEBD52EB0C9C0AE500FBF6A4 /* SKBookmark.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKBookmark.m; sourceTree = "<group>"; };
+ CEBF85DF0CCE2DE70057A050 /* NSAffineTransform_SKExtensions.h */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.h; path = NSAffineTransform_SKExtensions.h; sourceTree =
"<group>"; };
+ CEBF85E00CCE2DE70057A050 /* NSAffineTransform_SKExtensions.m */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSAffineTransform_SKExtensions.m; sourceTree =
"<group>"; };
CEC4C33C0CA90CA100299397 /* Spanish */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.nib; name = Spanish; path =
Spanish.lproj/BookmarkSheet.nib; sourceTree = "<group>"; };
CEC4C33D0CA90CA100299397 /* Spanish */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.nib; name = Spanish; path =
Spanish.lproj/BookmarksWindow.nib; sourceTree = "<group>"; };
CEC4C33E0CA90CA100299397 /* Spanish */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.nib; name = Spanish; path =
Spanish.lproj/ConversionProgressWindow.nib; sourceTree = "<group>"; };
@@ -886,6 +891,8 @@
children = (
CE4EC8810B7E6E920091F228 /*
CIImage_BDSKExtensions.h */,
CE4EC8820B7E6E920091F228 /*
CIImage_BDSKExtensions.m */,
+ CEBF85DF0CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.h */,
+ CEBF85E00CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.m */,
CE41B2A40C08CFA900E36EB7 /*
NSArray_SKExtensions.h */,
CE41B2A50C08CFA900E36EB7 /*
NSArray_SKExtensions.m */,
CE3A45510B7A04A4006B64D3 /*
NSBezierPath_BDSKExtensions.h */,
@@ -908,6 +915,8 @@
CE5487BB0B35A20A00F8AFB6 /*
NSFileManager_ExtendedAttributes.m */,
CEF839B00C77742A00A3AD51 /*
Files_SKExtensions.h */,
CEF839B10C77742A00A3AD51 /*
Files_SKExtensions.m */,
+ CE5BEA160C7C635400EBDCF7 /*
NSGeometry_SKExtensions.h */,
+ CE5BEA170C7C635400EBDCF7 /*
NSGeometry_SKExtensions.m */,
CECDC4FC0C5966A80026AAEC /*
NSImage_SKExtensions.h */,
CECDC4FD0C5966A80026AAEC /*
NSImage_SKExtensions.m */,
CE6C03EE0BEDF759007BF0B5 /*
NSParagraphStyle_SKExtensions.h */,
@@ -934,8 +943,6 @@
CE2DE50C0B85DC4000D0DA12 /*
PDFPage_SKExtensions.m */,
CE49726A0BDE8A7400D7F1D2 /*
PDFSelection_SKExtensions.h */,
CE49726B0BDE8A7400D7F1D2 /*
PDFSelection_SKExtensions.m */,
- CE5BEA160C7C635400EBDCF7 /*
NSGeometry_SKExtensions.h */,
- CE5BEA170C7C635400EBDCF7 /*
NSGeometry_SKExtensions.m */,
);
name = Categories;
sourceTree = "<group>";
@@ -1641,6 +1648,7 @@
CEAE1C480CA1877F00849B0F /*
SKSecondaryPDFView.m in Sources */,
CEAE39070CA43E7300849B0F /* SKSheetController.m
in Sources */,
CE8978CE0CBFC70B00EA2D98 /* SKTag.m in Sources
*/,
+ CEBF85E20CCE2DE70057A050 /*
NSAffineTransform_SKExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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