]> granicus.if.org Git - transmission/commitdiff
#5109 Show expansion tooltip for abbreviated file names in the File table
authorMitchell Livingston <livings124@transmissionbt.com>
Mon, 29 Oct 2012 22:17:08 +0000 (22:17 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Mon, 29 Oct 2012 22:17:08 +0000 (22:17 +0000)
macosx/FileNameCell.m

index e95713f80757c4dd41645296fbbac1ff8b1d26b7..b9e5a68baadb3551146dc7853407ffcdec285de7 100644 (file)
@@ -38,6 +38,7 @@
 #define PADDING_ABOVE_TITLE_FILE 2.0
 #define PADDING_BELOW_STATUS_FILE 2.0
 #define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0
+#define PADDING_EXPANSION_FRAME 2.0
 
 @interface FileNameCell (Private)
 
     [statusString drawInRect: statusRect];
 }
 
+- (NSRect) expansionFrameWithFrame: (NSRect) cellFrame inView: (NSView *) view
+{
+    NSAttributedString * titleString = [self attributedTitle];
+    NSRect realRect = [self rectForTitleWithString: titleString inBounds: cellFrame];
+    
+    if ([titleString size].width > NSWidth(realRect)
+        && NSMouseInRect([view convertPoint: [[view window] convertScreenToBase: [NSEvent mouseLocation]] fromView: nil], realRect, [view isFlipped]))
+    {
+        realRect.size.width = [titleString size].width;
+        return NSInsetRect(realRect, -PADDING_EXPANSION_FRAME, -PADDING_EXPANSION_FRAME);
+    }
+    
+    return NSZeroRect;
+}
+
+- (void) drawWithExpansionFrame: (NSRect) cellFrame inView: (NSView *)view
+{
+    cellFrame.origin.x += PADDING_EXPANSION_FRAME;
+    cellFrame.origin.y += PADDING_EXPANSION_FRAME;
+    
+    [fTitleAttributes setObject: [NSColor controlTextColor] forKey: NSForegroundColorAttributeName];
+    NSAttributedString * titleString = [self attributedTitle];
+    [titleString drawInRect: cellFrame];
+}
+
 @end
 
 @implementation FileNameCell (Private)