Revision: 4404
http://skim-app.svn.sourceforge.net/skim-app/?rev=4404&view=rev
Author: hofman
Date: 2008-08-14 16:31:01 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
Do the right thing when displaying a note window for a non-anchored note.
Remove irrelevant views and resize window. Still won't to able to edit those
notes though.
Modified Paths:
--------------
trunk/PDFAnnotation_SKExtensions.h
trunk/PDFAnnotation_SKExtensions.m
trunk/SKMainWindowController_UI.m
trunk/SKNoteWindowController.m
trunk/SKPDFView.m
Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h 2008-08-14 12:44:50 UTC (rev 4403)
+++ trunk/PDFAnnotation_SKExtensions.h 2008-08-14 16:31:01 UTC (rev 4404)
@@ -81,6 +81,7 @@
- (NSArray *)dashPattern;
- (void)setDashPattern:(NSArray *)pattern;
+- (PDFTextAnnotationIconType)iconType;
- (NSImage *)image;
- (NSAttributedString *)text;
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2008-08-14 12:44:50 UTC (rev 4403)
+++ trunk/PDFAnnotation_SKExtensions.m 2008-08-14 16:31:01 UTC (rev 4404)
@@ -189,6 +189,8 @@
[border release];
}
+- (PDFTextAnnotationIconType)iconType { return kPDFTextAnnotationIconNote; }
+
- (NSImage *)image { return nil; }
- (NSAttributedString *)text { return nil; }
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2008-08-14 12:44:50 UTC (rev 4403)
+++ trunk/SKMainWindowController_UI.m 2008-08-14 16:31:01 UTC (rev 4404)
@@ -1078,7 +1078,7 @@
return [self isPresentation] == NO && ([pdfView toolMode] ==
SKTextToolMode || [pdfView toolMode] == SKNoteToolMode) && [[[pdfView
currentSelection] pages] count] && [pdfView hideNotes] == NO;
} else if (action == @selector(editNote:)) {
PDFAnnotation *annotation = [pdfView activeAnnotation];
- return [self isPresentation] == NO && [annotation isSkimNote] &&
([[annotation type] isEqualToString:SKNFreeTextString] || [[annotation type]
isEqualToString:SKNNoteString]);
+ return [self isPresentation] == NO && [annotation isSkimNote] &&
([[annotation type] isEditable]);
} else if (action == @selector(toggleHideNotes:)) {
if ([pdfView hideNotes])
[menuItem setTitle:NSLocalizedString(@"Show Notes", @"Menu item
title")];
Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m 2008-08-14 12:44:50 UTC (rev 4403)
+++ trunk/SKNoteWindowController.m 2008-08-14 16:31:01 UTC (rev 4404)
@@ -52,6 +52,7 @@
#import "PDFPage_SKExtensions.h"
static NSString *SKNoteWindowFrameAutosaveName = @"SKNoteWindow";
+static NSString *SKGenericNoteWindowFrameAutosaveName = @"SKGenericNoteWindow";
static NSString *SKKeepNoteWindowsOnTopKey = @"SKKeepNoteWindowsOnTop";
@@ -102,7 +103,8 @@
[note addObserver:self forKeyPath:SKNPDFAnnotationPageKey options:0
context:SKNoteWindowPageObservationContext];
[note addObserver:self forKeyPath:SKNPDFAnnotationBoundsKey options:0
context:SKNoteWindowBoundsObservationContext];
- [[NSUserDefaultsController sharedUserDefaultsController]
addObserver:self forKeys:[NSArray arrayWithObjects:SKAnchoredNoteFontNameKey,
SKAnchoredNoteFontSizeKey, nil] context:SKNoteWindowDefaultsObservationContext];
+ if ([self isNoteType])
+ [[NSUserDefaultsController sharedUserDefaultsController]
addObserver:self forKeys:[NSArray arrayWithObjects:SKAnchoredNoteFontNameKey,
SKAnchoredNoteFontSizeKey, nil] context:SKNoteWindowDefaultsObservationContext];
}
return self;
}
@@ -110,7 +112,8 @@
- (void)dealloc {
[note removeObserver:self forKeyPath:SKNPDFAnnotationPageKey];
[note removeObserver:self forKeyPath:SKNPDFAnnotationBoundsKey];
- [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKeys:[NSArray
arrayWithObjects:SKAnchoredNoteFontNameKey, SKAnchoredNoteFontSizeKey, nil]];
+ if ([self isNoteType])
+ [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKeys:[NSArray
arrayWithObjects:SKAnchoredNoteFontNameKey, SKAnchoredNoteFontSizeKey, nil]];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[textViewUndoManager release];
[note release];
@@ -131,26 +134,74 @@
[[self window] setLevel:keepOnTop || forceOnTop ? NSFloatingWindowLevel :
NSNormalWindowLevel];
[[self window] setHidesOnDeactivate:keepOnTop || forceOnTop];
- if ([self isNoteType] && [[textView string] length] == 0) {
- NSString *fontName = [[NSUserDefaults standardUserDefaults]
stringForKey:SKAnchoredNoteFontNameKey];
- float fontSize = [[NSUserDefaults standardUserDefaults]
floatForKey:SKAnchoredNoteFontSizeKey];
- NSFont *font = fontName ? [NSFont fontWithName:fontName size:fontSize]
: nil;
- if (font)
- [textView setFont:font];
+ if ([self isNoteType]) {
+ if ([[textView string] length] == 0) {
+ NSString *fontName = [[NSUserDefaults standardUserDefaults]
stringForKey:SKAnchoredNoteFontNameKey];
+ float fontSize = [[NSUserDefaults standardUserDefaults]
floatForKey:SKAnchoredNoteFontSizeKey];
+ NSFont *font = fontName ? [NSFont fontWithName:fontName
size:fontSize] : nil;
+ if (font)
+ [textView setFont:font];
+ }
+
+ unsigned i, count = [iconTypePopUpButton numberOfItems];
+ for (i = 0; i < count; i++) {
+ NSMenuItem *item = [iconTypePopUpButton itemAtIndex:i];
+ [item setImage:noteIcons[[item tag]]];
+ }
+ } else {
+ NSView *gradientView = [imageView superview];
+ NSTextField *textField = nil;
+ NSTextField *promptField = nil;
+ NSEnumerator *viewEnum = [[gradientView subviews] objectEnumerator];
+ id view;
+
+ while (view = [viewEnum nextObject]) {
+ if ([view isKindOfClass:[NSTextField class]]) {
+ if ([view isEditable])
+ textField = view;
+ else
+ promptField = view;
+ }
+ }
+
+ [imageView unbind:@"value"];
+ [iconTypePopUpButton unbind:@"selectedTag"];
+ [textView unbind:@"attributedString"];
+ [textView unbind:@"editable"];
+
+ [[textView enclosingScrollView] removeFromSuperview];
+ [imageView removeFromSuperview];
+ [iconTypePopUpButton removeFromSuperview];
+ [promptField removeFromSuperview];
+
+ NSRect frame;
+
+ frame = [gradientView frame];
+ frame.size.height -= 32.0;
+ frame.origin.y += 32.0;
+ [gradientView setFrame:frame];
+
+ frame = [textField frame];
+ frame.size.width += 64.0;
+ [textField setFrame:frame];
+
+ NSSize minSize = [[self window] minSize];
+ NSSize maxSize = [[self window] maxSize];
+ frame = [[[self window] contentView] frame];
+ frame.size.height = NSHeight([statusBar frame]) +
NSHeight([gradientView frame]);
+ frame = [[self window] frameRectForContentRect:frame];
+ minSize.height = maxSize.height = NSHeight(frame);
+ [[self window] setMinSize:minSize];
+ [[self window] setMaxSize:maxSize];
+ [[self window] setFrame:frame display:NO];
}
- unsigned i, count = [iconTypePopUpButton numberOfItems];
- for (i = 0; i < count; i++) {
- NSMenuItem *item = [iconTypePopUpButton itemAtIndex:i];
- [item setImage:noteIcons[[item tag]]];
- }
-
[statusBar setLeftAction:@selector(statusBarClicked:)];
[statusBar setLeftTarget:self];
[self updateStatusMessage];
- [self setWindowFrameAutosaveNameOrCascade:SKNoteWindowFrameAutosaveName];
+ [self setWindowFrameAutosaveNameOrCascade:[self isNoteType] ?
SKNoteWindowFrameAutosaveName : SKGenericNoteWindowFrameAutosaveName];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleDocumentWillSaveNotification:)
name:SKPDFDocumentWillSaveNotification object:[self document]];
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-08-14 12:44:50 UTC (rev 4403)
+++ trunk/SKPDFView.m 2008-08-14 16:31:01 UTC (rev 4404)
@@ -2025,13 +2025,6 @@
[[NSWorkspace sharedWorkspace] openURL:[(PDFAnnotationLink
*)activeAnnotation URL]];
[self setActiveAnnotation:nil];
- } else if ([type isEqualToString:SKNNoteString]) {
-
- [[SKPDFHoverWindow sharedHoverWindow] orderOut:self];
-
- [[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewAnnotationDoubleClickedNotification object:self
- userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:activeAnnotation, SKPDFViewAnnotationKey, nil]];
-
} else if ([type isEqualToString:SKNFreeTextString]) {
NSRect editBounds = [activeAnnotation bounds];
@@ -2052,6 +2045,14 @@
[editField selectText:self];
[self setNeedsDisplayForAnnotation:activeAnnotation];
+
+ } else if ([activeAnnotation isEditable]) {
+
+ [[SKPDFHoverWindow sharedHoverWindow] orderOut:self];
+
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewAnnotationDoubleClickedNotification object:self
+ userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:activeAnnotation, SKPDFViewAnnotationKey, nil]];
+
}
}
@@ -2988,7 +2989,7 @@
if (newActiveAnnotation) {
- if ([theEvent clickCount] == 2 && ([[activeAnnotation type]
isEqualToString:SKNFreeTextString] || [[activeAnnotation type]
isEqualToString:SKNNoteString])) {
+ if ([theEvent clickCount] == 2 && [activeAnnotation isSkimNote]) {
[self editActiveAnnotation:self];
} else {
// Old (current) annotation location.
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit