Revision: 14563
http://sourceforge.net/p/skim-app/code/14563
Author: hofman
Date: 2024-10-21 17:07:53 +0000 (Mon, 21 Oct 2024)
Log Message:
-----------
Support for drawsImage flag of nnote annotation. Add it as an extra icon type
option in the popup. When the flag is set, allow resizing the note, reset the
size when it is unset. Use size ratio of the image when resizing while holding
the Option key.
Modified Paths:
--------------
trunk/Base.lproj/NoteWindow.xib
trunk/PDFAnnotation_SKExtensions.h
trunk/PDFAnnotation_SKExtensions.m
trunk/SKMainWindowController.m
trunk/SKNPDFAnnotationNote_SKExtensions.h
trunk/SKNPDFAnnotationNote_SKExtensions.m
trunk/SKNoteWindowController.m
trunk/SKPDFView.m
trunk/SKStringConstants.h
trunk/SKStringConstants.m
trunk/de.lproj/NoteWindow.strings
trunk/en.lproj/NoteWindow.strings
trunk/es.lproj/NoteWindow.strings
trunk/fr.lproj/NoteWindow.strings
trunk/it.lproj/NoteWindow.strings
trunk/ja.lproj/NoteWindow.strings
trunk/nl.lproj/NoteWindow.strings
trunk/pl.lproj/NoteWindow.strings
trunk/ru.lproj/NoteWindow.strings
trunk/zh_CN.lproj/NoteWindow.strings
trunk/zh_TW.lproj/NoteWindow.strings
Modified: trunk/Base.lproj/NoteWindow.xib
===================================================================
--- trunk/Base.lproj/NoteWindow.xib 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/Base.lproj/NoteWindow.xib 2024-10-21 17:07:53 UTC (rev 14563)
@@ -110,14 +110,15 @@
<menuItem title="New Paragraph"
tag="4" id="108"/>
<menuItem title="Paragraph"
tag="5" id="109"/>
<menuItem title="Insert" tag="6"
id="110"/>
+ <menuItem title="Image" tag="7"
id="Rit-8B-W2V"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<accessibilityConnection property="title"
destination="106" id="130"/>
- <binding destination="142"
name="selectedTag" keyPath="selection.iconType" id="208">
+ <binding destination="142"
name="selectedTag" keyPath="selection.extendedIconType" id="8f4-64-pf9">
<dictionary key="options">
- <integer
key="NSConditionallySetsEnabled" value="0"/>
+ <bool
key="NSConditionallySetsEnabled" value="NO"/>
</dictionary>
</binding>
<outlet property="nextKeyView"
destination="42" id="263"/>
Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/PDFAnnotation_SKExtensions.h 2024-10-21 17:07:53 UTC (rev 14563)
@@ -89,6 +89,8 @@
@property (nonatomic, nullable, readonly) NSImage *image;
@property (nonatomic, nullable, readonly) NSAttributedString *text;
+@property (nonatomic, readonly) PDFTextAnnotationIconType extendedIconType;
+
@property (nonatomic, readonly) BOOL hasNoteText;
@property (nonatomic, nullable, readonly) SKNoteText *noteText;
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/PDFAnnotation_SKExtensions.m 2024-10-21 17:07:53 UTC (rev 14563)
@@ -399,6 +399,8 @@
- (NSAttributedString *)text { return nil; }
+- (PDFTextAnnotationIconType)extendedIconType { return [self iconType]; }
+
- (BOOL)hasNoteText { return NO; }
- (SKNoteText *)noteText { return nil; }
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/SKMainWindowController.m 2024-10-21 17:07:53 UTC (rev 14563)
@@ -2695,7 +2695,7 @@
return;
// Update the UI, we should always do that unless the value did
not really change or we're just changing the mod date or user name
- if ([keyPath isEqualToString:SKNPDFAnnotationModificationDateKey]
== NO && [keyPath isEqualToString:SKNPDFAnnotationUserNameKey] == NO && ([[note
type] isEqualToString:SKNNoteString] == NO || [keyPath
isEqualToString:SKNPDFAnnotationBoundsKey] || [keyPath
isEqualToString:SKNPDFAnnotationColorKey] || [keyPath
isEqualToString:SKNPDFAnnotationIconTypeKey])) {
+ if ([keyPath isEqualToString:SKNPDFAnnotationModificationDateKey]
== NO && [keyPath isEqualToString:SKNPDFAnnotationUserNameKey] == NO && ([[note
type] isEqualToString:SKNNoteString] == NO || [keyPath
isEqualToString:SKNPDFAnnotationBoundsKey] || [keyPath
isEqualToString:SKNPDFAnnotationColorKey] || [keyPath
isEqualToString:SKNPDFAnnotationIconTypeKey] || [keyPath
isEqualToString:SKNPDFAnnotationImageKey] || [keyPath
isEqualToString:SKNPDFAnnotationDrawsImageKey])) {
PDFPage *page = [note page];
NSRect oldRect = NSZeroRect;
if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey] &&
[oldValue isEqual:[NSNull null]] == NO) {
Modified: trunk/SKNPDFAnnotationNote_SKExtensions.h
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.h 2024-10-21 17:03:31 UTC (rev
14562)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.h 2024-10-21 17:07:53 UTC (rev
14563)
@@ -44,8 +44,13 @@
extern NSString *SKPDFAnnotationRichTextKey;
+enum {
+ kSKNPDFTextAnnotationIconImage = 7
+};
+
@interface SKNPDFAnnotationNote (SKExtensions)
@property (nonatomic, nullable, readonly) id richText;
+@property (nonatomic) PDFTextAnnotationIconType extendedIconType;
@end
NS_ASSUME_NONNULL_END
Modified: trunk/SKNPDFAnnotationNote_SKExtensions.m
===================================================================
--- trunk/SKNPDFAnnotationNote_SKExtensions.m 2024-10-21 17:03:31 UTC (rev
14562)
+++ trunk/SKNPDFAnnotationNote_SKExtensions.m 2024-10-21 17:07:53 UTC (rev
14563)
@@ -57,9 +57,14 @@
@implementation SKNPDFAnnotationNote (SKExtensions)
++ (NSSet *)keyPathsForValuesAffectingExtendedIconType {
+ return [NSSet setWithObjects:SKNPDFAnnotationIconTypeKey,
SKNPDFAnnotationDrawsImageKey, nil];
+}
+
- (void)setDefaultSkimNoteProperties {
[self setColor:[[NSUserDefaults standardUserDefaults]
colorForKey:SKAnchoredNoteColorKey]];
[self setIconType:[[NSUserDefaults standardUserDefaults]
integerForKey:SKAnchoredNoteIconTypeKey]];
+ [self setDrawsImage:[[NSUserDefaults standardUserDefaults]
boolForKey:SKAnchoredNoteDrawsImageKey]];
[self setTexts:@[[[SKNoteText alloc] initWithNote:self]]];
[self setPopup:nil];
}
@@ -66,10 +71,32 @@
- (BOOL)isNote { return YES; }
+- (BOOL)isResizable { return [self isSkimNote] && [self drawsImage]; }
+
- (BOOL)isMovable { return [self isSkimNote]; }
- (BOOL)hasBorder { return NO; }
+- (PDFTextAnnotationIconType)extendedIconType {
+ return [self drawsImage] ? kSKNPDFTextAnnotationIconImage : [self
iconType];
+}
+
+- (void)setExtendedIconType:(PDFTextAnnotationIconType)iconType {
+ if (iconType == kSKNPDFTextAnnotationIconImage) {
+ if ([self drawsImage] == NO)
+ [self setDrawsImage:YES];
+ if ([self iconType] != kPDFTextAnnotationIconNote)
+ [self setIconType:kPDFTextAnnotationIconNote];
+ } else {
+ if ([self drawsImage])
+ [self setDrawsImage:NO];
+ if ([self iconType] != iconType)
+ [self setIconType:iconType];
+ if (NSEqualSizes([self bounds].size, SKNPDFAnnotationNoteSize) == NO)
+ [self setBounds:(NSRect){[self bounds].origin,
SKNPDFAnnotationNoteSize}];
+ }
+}
+
// override these Leopard methods to avoid showing the standard tool tips over
our own
- (NSString *)toolTip { return @""; }
@@ -91,6 +118,7 @@
NSMutableSet *mutableKeys = [[super keysForValuesToObserveForUndo]
mutableCopy];
[mutableKeys addObject:SKNPDFAnnotationTextKey];
[mutableKeys addObject:SKNPDFAnnotationImageKey];
+ [mutableKeys addObject:SKNPDFAnnotationDrawsImageKey];
noteKeys = [mutableKeys copy];
}
return noteKeys;
Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/SKNoteWindowController.m 2024-10-21 17:07:53 UTC (rev 14563)
@@ -89,7 +89,7 @@
@synthesize textView, topView, edgeView, imageView, statusBar,
iconTypePopUpButton, iconLabelField, checkButton, noteController, note,
keepOnTop, forceOnTop;
@dynamic isNoteType;
-static NSImage *noteIcons[7] = {nil, nil, nil, nil, nil, nil, nil};
+static NSImage *noteIcons[8] = {nil, nil, nil, nil, nil, nil, nil, nil};
+ (void)makeNoteIcons {
if (noteIcons[0]) return;
@@ -109,6 +109,16 @@
}];
[noteIcons[i] setTemplate:YES];
}
+ noteIcons[kSKNPDFTextAnnotationIconImage] = [NSImage
imageWithSize:SKNPDFAnnotationNoteSize flipped:NO drawingHandler:^(NSRect r){
+ NSBezierPath *path = [NSBezierPath
bezierPathWithRoundedRect:NSMakeRect(1.5, 1.5, 13.0, 13.0) xRadius:1.0
yRadius:1.0];
+ CGFloat dash = 3.0;
+ [path setLineDash:&dash count:1 phase:0.0];
+ [path setLineWidth:1.0];
+ [path setLineCapStyle:NSButtLineCapStyle];
+ [[NSColor blackColor] setStroke];
+ [path stroke];
+ return YES;
+ }];
}
+ (NSArray *)fontKeysToObserve {
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/SKPDFView.m 2024-10-21 17:07:53 UTC (rev 14563)
@@ -2760,7 +2760,7 @@
- (void)setNeedsDisplayForAnnotation:(PDFAnnotation *)annotation
onPage:(PDFPage *)page {
NSRect rect = [annotation displayRect];
if (annotation == currentAnnotation) {
- CGFloat margin = ([annotation isResizable] ? HANDLE_SIZE : 1.0) /
[self scaleFactor];
+ CGFloat margin = (([annotation isResizable] || [annotation isNote]) ?
HANDLE_SIZE : 1.0) / [self scaleFactor];
rect = NSInsetRect(rect, -margin, -margin);
}
[self setNeedsDisplayInRect:rect ofPage:page];
@@ -3742,7 +3742,11 @@
CGFloat height = NSHeight(newBounds);
CGFloat ds = 2.0 * margin;
CGFloat ratio = isInk ? fmax(1.0, NSWidth(originalBounds) - ds) /
fmax(1.0, NSHeight(originalBounds) - ds) : 1.0;
-
+ if ([currentAnnotation isNote] && [(SKNPDFAnnotationNote
*)currentAnnotation drawsImage] && [currentAnnotation image]) {
+ NSSize size = [[currentAnnotation image] size];
+ ratio = size.width / size.height;
+ }
+
if ((resizeHandle & SKMaxXEdgeMask))
width = fmax(minSize, width + relPoint.x);
else if ((resizeHandle & SKMinXEdgeMask))
Modified: trunk/SKStringConstants.h
===================================================================
--- trunk/SKStringConstants.h 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/SKStringConstants.h 2024-10-21 17:07:53 UTC (rev 14563)
@@ -84,6 +84,7 @@
extern NSString *SKFreeTextNoteFontColorKey;
extern NSString *SKFreeTextNoteAlignmentKey;
extern NSString *SKAnchoredNoteIconTypeKey;
+extern NSString *SKAnchoredNoteDrawsImageKey;
extern NSString *SKFreeTextNoteLineWidthKey;
extern NSString *SKFreeTextNoteLineStyleKey;
extern NSString *SKFreeTextNoteDashPatternKey;
Modified: trunk/SKStringConstants.m
===================================================================
--- trunk/SKStringConstants.m 2024-10-21 17:03:31 UTC (rev 14562)
+++ trunk/SKStringConstants.m 2024-10-21 17:07:53 UTC (rev 14563)
@@ -85,6 +85,7 @@
NSString *SKFreeTextNoteAlignmentKey = @"SKFreeTextNoteAlignment";
NSString *SKFreeTextNoteLineWidthKey = @"SKFreeTextNoteLineWidth";
NSString *SKAnchoredNoteIconTypeKey = @"SKAnchoredNoteIconType";
+NSString *SKAnchoredNoteDrawsImageKey = @"SKAnchoredDrawsImageType";
NSString *SKFreeTextNoteLineStyleKey = @"SKFreeTextNoteLineStyle";
NSString *SKFreeTextNoteDashPatternKey = @"SKFreeTextNoteDashPattern";
NSString *SKCircleNoteLineWidthKey = @"SKCircleNoteLineWidth";
Modified: trunk/de.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/en.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/es.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/fr.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/it.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/ja.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/nl.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/pl.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/ru.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/zh_CN.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
Modified: trunk/zh_TW.lproj/NoteWindow.strings
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit