Revision: 14570
http://sourceforge.net/p/skim-app/code/14570
Author: hofman
Date: 2024-10-23 08:55:16 +0000 (Wed, 23 Oct 2024)
Log Message:
-----------
draw the note's image in the popup menu item when available
Modified Paths:
--------------
trunk/SKNoteWindowController.m
Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m 2024-10-23 08:33:01 UTC (rev 14569)
+++ trunk/SKNoteWindowController.m 2024-10-23 08:55:16 UTC (rev 14570)
@@ -162,6 +162,8 @@
[note addObserver:self forKeyPath:SKNPDFAnnotationPageKey options:0
context:&SKNoteWindowNoteObservationContext];
[note addObserver:self forKeyPath:SKNPDFAnnotationBoundsKey options:0
context:&SKNoteWindowNoteObservationContext];
[note addObserver:self forKeyPath:SKNPDFAnnotationStringKey options:0
context:&SKNoteWindowNoteObservationContext];
+ if ([note isNote])
+ [note addObserver:self forKeyPath:SKNPDFAnnotationImageKey
options:0 context:&SKNoteWindowNoteObservationContext];
if ([self isNoteType]) {
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
for (NSString *key in [[self class] fontKeysToObserve])
@@ -184,6 +186,18 @@
[[self window] setCollectionBehavior:(onTop ?
(NSWindowCollectionBehaviorManaged |
NSWindowCollectionBehaviorFullScreenAuxiliary) :
NSWindowCollectionBehaviorFullScreenAuxiliary)];
}
+- (void)updateMenuImage {
+ NSImage *img = [note image];
+ if (img)
+ img = [NSImage imageWithSize:SKNPDFAnnotationNoteSize flipped:NO
drawingHandler:^(NSRect r){
+ [img drawInRect:r];
+ return YES;
+ }];
+ else
+ img = noteIcons[kSKNPDFTextAnnotationIconImage];
+ [[iconTypePopUpButton itemAtIndex:kSKNPDFTextAnnotationIconImage]
setImage:img];
+}
+
- (void)windowDidLoad {
[self updateWindowLevel];
@@ -205,6 +219,7 @@
for (NSMenuItem *item in [iconTypePopUpButton itemArray])
[item setImage:noteIcons[[item tag]]];
+ [self updateMenuImage];
} else {
[topView removeFromSuperview];
@@ -256,6 +271,8 @@
[note removeObserver:self forKeyPath:SKNPDFAnnotationPageKey
context:&SKNoteWindowNoteObservationContext];
[note removeObserver:self forKeyPath:SKNPDFAnnotationBoundsKey
context:&SKNoteWindowNoteObservationContext];
[note removeObserver:self forKeyPath:SKNPDFAnnotationStringKey
context:&SKNoteWindowNoteObservationContext];
+ if ([note isNote])
+ [note removeObserver:self forKeyPath:SKNPDFAnnotationImageKey
context:&SKNoteWindowNoteObservationContext];
if ([self isNoteType]) {
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
for (NSString *key in [[self class] fontKeysToObserve]) {
@@ -423,6 +440,8 @@
} else if (context == &SKNoteWindowNoteObservationContext) {
if ([keyPath isEqualToString:SKNPDFAnnotationStringKey])
[self synchronizeWindowTitleWithDocumentName];
+ else if ([keyPath isEqualToString:SKNPDFAnnotationImageKey])
+ [self updateMenuImage];
else
[self updateStatusMessage];
} else {
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