1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-20 13:16:53 +00:00

attempt to fix table drawing issues

This commit is contained in:
Mitchell Livingston 2008-01-15 04:45:57 +00:00
parent 2047901eae
commit edb46062b2
4 changed files with 54 additions and 15 deletions

View file

@ -56,7 +56,9 @@
- (void) addTrackingAreasForView: (NSView *) controlView inRect: (NSRect) cellFrame withUserInfo: (NSDictionary *) userInfo
mouseLocation: (NSPoint) mouseLocation;
- (void) mouseEntered: (NSEvent *) event;
- (void) mouseExited: (NSEvent *) event;
/*- (void) mouseEntered: (NSEvent *) event;
- (void) mouseExited: (NSEvent *) event;*/
- (void) setControlHover: (BOOL) hover;
- (void) setRevealHover: (BOOL) hover;
@end

View file

@ -384,7 +384,7 @@
[area release];
}
- (void) mouseEntered: (NSEvent *) event
/*- (void) mouseEntered: (NSEvent *) event
{
NSDictionary * userInfo = [event userData];
@ -402,6 +402,16 @@
fHoverReveal = NO;
[(NSControl *)[self controlView] updateCell: self];
}*/
- (void) setControlHover: (BOOL) hover
{
fHoverControl = hover;
}
- (void) setRevealHover: (BOOL) hover
{
fHoverReveal = hover;
}
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
@ -505,6 +515,17 @@
else
controlImage = [NSImage imageNamed: [@"Resume" stringByAppendingString: controlImageSuffix]];
}
//TEST CODE
/*NSImage * controlImage;
if (fMouseDownControlButton)
controlImage = [NSImage imageNamed: @"ResumeOn.png"];
else if (fHoverControl)
controlImage = [NSImage imageNamed: @"ResumeNoWaitOff.png"];
else
controlImage = [NSImage imageNamed: @"ResumeOff.png"];*/
[controlImage setFlipped: YES];
[controlImage drawInRect: [self controlButtonRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver
fraction: 1.0];

View file

@ -37,8 +37,7 @@
IBOutlet NSMenu * fContextRow, * fContextNoRow;
int fMouseRow;
TorrentCell * fMouseCell;
int fMouseControlRow, fMouseRevealRow;
NSIndexSet * fSelectedIndexes;
NSMutableArray * fKeyStrokes;

View file

@ -54,7 +54,8 @@
{
fDefaults = [NSUserDefaults standardUserDefaults];
fMouseRow = -1;
fMouseControlRow = -1;
fMouseRevealRow = -1;
[self setDelegate: self];
}
@ -64,7 +65,7 @@
- (void) dealloc
{
[fMouseCell release];
//[fMouseCell release];
[fSelectedIndexes release];
[fKeyStrokes release];
@ -81,6 +82,8 @@
- (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell forTableColumn: (NSTableColumn *) tableColumn row: (int) row
{
[cell setRepresentedObject: [fTorrents objectAtIndex: row]];
[cell setControlHover: row == fMouseControlRow];
[cell setRevealHover: row == fMouseRevealRow];
}
- (NSString *) tableView: (NSTableView *) tableView typeSelectStringForTableColumn: (NSTableColumn *) tableColumn row: (int) row
@ -120,11 +123,13 @@
- (void) mouseEntered: (NSEvent *) event
{
NSDictionary * dict = (NSDictionary *)[event userData];
NSNumber * row;
if ((row = [(NSDictionary *)[event userData] objectForKey: @"Row"]))
if ((row = [dict objectForKey: @"Row"]))
{
int rowVal = [row intValue];
TorrentCell * cell = (TorrentCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: rowVal];
/*TorrentCell * cell = (TorrentCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: rowVal];
if (fMouseCell != cell)
{
[fMouseCell release];
@ -135,7 +140,14 @@
[fMouseCell setRepresentedObject: [fTorrents objectAtIndex: rowVal]];
[fMouseCell setControlView: self];
[fMouseCell mouseEntered: event];
}
}*/
if ([[dict objectForKey: @"Type"] isEqualToString: @"Control"])
fMouseControlRow = rowVal;
else
fMouseRevealRow = rowVal;
[self setNeedsDisplayInRect: [self rectOfRow: rowVal]];
}
}
@ -144,18 +156,23 @@
NSNumber * row;
if ((row = [(NSDictionary *)[event userData] objectForKey: @"Row"]))
{
TorrentCell * cell = (TorrentCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Torrent"]
/*TorrentCell * cell = (TorrentCell *)[self preparedCellAtColumn: [self columnWithIdentifier: @"Torrent"]
row: [row intValue]];
[cell setControlView: self];
[cell mouseExited: event];
[fMouseCell release];
fMouseCell = nil;
fMouseRow = -1;
fMouseRow = -1;*/
fMouseControlRow = -1;
fMouseRevealRow = -1;
[self setNeedsDisplayInRect: [self rectOfRow: [row intValue]]];
}
}
- (NSCell *) preparedCellAtColumn: (NSInteger) column row: (NSInteger) row
/*- (NSCell *) preparedCellAtColumn: (NSInteger) column row: (NSInteger) row
{
if (![self selectedCell] && row == fMouseRow && column == [self columnWithIdentifier: @"Torrent"])
return fMouseCell;
@ -169,9 +186,9 @@
[self setNeedsDisplayInRect: [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: fMouseRow]];
else
[super updateCell: cell];
}
}*/
- (void)tableViewSelectionIsChanging:(NSNotification *)aNotification
- (void) tableViewSelectionIsChanging: (NSNotification *) notification
{
if (fSelectedIndexes)
[self selectRowIndexes: fSelectedIndexes byExtendingSelection: NO];