Revision: 15148 http://sourceforge.net/p/skim-app/code/15148 Author: hofman Date: 2025-05-04 09:11:54 +0000 (Sun, 04 May 2025) Log Message: ----------- wait generating image for tool tip until grouped search result is finished being constructed by inspecting a flag set when ending searching a page
Modified Paths: -------------- trunk/SKGroupedSearchResult.h trunk/SKGroupedSearchResult.m trunk/SKImageToolTipContext.h trunk/SKImageToolTipWindow.m trunk/SKMainWindowController.m Modified: trunk/SKGroupedSearchResult.h =================================================================== --- trunk/SKGroupedSearchResult.h 2025-05-03 14:51:40 UTC (rev 15147) +++ trunk/SKGroupedSearchResult.h 2025-05-04 09:11:54 UTC (rev 15148) @@ -47,6 +47,7 @@ PDFPage *page; NSUInteger maxCount; NSMutableArray<PDFSelection *> *matches; + BOOL readyForToolTip; } @property (nonatomic, readonly) PDFPage *page; @@ -55,6 +56,7 @@ @property (nonatomic) NSUInteger maxCount; @property (weak, nonatomic, readonly) NSString *label; @property (nonatomic, readonly) NSArray<PDFSelection *> *matches; +@property (nonatomic, getter=isReadyForToolTip) BOOL readyForToolTip; - (instancetype)initWithPage:(PDFPage *)aPage maxCount:(NSUInteger)aMaxCount; Modified: trunk/SKGroupedSearchResult.m =================================================================== --- trunk/SKGroupedSearchResult.m 2025-05-03 14:51:40 UTC (rev 15147) +++ trunk/SKGroupedSearchResult.m 2025-05-04 09:11:54 UTC (rev 15148) @@ -45,7 +45,7 @@ @implementation SKGroupedSearchResult -@synthesize page, maxCount, matches; +@synthesize page, maxCount, matches, readyForToolTip; @dynamic pageIndex, count, label; + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { Modified: trunk/SKImageToolTipContext.h =================================================================== --- trunk/SKImageToolTipContext.h 2025-05-03 14:51:40 UTC (rev 15147) +++ trunk/SKImageToolTipContext.h 2025-05-04 09:11:54 UTC (rev 15148) @@ -44,6 +44,8 @@ @protocol SKImageToolTipContext <NSObject> - (nullable NSImage *)toolTipImageWithScale:(CGFloat)scale; +@optional +@property (nonatomic, readonly, getter=isReadyForToolTip) BOOL readyForToolTip; @end Modified: trunk/SKImageToolTipWindow.m =================================================================== --- trunk/SKImageToolTipWindow.m 2025-05-03 14:51:40 UTC (rev 15147) +++ trunk/SKImageToolTipWindow.m 2025-05-04 09:11:54 UTC (rev 15148) @@ -174,7 +174,11 @@ image = nil; shouldShow = NO; - dispatch_async([[self class] imageQueue], ^{ + dispatch_time_t delay = 0; + if ([aContext respondsToSelector:@selector(isReadyForToolTip)] && [aContext isReadyForToolTip] == NO) + delay = NSEC_PER_SEC / 10; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay), [[self class] imageQueue], ^{ NSNumber *usedScaleNumber = [[NSUserDefaults standardUserDefaults] objectForKey:SKToolTipScaleKey]; CGFloat usedScale = [usedScaleNumber respondsToSelector:@selector(doubleValue)] ? [usedScaleNumber doubleValue] : DEFAULT_SCALE; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-05-03 14:51:40 UTC (rev 15147) +++ trunk/SKMainWindowController.m 2025-05-04 09:11:54 UTC (rev 15148) @@ -2037,6 +2037,18 @@ - (void)documentDidEndPageFind:(NSNotification *)note { NSUInteger pageIndex = [[[note userInfo] objectForKey:@"PDFDocumentPageIndex"] unsignedIntValue]; + + NSUInteger i = [groupedSearchResults count]; + while (i-- > 0) { + SKGroupedSearchResult *result = [groupedSearchResults objectAtIndex:i]; + NSUInteger aPageIndex = [result pageIndex]; + if (pageIndex >= aPageIndex) { + if (pageIndex == aPageIndex) + [result setReadyForToolTip:YES]; + break; + } + } + if ([statusBar progressIndicatorStyle] == SKProgressIndicatorStyleDeterminate) [[statusBar progressIndicator] setDoubleValue:pageIndex + 1.0]; if (pageIndex > 0 && pageIndex % 50 == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit