Revision: 2808
http://skim-app.svn.sourceforge.net/skim-app/?rev=2808&view=rev
Author: hofman
Date: 2007-09-02 12:08:57 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
Add hidden defaults for default size of new notes.
Modified Paths:
--------------
trunk/InitialUserDefaults.plist
trunk/SKPDFAnnotationNote.m
trunk/SKPDFView.m
trunk/SKStringConstants.h
trunk/SKStringConstants.m
Modified: trunk/InitialUserDefaults.plist
===================================================================
--- trunk/InitialUserDefaults.plist 2007-09-02 18:47:52 UTC (rev 2807)
+++ trunk/InitialUserDefaults.plist 2007-09-02 19:08:57 UTC (rev 2808)
@@ -201,6 +201,10 @@
BAt0eXBlZHN0cmVhbYED6IQBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWE
AWMBhARmZmZmAQABAYY=
</data>
+ <key>SKDefaultNoteWidth</key>
+ <real>128.0</real>
+ <key>SKDefaultNoteHeight</key>
+ <real>64.0</real>
</array>
<key>SKActivateFullScreenNavigationAtBottom</key>
<false/>
Modified: trunk/SKPDFAnnotationNote.m
===================================================================
--- trunk/SKPDFAnnotationNote.m 2007-09-02 18:47:52 UTC (rev 2807)
+++ trunk/SKPDFAnnotationNote.m 2007-09-02 19:08:57 UTC (rev 2808)
@@ -380,6 +380,8 @@
NSScriptCommand *currentCommand = [NSScriptCommand currentCommand];
if ([currentCommand isKindOfClass:[NSCreateCommand class]]) {
unsigned long classCode = [[(NSCreateCommand *)currentCommand
createClassDescription] appleEventCode];
+ float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
+ float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
if (classCode == 'Note') {
@@ -411,15 +413,15 @@
}
}
} else if (type == SKASTextNote) {
- self = [[SKPDFAnnotationFreeText alloc]
initWithBounds:NSMakeRect(100.0, 100.0, 64.0, 64.0)];
+ self = [[SKPDFAnnotationFreeText alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
} else if (type == SKASAnchoredNote) {
self = [[SKPDFAnnotationNote alloc]
initWithBounds:NSMakeRect(100.0, 100.0, 16.0, 16.0)];
} else if (type == SKASCircleNote) {
- self = [[SKPDFAnnotationCircle alloc]
initWithBounds:NSMakeRect(100.0, 100.0, 64.0, 64.0)];
+ self = [[SKPDFAnnotationCircle alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
} else if (type == SKASSquareNote) {
- self = [[SKPDFAnnotationSquare alloc]
initWithBounds:NSMakeRect(100.0, 100.0, 64.0, 64.0)];
+ self = [[SKPDFAnnotationSquare alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
} else if (type == SKASLineNote) {
- self = [[SKPDFAnnotationLine alloc]
initWithBounds:NSMakeRect(100.0, 100.0, 16.0, 16.0)];
+ self = [[SKPDFAnnotationLine alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
}
}
}
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2007-09-02 18:47:52 UTC (rev 2807)
+++ trunk/SKPDFView.m 2007-09-02 19:08:57 UTC (rev 2808)
@@ -70,6 +70,8 @@
NSString *SKSkimNotePboardType = @"SKSkimNotePboardType";
+#define ANCHORED_NOTE_SIZE SKMakeSquareSize(16.0)
+
static CGMutablePathRef SKCGCreatePathWithRoundRectInRect(CGRect rect, float
radius);
static void SKCGContextDrawGrabHandle(CGContextRef context, CGPoint point,
float radius);
@@ -823,7 +825,9 @@
// Convert to "page space".
center = SKIntegralPoint([self convertPoint: center toPage:
page]);
- NSSize defaultSize = isAlternate ? SKMakeSquareSize(16.0) : ([page
rotation] % 180 == 90) ? NSMakeSize(64.0, 128.0) : NSMakeSize(128.0, 64.0);
+ float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
+ float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
+ NSSize defaultSize = isAlternate ? ANCHORED_NOTE_SIZE : ([page
rotation] % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) :
NSMakeSize(defaultHeight, defaultWidth);
NSRect bounds = SKRectFromCenterAndSize(center, defaultSize);
bounds = SKConstrainRect(bounds, [page boundsForBox:[self
displayBox]]);
@@ -1689,10 +1693,12 @@
if (annotationType == SKCircleNote || annotationType == SKSquareNote)
bounds = NSInsetRect(bounds, -5.0, -5.0);
} else {
- NSSize defaultSize = (annotationType == SKAnchoredNote) ?
SKMakeSquareSize(16.0) : ([page rotation] % 180 == 90) ? NSMakeSize(64.0,
128.0) : NSMakeSize(128.0, 64.0);
+ float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
+ float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
+ NSSize defaultSize = (annotationType == SKAnchoredNote) ?
ANCHORED_NOTE_SIZE : ([page rotation] % 180 == 0) ? NSMakeSize(defaultWidth,
defaultHeight) : NSMakeSize(defaultHeight, defaultWidth);
point = [self convertPoint:point toPage:page];
- bounds = NSMakeRect(point.x - 0.5 * defaultSize.width, point.y - 0.5 *
defaultSize.height, defaultSize.width, defaultSize.height);
+ bounds = SKRectFromCenterAndSize(point, defaultSize);
}
// Make sure it fits in the page
@@ -1721,7 +1727,7 @@
NSBeep();
return;
} else {
- 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];
@@ -1734,11 +1740,13 @@
center = SKCenterPoint(viewFrame);
page = [self pageForPoint: center nearest: YES];
}
+
+ float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
+ float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
+ NSSize defaultSize = (annotationType == SKAnchoredNote) ?
ANCHORED_NOTE_SIZE : ([page rotation] % 180 == 0) ? NSMakeSize(defaultWidth,
defaultHeight) : NSMakeSize(defaultHeight, defaultWidth);
// Convert to "page space".
center = SKIntegralPoint([self convertPoint: center toPage:
page]);
- if ([page rotation] % 180 == 90)
- defaultSize = NSMakeSize(defaultSize.height, defaultSize.width);
bounds = SKRectFromCenterAndSize(center, defaultSize);
// Make sure it fits in the page
@@ -2759,8 +2767,8 @@
NSPointInRect(pagePoint, [page boundsForBox:[self
displayBox]])) {
// add a new annotation immediately, unless this is just a click
if (annotationMode == SKAnchoredNote || NSLeftMouseDragged ==
[[NSApp nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask)
untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:NO] type])
{
- float width = annotationMode == SKAnchoredNote ? 16.0 :
annotationMode == SKLineNote ? 4.0 : 8.0;
- NSRect bounds = NSMakeRect(pagePoint.x - floorf(0.5 * width),
pagePoint.y - floorf(0.5 * width), width, width);
+ NSSize size = annotationMode == SKAnchoredNote ?
ANCHORED_NOTE_SIZE : annotationMode == SKLineNote ? SKMakeSquareSize(4.0) :
SKMakeSquareSize(8.0);
+ NSRect bounds = SKRectFromCenterAndSize(pagePoint, size);
[[self undoManager] beginUndoGrouping];
didBeginUndoGrouping = YES;
[self addAnnotationWithType:annotationMode contents:nil
page:page bounds:bounds];
Modified: trunk/SKStringConstants.h
===================================================================
--- trunk/SKStringConstants.h 2007-09-02 18:47:52 UTC (rev 2807)
+++ trunk/SKStringConstants.h 2007-09-02 19:08:57 UTC (rev 2808)
@@ -91,6 +91,8 @@
extern NSString *SKLineNoteDashPatternKey;
extern NSString *SKLineNoteStartLineStyleKey;
extern NSString *SKLineNoteEndLineStyleKey;
+extern NSString *SKDefaultNoteWidthKey;
+extern NSString *SKDefaultNoteHeightKey;
extern NSString *SKSwatchColorsKey;
extern NSString *SKDefaultPDFDisplaySettingsKey;
extern NSString *SKDefaultFullScreenPDFDisplaySettingsKey;
Modified: trunk/SKStringConstants.m
===================================================================
--- trunk/SKStringConstants.m 2007-09-02 18:47:52 UTC (rev 2807)
+++ trunk/SKStringConstants.m 2007-09-02 19:08:57 UTC (rev 2808)
@@ -92,6 +92,8 @@
NSString *SKLineNoteLineStyleKey = @"SKLineNoteLineStyle";
NSString *SKLineNoteStartLineStyleKey = @"SKLineNoteStartLineStyle";
NSString *SKLineNoteEndLineStyleKey = @"SKLineNoteEndLineStyle";
+NSString *SKDefaultNoteWidthKey = @"SKDefaultNoteWidth";
+NSString *SKDefaultNoteHeightKey = @"SKDefaultNoteHeight";
NSString *SKSwatchColorsKey = @"SKSwatchColors";
NSString *SKDefaultPDFDisplaySettingsKey = @"SKDefaultPDFDisplaySettings";
NSString *SKDefaultFullScreenPDFDisplaySettingsKey =
@"SKDefaultFullScreenPDFDisplaySettings";
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