Revision: 28290
          http://sourceforge.net/p/bibdesk/svn/28290
Author:   hofman
Date:     2023-06-05 16:07:26 +0000 (Mon, 05 Jun 2023)
Log Message:
-----------
add tooltips for titles, include subtitle if supported

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2023-06-05 
09:22:52 UTC (rev 28289)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2023-06-05 
16:07:26 UTC (rev 28290)
@@ -1628,16 +1628,18 @@
         NSPoint mouseLoc = [self convertPoint:[[self window] 
mouseLocationOutsideOfEventStream] fromView:nil];
         NSUInteger mouseIndex = NSNotFound;
         NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | 
NSTrackingActiveInActiveApp;
+        CGFloat textHeight = [self _textHeight];
         
         for (r = rMin, i = iMin; r < rMax; r++) 
         {
             for (c = cMin; c < cMax && i < iMax; c++, i++) 
             {
-                NSRect iconRect = NSIntersectionRect(visibleRect, [self 
_rectOfIconInRow:r column:c]);
+                NSRect iconRect = [self _rectOfIconInRow:r column:c];
+                NSRect rect = NSIntersectionRect(visibleRect, iconRect);
                 
-                if (NSIsEmptyRect(iconRect) == NO) {
+                if (NSIsEmptyRect(rect) == NO) {
                     // Finder doesn't show buttons unless it's the front app.  
If Finder is the front app, it shows them for any window, regardless of 
main/key state, so we'll do the same.
-                    BOOL mouseInside = NSPointInRect(mouseLoc, iconRect);
+                    BOOL mouseInside = NSPointInRect(mouseLoc, rect);
                     
                     if (mouseInside) {
                         mouseIndex = i;
@@ -1646,14 +1648,20 @@
                         options &= ~NSTrackingAssumeInside;
                     }
                     
-                    NSTrackingArea *area = [[NSTrackingArea alloc] 
initWithRect:iconRect options:options owner:self userInfo:nil];
+                    NSTrackingArea *area = [[NSTrackingArea alloc] 
initWithRect:rect options:options owner:self userInfo:nil];
                     [self addTrackingArea:area];
                     [_trackingAreas addObject:area];
                     [area release];
                     
                     // don't pass the URL as owner, as it's not retained; use 
the delegate method instead
-                    [self addToolTipRect:iconRect owner:self userData:NULL];
+                    [self addToolTipRect:rect owner:self userData:NULL];
                 }
+                
+                rect = NSIntersectionRect(visibleRect, 
NSMakeRect(NSMinX(iconRect), NSMaxY(iconRect) + TEXT_OFFSET, NSWidth(iconRect), 
textHeight));
+                
+                if (NSIsEmptyRect(rect) == NO) {
+                    [self addToolTipRect:rect owner:self userData:(void *)1];
+                }
             }
         }    
         
@@ -3292,6 +3300,12 @@
 
 - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag 
point:(NSPoint)point userData:(void *)userData
 {
+    BOOL isTitle = (userData == (void *)1);
+    if (isTitle) {
+        // shift the point for title toool tips so it falls within its icon 
rect
+        point.y -= TEXT_OFFSET + [self _textHeight];
+    }
+    
     NSURL *theURL = [self _URLAtPoint:point];
     NSString *name = nil;
     if ([theURL isFileURL]) {
@@ -3301,6 +3315,14 @@
     } else {
         name = [[theURL absoluteString] 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     }
+    if (isTitle && [_dataSource 
respondsToSelector:@selector(fileView:subtitleAtIndex:)]) {
+        NSUInteger i = [self _indexAtPoint:point dropOperation:NULL];
+        if (i != NSNotFound) {
+            NSString *subtitle = [self subtitleAtIndex:i];
+            if (subtitle)
+                name = [name stringByAppendingFormat:@"\n%@", subtitle];
+        }
+    }
     return name;
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to