Changeset 8260


Ignore:
Timestamp:
Apr 20, 2009, 2:45:27 AM (13 years ago)
Author:
livings124
Message:

skeleton for priorities in the Mac UI - still lacks ability to actually change the priority

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileOutlineController.m

    r7802 r8260  
    288288- (void) setPriority: (id) sender
    289289{
    290     NSInteger priority;
     290    tr_priority_t priority;
    291291    switch ([sender tag])
    292292    {
     
    375375        //determine which priorities are checked
    376376        NSIndexSet * indexSet = [fOutline selectedRowIndexes];
    377         NSInteger priority;
     377        tr_priority_t priority;
    378378        switch ([menuItem tag])
    379379        {
  • trunk/macosx/Torrent.h

    r8023 r8260  
    123123- (void) setWaitToStart: (BOOL) wait;
    124124- (BOOL) waitingToStart;
     125
     126- (tr_priority_t) priority;
     127- (void) setPriority: (tr_priority_t) priority;
    125128
    126129- (void) revealData;
     
    244247- (NSInteger) checkForFiles: (NSIndexSet *) indexSet;
    245248- (void) setFileCheckState: (NSInteger) state forIndexes: (NSIndexSet *) indexSet;
    246 - (void) setFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
    247 - (BOOL) hasFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet;
     249- (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet;
     250- (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet;
    248251- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
    249252
  • trunk/macosx/Torrent.m

    r8122 r8260  
    445445}
    446446
     447- (tr_priority_t) priority
     448{
     449    return tr_torrentGetPriority(fHandle);
     450}
     451
     452- (void) setPriority: (tr_priority_t) priority
     453{
     454    return tr_torrentSetPriority(fHandle, priority);
     455}
     456
    447457- (void) revealData
    448458{
     
    14591469}
    14601470
    1461 - (void) setFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet
     1471- (void) setFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet
    14621472{
    14631473    const NSUInteger count = [indexSet count];
     
    14701480}
    14711481
    1472 - (BOOL) hasFilePriority: (NSInteger) priority forIndexes: (NSIndexSet *) indexSet
     1482- (BOOL) hasFilePriority: (tr_priority_t) priority forIndexes: (NSIndexSet *) indexSet
    14731483{
    14741484    for (NSInteger index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
     
    14881498            continue;
    14891499       
    1490         const NSInteger priority = tr_torrentGetFilePriority(fHandle, index);
     1500        const tr_priority_t priority = tr_torrentGetFilePriority(fHandle, index);
    14911501        if (priority == TR_PRI_LOW)
    14921502        {
  • trunk/macosx/TorrentCell.h

    r7659 r8260  
    3333            fHoverControl, fHoverReveal, fHoverAction;
    3434   
     35    NSImage * fHighPriorityImage, * fLowPriorityImage;
     36   
    3537    NSColor * fBarBorderColor, * fBluePieceColor;
    3638}
  • trunk/macosx/TorrentCell.m

    r7659 r8260  
    3737#define ACTION_BUTTON_WIDTH 16.0f
    3838
     39#define PRIORITY_ICON_WIDTH 14.0f
     40#define PRIORITY_ICON_HEIGHT 14.0f
     41
    3942//ends up being larger than font height
    4043#define HEIGHT_TITLE 16.0f
     
    4447#define PADDING_BETWEEN_IMAGE_AND_TITLE 5.0f
    4548#define PADDING_BETWEEN_IMAGE_AND_BAR 7.0f
     49#define PADDING_BETWEEN_TITLE_AND_PRIORITY 4.0f
    4650#define PADDING_ABOVE_TITLE 4.0f
    4751#define PADDING_ABOVE_MIN_STATUS 4.0f
     
    99103        fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0f green: 0.4f blue: 0.8f alpha: 1.0f] retain];
    100104        fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0f alpha: 0.2f] retain];
     105       
     106        fHighPriorityImage = [[NSImage imageNamed: @"PriorityHigh.png"] copy];
     107        [fHighPriorityImage setFlipped: YES];
     108       
     109        fLowPriorityImage = [[NSImage imageNamed: @"PriorityLow.png"] copy];
     110        [fLowPriorityImage setFlipped: YES];
    101111    }
    102112        return self;
     
    455465    NSRect titleRect = [self rectForTitleWithString: titleString basedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame];
    456466    [titleString drawInRect: titleRect];
     467   
     468    //priority icon
     469    if ([torrent priority] != TR_PRI_NORMAL)
     470    {
     471        NSImage * priorityImage = [torrent priority] == TR_PRI_HIGH ? fHighPriorityImage : fLowPriorityImage;
     472       
     473        NSRect priorityRect = NSMakeRect(NSMaxX(titleRect) + PADDING_BETWEEN_TITLE_AND_PRIORITY,
     474                                titleRect.origin.y - (PRIORITY_ICON_HEIGHT - titleRect.size.height) / 2.0,
     475                                PRIORITY_ICON_WIDTH, PRIORITY_ICON_HEIGHT);
     476        [priorityImage drawInRect: priorityRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
     477    }
    457478   
    458479    //progress
     
    719740            inBounds: (NSRect) bounds
    720741{
    721     BOOL minimal = [fDefaults boolForKey: @"SmallView"];
     742    const BOOL minimal = [fDefaults boolForKey: @"SmallView"];
    722743   
    723744    NSRect result = bounds;
     
    727748    result.size = [string size];
    728749    result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL
    729                             - (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + statusRect.size.width : 0));
     750                - (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + statusRect.size.width : 0.0)
     751                - ([[self representedObject] priority] != TR_PRI_NORMAL ? PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY: 0.0));
    730752   
    731753    return result;
Note: See TracChangeset for help on using the changeset viewer.