Changeset 1575


Ignore:
Timestamp:
Mar 22, 2007, 4:30:08 AM (14 years ago)
Author:
livings124
Message:

seeding bar shows progress towards ratio

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r1500 r1575  
    143143                A289EB0C0A33C56D00B082A3 /* ButtonBorder.png in Resources */ = {isa = PBXBuildFile; fileRef = A289EB0B0A33C56D00B082A3 /* ButtonBorder.png */; };
    144144                A28DBADC0A33C1D800F4B4A7 /* ActionButton.png in Resources */ = {isa = PBXBuildFile; fileRef = A28DBADB0A33C1D800F4B4A7 /* ActionButton.png */; };
     145                A28FF34E0BB23A4E001F5010 /* ProgressBarLightGreen.png in Resources */ = {isa = PBXBuildFile; fileRef = A28FF34D0BB23A4E001F5010 /* ProgressBarLightGreen.png */; };
    145146                A2912C540A2956E80097A0CA /* PrefsWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = A2912C520A2956E80097A0CA /* PrefsWindow.nib */; };
    146147                A291DAAF0AC8BEB6003385E9 /* PiecesView.m in Sources */ = {isa = PBXBuildFile; fileRef = A291DAAD0AC8BEB6003385E9 /* PiecesView.m */; };
     
    354355                A289EB0B0A33C56D00B082A3 /* ButtonBorder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ButtonBorder.png; path = macosx/Images/ButtonBorder.png; sourceTree = "<group>"; };
    355356                A28DBADB0A33C1D800F4B4A7 /* ActionButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButton.png; path = macosx/Images/ActionButton.png; sourceTree = "<group>"; };
     357                A28FF34D0BB23A4E001F5010 /* ProgressBarLightGreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarLightGreen.png; path = macosx/Images/ProgressBarLightGreen.png; sourceTree = "<group>"; };
    356358                A2912C530A2956E80097A0CA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = macosx/English.lproj/PrefsWindow.nib; sourceTree = "<group>"; };
    357359                A291DAAC0AC8BEB6003385E9 /* PiecesView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PiecesView.h; path = macosx/PiecesView.h; sourceTree = "<group>"; };
     
    518520                                A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */,
    519521                                A2305A7F0A3DC9E400AB2D77 /* ProgressBarGreen.png */,
     522                                A28FF34D0BB23A4E001F5010 /* ProgressBarLightGreen.png */,
    520523                                A260C9AB0AA3B8D700FDC1B7 /* Error.tiff */,
    521524                                A29C8B320ACC6E93000ED9F9 /* YellowDot.tiff */,
     
    858861                                A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */,
    859862                                A24103070AF80E390001C8D0 /* FilterButtonPressedLeft.png in Resources */,
     863                                A28FF34E0BB23A4E001F5010 /* ProgressBarLightGreen.png in Resources */,
    860864                        );
    861865                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/Torrent.h

    r1519 r1575  
    2525#import <Cocoa/Cocoa.h>
    2626#import <transmission.h>
     27
     28#define INVALID -99
    2729
    2830@interface Torrent : NSObject
     
    9092- (float)       ratioLimit;
    9193- (void)        setRatioLimit: (float) limit;
     94- (float)       actualStopRatio; //returns INVALID if will not stop
    9295
    9396- (int)     checkUpload;
  • trunk/macosx/Torrent.m

    r1561 r1575  
    3131#define BLANK_PIECE -99
    3232
    33 #define INVALID -99
    34 
    3533@interface Torrent (Private)
    3634
     
    267265   
    268266    //check to stop for ratio
    269     if ([self isSeeding] && ((fRatioSetting == NSOnState && [self ratio] >= fRatioLimit)
    270             || (fRatioSetting == NSMixedState && [fDefaults boolForKey: @"RatioCheck"]
    271                 && [self ratio] >= [fDefaults floatForKey: @"RatioLimit"])))
     267    float stopRatio;
     268    if ([self isSeeding] && (stopRatio = [self actualStopRatio]) != INVALID && [self ratio] >= stopRatio)
    272269    {
    273270        [self stopTransfer];
     
    437434                                    [NSNumber numberWithBool: [self isError]], @"Error", nil];
    438435   
     436    if ([self isSeeding])
     437    {
     438        [info setObject: [NSNumber numberWithFloat: [self ratio]] forKey: @"Ratio"];
     439        [info setObject: [NSNumber numberWithFloat: [self actualStopRatio]] forKey: @"StopRatio"];
     440    }
     441   
    439442    if (![fDefaults boolForKey: @"SmallView"])
    440443    {
     
    546549    if (limit >= 0)
    547550        fRatioLimit = limit;
     551}
     552
     553- (float) actualStopRatio
     554{
     555    if (fRatioSetting == NSOnState)
     556        return fRatioLimit;
     557    else if (fRatioSetting == NSMixedState && [fDefaults boolForKey: @"RatioCheck"])
     558        return [fDefaults floatForKey: @"RatioLimit"];
     559    else
     560        return INVALID;
    548561}
    549562
  • trunk/macosx/TorrentCell.h

    r855 r1575  
    3535    NSImage * fProgressWhite, * fProgressBlue, * fProgressGray, * fProgressGreen,
    3636                    * fProgressAdvanced, * fProgressEndWhite, * fProgressEndBlue,
    37                     * fProgressEndGray, * fProgressEndGreen, * fProgressEndAdvanced,
    38                     * fErrorImage;
     37                    * fProgressEndGray, * fProgressEndGreen, * fProgressLightGreen,
     38                    * fProgressEndAdvanced, * fErrorImage;
    3939
    4040    NSUserDefaults * fDefaults;
  • trunk/macosx/TorrentCell.m

    r1402 r1575  
    6464        [fProgressGreen setScalesWhenResized: YES];
    6565       
     66        fProgressLightGreen = [NSImage imageNamed: @"ProgressBarLightGreen.png"];
     67        [fProgressLightGreen setScalesWhenResized: YES];
     68       
    6669        fProgressAdvanced = [NSImage imageNamed: @"ProgressBarAdvanced.png"];
    6770        [fProgressAdvanced setScalesWhenResized: YES];
     
    9295
    9396    width -= 2.0;
    94     if ([[info objectForKey: @"Seeding"] boolValue])
    95     {
    96         [fProgressEndGreen compositeToPoint: point operation: NSCompositeSourceOver];
    97        
    98         point.x += 1.0;
    99         [self placeBar: fProgressGreen width: width point: point];
    100        
    101         point.x += width;
    102         [fProgressEndGreen compositeToPoint: point operation: NSCompositeSourceOver];
     97   
     98    BOOL seeding = [[info objectForKey: @"Seeding"] boolValue],
     99        isActive = [[info objectForKey: @"Active"] boolValue];
     100    float completedWidth, remainingWidth;
     101   
     102    //bar images
     103    NSImage * barLeftEnd, * barRightEnd, * barComplete, * barRemaining;
     104    if (seeding)
     105    {
     106        float stopRatio, ratio;
     107        if ((stopRatio = [[info objectForKey: @"StopRatio"] floatValue]) != INVALID
     108                && (ratio = [[info objectForKey: @"Ratio"] floatValue]) < stopRatio)
     109            completedWidth = width * ratio / stopRatio;
     110        else
     111            completedWidth = width;
     112        remainingWidth = width - completedWidth;
     113       
     114        barLeftEnd = fProgressEndGreen;
     115        barRightEnd = fProgressEndGreen;
     116        barComplete = fProgressGreen;
     117        barRemaining = fProgressLightGreen;
    103118    }
    104119    else
    105120    {
    106         float completedWidth = [[info objectForKey: @"Progress"] floatValue] * width,
    107                 remainingWidth = width - completedWidth;
    108         BOOL isActive = [[info objectForKey: @"Active"] boolValue];
    109        
    110         //left end
    111         NSImage * barLeftEnd;
     121        completedWidth = [[info objectForKey: @"Progress"] floatValue] * width;
     122        remainingWidth = width - completedWidth;
     123       
    112124        if (remainingWidth == width)
    113125            barLeftEnd = fProgressEndWhite;
     
    117129            barLeftEnd = fProgressEndGray;
    118130       
    119         [barLeftEnd compositeToPoint: point operation: NSCompositeSourceOver];
    120        
    121         //active bar
    122         point.x += 1.0;
    123         [self placeBar: isActive ? fProgressBlue : fProgressGray width: completedWidth point: point];
    124        
    125         //remaining bar
    126         point.x += completedWidth;
    127         [self placeBar: fProgressWhite width: remainingWidth point: point];
    128        
    129         //right end
    130         NSImage * barRightEnd;
    131131        if (completedWidth < width)
    132132            barRightEnd = fProgressEndWhite;
     
    136136            barRightEnd = fProgressEndGray;
    137137       
    138         point.x += remainingWidth;
    139         [barRightEnd compositeToPoint: point operation: NSCompositeSourceOver];
    140     }
     138        barComplete = isActive ? fProgressBlue : fProgressGray;
     139        barRemaining = fProgressWhite;
     140    }
     141   
     142    [barLeftEnd compositeToPoint: point operation: NSCompositeSourceOver];
     143   
     144    //active bar
     145    point.x += 1.0;
     146    [self placeBar: barComplete width: completedWidth point: point];
     147   
     148    //remaining bar
     149    point.x += completedWidth;
     150    [self placeBar: barRemaining width: remainingWidth point: point];
     151   
     152    point.x += remainingWidth;
     153    [barRightEnd compositeToPoint: point operation: NSCompositeSourceOver];
    141154}
    142155
Note: See TracChangeset for help on using the changeset viewer.