Changeset 14705


Ignore:
Timestamp:
Mar 3, 2016, 5:57:08 PM (3 years ago)
Author:
mikedld
Message:

#6078: Show main window and scroll to torrent on notification click

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r14703 r14705  
    19921992           
    19931993            NSAssert1(row != -1, @"expected a row to be found for torrent %@", torrent);
    1994             [fTableView selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection:NO];
    1995             #warning focus the window
     1994
     1995            [self showMainWindow: nil];
     1996            [fTableView selectAndScrollToRow: row];
    19961997        }
    19971998    }
  • trunk/macosx/TorrentTableView.h

    r14662 r14705  
    9292- (CGFloat) piecesBarPercent;
    9393
     94- (void) selectAndScrollToRow: (NSInteger) row;
     95
    9496@end
  • trunk/macosx/TorrentTableView.m

    r14665 r14705  
    843843}
    844844
     845- (void) selectAndScrollToRow: (NSInteger) row
     846{
     847    NSParameterAssert(row >= 0);
     848    NSParameterAssert(row < [self numberOfRows]);
     849   
     850    [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
     851   
     852    const NSRect rowRect = [self rectOfRow: row];
     853    const NSRect viewRect = [[self superview] frame];
     854
     855    NSPoint scrollOrigin = rowRect.origin;
     856    scrollOrigin.y += (rowRect.size.height - viewRect.size.height) / 2;
     857    if (scrollOrigin.y < 0)
     858        scrollOrigin.y = 0;
     859
     860    [[[self superview] animator] setBoundsOrigin: scrollOrigin];
     861}
     862
    845863@end
    846864
Note: See TracChangeset for help on using the changeset viewer.