simplify the priority selector mouse-over code
This commit is contained in:
parent
695b6b105d
commit
a0221c0818
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class Torrent;
|
||||
@class FilePriorityCell;
|
||||
@class CTGradient;
|
||||
|
||||
@interface FileOutlineView : NSOutlineView
|
||||
|
@ -35,10 +34,11 @@
|
|||
CTGradient * fHighPriorityGradient, * fLowPriorityGradient, * fMixedPriorityGradient;
|
||||
|
||||
int fMouseRow;
|
||||
FilePriorityCell * fMouseCell;
|
||||
}
|
||||
|
||||
- (void) setTorrent: (Torrent *) torrent;
|
||||
- (Torrent *) torrent;
|
||||
|
||||
- (int) hoveredRow;
|
||||
|
||||
@end
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -132,24 +128,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (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]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,33 +148,11 @@
|
|||
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])
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -93,16 +93,9 @@
|
|||
[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
|
||||
|
|
Loading…
Reference in New Issue