]> granicus.if.org Git - transmission/commitdiff
simplify the priority selector mouse-over code
authorMitchell Livingston <livings124@transmissionbt.com>
Tue, 25 Mar 2008 03:17:35 +0000 (03:17 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Tue, 25 Mar 2008 03:17:35 +0000 (03:17 +0000)
macosx/FileOutlineController.m
macosx/FileOutlineView.h
macosx/FileOutlineView.m
macosx/FilePriorityCell.h
macosx/FilePriorityCell.m

index 7d924b9ca3082d2948a23a0c7b4c29afe60eb9e5..8e4ce851624c9f7b11cd45efdd5073639aad60f3 100644 (file)
@@ -25,6 +25,7 @@
 #import "FileOutlineController.h"
 #import "Torrent.h"
 #import "FileOutlineView.h"
+#import "FilePriorityCell.h"
 #import "NSApplicationAdditions.h"
 
 #define ROW_SMALL_HEIGHT 18.0
@@ -117,7 +118,10 @@ typedef enum
     if ([identifier isEqualToString: @"Check"])
         [cell setEnabled: [fTorrent canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]]];
     else if ([identifier isEqualToString: @"Priority"])
+    {
         [cell setRepresentedObject: item];
+        [(FilePriorityCell *)cell setHovered: [NSApp isOnLeopardOrBetter] ? [fOutline hoveredRow] == [fOutline rowForItem: item] : NO];
+    }
     else;
 }
 
index 71300dd7c7bacef5908aa800bad111f0434a0b3e..f70e7ee39998c0293beb69243e0ef3a459643a26 100644 (file)
@@ -25,7 +25,6 @@
 #import <Cocoa/Cocoa.h>
 
 @class Torrent;
-@class FilePriorityCell;
 @class CTGradient;
 
 @interface FileOutlineView : NSOutlineView
     CTGradient * fHighPriorityGradient, * fLowPriorityGradient, * fMixedPriorityGradient;
     
     int fMouseRow;
-    FilePriorityCell * fMouseCell;
 }
 
 - (void) setTorrent: (Torrent *) torrent;
 - (Torrent *) torrent;
 
+- (int) hoveredRow;
+
 @end
index 71e41ee711398dc630511f66614310fd58801232..166aba593196b0ef2f84fa6a781034d38e9c1fa4 100644 (file)
@@ -22,8 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  *****************************************************************************/
 
-#warning treat hovering the same as in the table?
-
 #import "FileOutlineView.h"
 #import "FileNameCell.h"
 #import "FilePriorityCell.h"
@@ -66,8 +64,6 @@
     [fLowPriorityGradient release];
     [fMixedPriorityGradient release];
     
-    [fMouseCell release];
-    
     [super dealloc];
 }
 
     }
 }
 
+- (int) hoveredRow
+{
+    return fMouseRow;
+}
+
 - (void) mouseEntered: (NSEvent *) event
 {
     NSNumber * row;
     if ((row = [(NSDictionary *)[event userData] objectForKey: @"Row"]))
     {
-        int rowVal = [row intValue];
-        FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Priority"] row: rowVal];
-        if (fMouseCell != cell)
-        {
-            [fMouseCell release];
-            
-            fMouseRow = rowVal;
-            fMouseCell = [cell copy];
-            
-            [fMouseCell setControlView: self];
-            [fMouseCell mouseEntered: event];
-            [fMouseCell setRepresentedObject: [cell representedObject]];
-        }
+        fMouseRow = [row intValue];
+        [self setNeedsDisplayInRect: [self rectOfRow: fMouseRow]];
     }
 }
 
     NSNumber * row;
     if ((row = [(NSDictionary *)[event userData] objectForKey: @"Row"]))
     {
-        FilePriorityCell * cell = (FilePriorityCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Priority"]
-                                                        row: [row intValue]];
-        [cell setControlView: self];
-        [cell mouseExited: event];
-        
-        [fMouseCell release];
-        fMouseCell = nil;
+        [self setNeedsDisplayInRect: [self rectOfRow: [row intValue]]];
         fMouseRow = -1;
     }
 }
 
-- (NSCell *) preparedCellAtColumn: (NSInteger) column row: (NSInteger) row
-{
-    if (![self selectedCell] && row == fMouseRow && column == [self columnWithIdentifier: @"Priority"])
-        return fMouseCell;
-    else
-        return [super preparedCellAtColumn: column row: row];
-}
-
-- (void) updateCell: (NSCell *) cell
-{
-    if (cell == fMouseCell)
-        [self setNeedsDisplayInRect: [self frameOfCellAtColumn: [self columnWithIdentifier: @"Priority"] row: fMouseRow]];
-    else
-        [super updateCell: cell];
-}
-
 - (void) drawRow: (int) row clipRect: (NSRect) clipRect
 {
     if (![self isRowSelected: row])
index e76b5ebdcbd04c69fa79baeaeb800ee2d261aa98..8d99a937ac557a89a30d75a2385a6ed56742f5d0 100644 (file)
@@ -32,7 +32,7 @@
 
 - (void) addTrackingAreasForView: (NSView *) controlView inRect: (NSRect) cellFrame withUserInfo: (NSDictionary *) userInfo
             mouseLocation: (NSPoint) mouseLocation;
-- (void) mouseEntered: (NSEvent *) event;
-- (void) mouseExited: (NSEvent *) event;
+
+- (void) setHovered: (BOOL) hovered;
 
 @end
index 6a8d218fea236a510cde61fef27988f5ad5fb2a0..b523e718daa205d0b3c6ab2a4a7a7ef71e760575 100644 (file)
     [area release];
 }
 
-- (void) mouseEntered: (NSEvent *) event
+- (void) setHovered: (BOOL) hovered
 {
-    fHoverRow = YES;
-    [(NSControl *)[self controlView] updateCell: self];
-}
-
-- (void) mouseExited: (NSEvent *) event
-{
-    fHoverRow = NO;
-    [(NSControl *)[self controlView] updateCell: self];
+    fHoverRow = hovered;
 }
 
 - (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView