Changeset 2724
- Timestamp:
- Aug 11, 2007, 5:04:10 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/TorrentCell.m
r2723 r2724 51 51 - (NSImage *) advancedBarSimple; 52 52 53 - (NSRect) rectForTitleBasedOnMinimalStatusRect: (NSRect) statusRect inBounds: (NSRect) bounds; 54 - (NSRect) rectForProgressBasedOnTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds; 53 #warning rearrange 54 - (NSRect) rectForMinimalStatusRectWithString: (NSAttributedString *) string inBounds: (NSRect) bounds; 55 - (NSRect) rectForTitleBasedOnMinimalStatusRect: (NSRect) statusRect withString: (NSAttributedString *) string 56 inBounds: (NSRect) bounds; 57 - (NSRect) rectForProgressBasedOnTitleRect: (NSRect) titleRect withString: (NSAttributedString *) string inBounds: (NSRect) bounds; 55 58 - (NSRect) rectForBarBasedOnAboveRect: (NSRect) aboveRect inBounds: (NSRect) bounds; 56 - (NSRect) rectForStatusBasedOnProgressRect: (NSRect) progressRect inBounds: (NSRect) bounds; 59 - (NSRect) rectForStatusBasedOnProgressRect: (NSRect) progressRect withString: (NSAttributedString *) string 60 inBounds: (NSRect) bounds; 57 61 58 62 - (NSAttributedString *) attributedTitleWithColor: (NSColor *) color; … … 139 143 - (NSRect) titleRectForBounds: (NSRect) bounds 140 144 { 141 return [self rectForTitleBasedOnMinimalStatusRect: [self minimalStatusRectForBounds: bounds] inBounds: bounds]; 145 return [self rectForTitleBasedOnMinimalStatusRect: [self minimalStatusRectForBounds: bounds] 146 withString: [self attributedTitleWithColor: nil] inBounds: bounds]; 142 147 } 143 148 144 149 - (NSRect) minimalStatusRectForBounds: (NSRect) bounds 145 150 { 146 if (![fDefaults boolForKey: @"SmallView"])147 return NSZeroRect;148 149 151 Torrent * torrent = [self representedObject]; 150 NSString * string = ![fDefaults boolForKey: @"SmallStatusRegular"] && [torrent isActive]152 NSString * string = [torrent isActive] && ![fDefaults boolForKey: @"SmallStatusRegular"] 151 153 ? [torrent remainingTimeString] : [torrent shortStatusString]; 152 NSAttributedString * status = [self attributedStatusString: string withColor: nil]; 153 154 NSRect result = bounds; 155 result.size = [status size]; 156 157 result.origin.x += bounds.size.width - result.size.width - PADDING_HORIZONAL; 158 result.origin.y += PADDING_ABOVE_MIN_STATUS; 159 160 return result; 154 return [self rectForMinimalStatusRectWithString: [self attributedStatusString: string withColor: nil] inBounds: bounds]; 161 155 } 162 156 163 157 - (NSRect) progressRectForBounds: (NSRect) bounds 164 158 { 165 return [self rectForProgressBasedOnTitleRect: [self titleRectForBounds: bounds] inBounds: bounds]; 159 NSString * string = [[self representedObject] progressString]; 160 return [self rectForProgressBasedOnTitleRect: [self titleRectForBounds: bounds] 161 withString: [self attributedStatusString: string withColor: nil] inBounds: bounds]; 166 162 } 167 163 … … 175 171 - (NSRect) statusRectForBounds: (NSRect) bounds 176 172 { 177 return [self rectForStatusBasedOnProgressRect: [self progressRectForBounds: bounds] inBounds: bounds]; 178 } 179 180 - (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView 181 { 173 NSString * string = [[self representedObject] statusString]; 174 return [self rectForStatusBasedOnProgressRect: [self progressRectForBounds: bounds] 175 withString: [self attributedStatusString: string withColor: nil] inBounds: bounds]; 176 } 177 178 - (void) drawInteriorWithFrame: (NSRect) cellFrame inView: (NSView *) controlView 179 { 180 [super drawInteriorWithFrame: cellFrame inView: controlView]; 181 182 182 Torrent * torrent = [self representedObject]; 183 183 … … 221 221 222 222 //minimal status 223 NSRect minimalStatusRect = [self minimalStatusRectForBounds: cellFrame];223 NSRect minimalStatusRect; 224 224 if (minimal) 225 225 { 226 226 NSString * string = ![fDefaults boolForKey: @"SmallStatusRegular"] && [torrent isActive] 227 227 ? [torrent remainingTimeString] : [torrent shortStatusString]; 228 [[self attributedStatusString: string withColor: statusColor] drawInRect: minimalStatusRect]; 228 NSAttributedString * minimalString = [self attributedStatusString: string withColor: statusColor]; 229 minimalStatusRect = [self rectForMinimalStatusRectWithString: minimalString inBounds: cellFrame]; 230 231 [minimalString drawInRect: minimalStatusRect]; 229 232 } 230 233 231 234 //title 232 NSRect titleRect = [self rectForTitleBasedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame]; 233 [[self attributedTitleWithColor: titleColor] drawInRect: titleRect]; 235 NSAttributedString * titleString = [self attributedTitleWithColor: titleColor]; 236 NSRect titleRect = [self rectForTitleBasedOnMinimalStatusRect: minimalStatusRect withString: titleString inBounds: cellFrame]; 237 [titleString drawInRect: titleRect]; 234 238 235 239 //progress … … 237 241 if (!minimal) 238 242 { 239 progressRect = [self rectForProgressBasedOnTitleRect: titleRect inBounds: cellFrame]; 240 [[self attributedStatusString: [torrent progressString] withColor: statusColor] drawInRect: progressRect]; 243 NSAttributedString * progressString = [self attributedStatusString: [torrent progressString] withColor: statusColor]; 244 progressRect = [self rectForProgressBasedOnTitleRect: titleRect withString: progressString inBounds: cellFrame]; 245 [progressString drawInRect: progressRect]; 241 246 } 242 247 … … 249 254 if (!minimal) 250 255 { 251 NSRect statusRect = [self rectForStatusBasedOnProgressRect: progressRect inBounds: cellFrame]; 252 [[self attributedStatusString: [torrent statusString] withColor: statusColor] drawInRect: statusRect]; 256 NSAttributedString * statusString = [self attributedStatusString: [torrent statusString] withColor: statusColor]; 257 NSRect statusRect = [self rectForStatusBasedOnProgressRect: progressRect withString: statusString inBounds: cellFrame]; 258 [statusString drawInRect: statusRect]; 253 259 } 254 260 } … … 524 530 } 525 531 526 - (NSRect) rectForTitleBasedOnMinimalStatusRect: (NSRect) statusRect inBounds: (NSRect) bounds 532 - (NSRect) rectForMinimalStatusRectWithString: (NSAttributedString *) string inBounds: (NSRect) bounds 533 { 534 if (![fDefaults boolForKey: @"SmallView"]) 535 return NSZeroRect; 536 537 NSRect result = bounds; 538 result.size = [string size]; 539 540 result.origin.x += bounds.size.width - result.size.width - PADDING_HORIZONAL; 541 result.origin.y += PADDING_ABOVE_MIN_STATUS; 542 543 return result; 544 } 545 546 - (NSRect) rectForTitleBasedOnMinimalStatusRect: (NSRect) statusRect withString: (NSAttributedString *) string 547 inBounds: (NSRect) bounds 527 548 { 528 549 BOOL minimal = [fDefaults boolForKey: @"SmallView"]; 529 550 530 NSRect result = bounds;551 NSRect result = bounds; 531 552 532 553 result.origin.y += PADDING_ABOVE_TITLE; 533 554 result.origin.x += PADDING_HORIZONAL + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_TITLE; 534 555 535 result.size = [ [self attributedTitleWithColor: nil]size];556 result.size = [string size]; 536 557 result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL 537 558 - (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + statusRect.size.width : 0)); … … 540 561 } 541 562 542 - (NSRect) rectForProgressBasedOnTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds563 - (NSRect) rectForProgressBasedOnTitleRect: (NSRect) titleRect withString: (NSAttributedString *) string inBounds: (NSRect) bounds 543 564 { 544 565 if ([fDefaults boolForKey: @"SmallView"]) 545 566 return NSZeroRect; 546 567 547 NSSize progressSize = [ [self attributedStatusString: [[self representedObject] progressString] withColor: nil]size];568 NSSize progressSize = [string size]; 548 569 549 570 NSRect result = titleRect; 550 551 571 result.size.width = MIN(progressSize.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL); 552 572 … … 570 590 } 571 591 572 - (NSRect) rectForStatusBasedOnProgressRect: (NSRect) progressRect inBounds: (NSRect) bounds 592 - (NSRect) rectForStatusBasedOnProgressRect: (NSRect) progressRect withString: (NSAttributedString *) string 593 inBounds: (NSRect) bounds 573 594 { 574 595 if ([fDefaults boolForKey: @"SmallView"]) 575 596 return NSZeroRect; 576 597 577 NSSize statusSize = [ [self attributedStatusString: [[self representedObject] statusString] withColor: nil]size];598 NSSize statusSize = [string size]; 578 599 579 600 NSRect result = progressRect;
Note: See TracChangeset
for help on using the changeset viewer.