Changeset 9048
- Timestamp:
- Sep 7, 2009, 5:40:09 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/TorrentCell.m
r9045 r9048 586 586 Torrent * torrent = [self representedObject]; 587 587 588 NSRect leftRect, rightRect; 589 NSDivideRect(barRect, &leftRect, &rightRect, [torrent progress] * NSWidth(barRect), NSMinXEdge); 590 591 //don't-have section 592 if (!NSIsEmptyRect(rightRect)) 593 { 594 NSRect unwantedRect = rightRect; 595 596 if (![torrent allDownloaded]) 597 { 598 //the ratio of total progress to total width equals ratio of progress of amount wanted to wanted width 599 const CGFloat widthRemaining = NSWidth(barRect) * (1.0 - [torrent progressDone]) / [torrent progress]; 600 601 NSRect wantedRect; 602 NSDivideRect(rightRect, &wantedRect, &unwantedRect, widthRemaining, NSMinXEdge); 603 604 if (!NSIsEmptyRect(wantedRect)) 605 { 606 //not-available section 607 if ([torrent isActive] && ![torrent isChecking] && [fDefaults boolForKey: @"DisplayProgressBarAvailable"]) 608 { 609 NSRect unavailableRect; 610 NSDivideRect(wantedRect, &wantedRect, &unavailableRect, [torrent availableDesired] * NSWidth(wantedRect), NSMinXEdge); 611 612 [[ProgressGradients progressRedGradient] drawInRect: unavailableRect angle: 90]; 613 } 614 615 //remaining section 616 [[ProgressGradients progressWhiteGradient] drawInRect: wantedRect angle: 90]; 617 } 618 } 619 620 //unwanted section 621 [[ProgressGradients progressLightGrayGradient] drawInRect: unwantedRect angle: 90]; 622 } 623 624 if (!NSIsEmptyRect(leftRect)) 588 NSRect haveRect, missingRect; 589 NSDivideRect(barRect, &haveRect, &missingRect, floorf([torrent progress] * NSWidth(barRect)), NSMinXEdge); 590 591 if (!NSIsEmptyRect(haveRect)) 625 592 { 626 593 if ([torrent isActive]) 627 594 { 628 595 if ([torrent isChecking]) 629 [[ProgressGradients progressYellowGradient] drawInRect: leftRect angle: 90];596 [[ProgressGradients progressYellowGradient] drawInRect: haveRect angle: 90]; 630 597 else if ([torrent isSeeding]) 631 598 { 632 599 NSRect ratioHaveRect, ratioRemainingRect; 633 NSDivideRect(leftRect, &ratioHaveRect, &ratioRemainingRect, [torrent progressStopRatio] * NSWidth(leftRect), NSMinXEdge); 600 NSDivideRect(haveRect, &ratioHaveRect, &ratioRemainingRect, floorf([torrent progressStopRatio] * NSWidth(haveRect)), 601 NSMinXEdge); 634 602 635 603 [[ProgressGradients progressGreenGradient] drawInRect: ratioHaveRect angle: 90]; … … 637 605 } 638 606 else 639 [[ProgressGradients progressBlueGradient] drawInRect: leftRect angle: 90];607 [[ProgressGradients progressBlueGradient] drawInRect: haveRect angle: 90]; 640 608 } 641 609 else … … 643 611 if ([torrent waitingToStart]) 644 612 { 645 if ([torrent progressDone] == 0.0)646 [[ProgressGradients progressDarkGreenGradient] drawInRect: leftRect angle: 90];613 if ([torrent allDownloaded]) 614 [[ProgressGradients progressDarkGreenGradient] drawInRect: haveRect angle: 90]; 647 615 else 648 [[ProgressGradients progressDarkBlueGradient] drawInRect: leftRect angle: 90];616 [[ProgressGradients progressDarkBlueGradient] drawInRect: haveRect angle: 90]; 649 617 } 650 618 else 651 [[ProgressGradients progressGrayGradient] drawInRect: leftRect angle: 90];619 [[ProgressGradients progressGrayGradient] drawInRect: haveRect angle: 90]; 652 620 } 621 } 622 623 if (!NSIsEmptyRect(missingRect)) 624 { 625 if (![torrent allDownloaded]) 626 { 627 //the ratio of total progress to total width equals ratio of progress of amount wanted to wanted width 628 const CGFloat widthRemaining = floorf(NSWidth(barRect) * (1.0 - [torrent progressDone]) / [torrent progress]); 629 630 NSRect wantedRect; 631 NSDivideRect(missingRect, &wantedRect, &missingRect, widthRemaining, NSMinXEdge); 632 633 //not-available section 634 if ([torrent isActive] && ![torrent isChecking] && [fDefaults boolForKey: @"DisplayProgressBarAvailable"]) 635 { 636 NSRect unavailableRect; 637 NSDivideRect(wantedRect, &wantedRect, &unavailableRect, floorf([torrent availableDesired] * NSWidth(wantedRect)), 638 NSMinXEdge); 639 640 [[ProgressGradients progressRedGradient] drawInRect: unavailableRect angle: 90]; 641 } 642 643 //remaining section 644 [[ProgressGradients progressWhiteGradient] drawInRect: wantedRect angle: 90]; 645 } 646 647 //unwanted section 648 [[ProgressGradients progressLightGrayGradient] drawInRect: missingRect angle: 90]; 653 649 } 654 650 }
Note: See TracChangeset
for help on using the changeset viewer.