update filter correctly when switching from waiting to check state to seeding

This commit is contained in:
Mitchell Livingston 2007-05-29 21:56:38 +00:00
parent 0adeb9b2f6
commit 90f9a9c716
4 changed files with 64 additions and 44 deletions

View File

@ -1676,11 +1676,17 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[tempTorrents setArray: fTorrents];
//set buttons with counts
[fNoFilterButton setCount: [fTorrents count]];
[fDownloadFilterButton setCount: downloading];
[fSeedFilterButton setCount: seeding];
[fPauseFilterButton setCount: paused];
[fFilterBar replaceButtons];
BOOL change = NO;
if ([fNoFilterButton setCount: [fTorrents count]])
change = YES;
if ([fDownloadFilterButton setCount: downloading])
change = YES;
if ([fSeedFilterButton setCount: seeding])
change = YES;
if ([fPauseFilterButton setCount: paused])
change = YES;
if (change)
[fFilterBar replaceButtons];
NSString * searchString = [fSearchFilterField stringValue];
if ([searchString length] > 0)

View File

@ -34,7 +34,7 @@
NSTrackingRectTag fTrackingTag;
}
- (void) setCount: (int) count;
- (BOOL) setCount: (int) count;
- (void) setEnabled: (BOOL) enable;
- (void) resetBounds: (NSNotification *) notification;

View File

@ -25,6 +25,12 @@
#import "FilterBarButton.h"
#import "StringAdditions.h"
@interface FilterBarButton (Private)
- (NSImage *) badgeCount: (int) count color: (NSColor *) color;
@end
@implementation FilterBarButton
- (id) initWithCoder: (NSCoder *) coder
@ -64,46 +70,10 @@
[super dealloc];
}
- (NSImage *) badgeCount: (int) count color: (NSColor *) color
{
NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[[NSFontManager sharedFontManager] convertFont: [NSFont fontWithName: @"Lucida Grande" size: 10.0]
toHaveTrait: NSBoldFontMask], NSFontAttributeName, nil];
NSString * string = [NSString stringWithInt: count];
NSSize stringSize = [string sizeWithAttributes: attributes];
NSRect badgeRect = NSMakeRect(0, 0, stringSize.width + 6.0, stringSize.height);
//create badge part
NSImage * tempBadge = [[NSImage alloc] initWithSize: badgeRect.size];
NSBezierPath * bp = [NSBezierPath bezierPathWithOvalInRect: badgeRect];
[tempBadge lockFocus];
[color set];
[bp fill];
[tempBadge unlockFocus];
//create string part
NSImage * badge = [[NSImage alloc] initWithSize: badgeRect.size];
[badge lockFocus];
[string drawAtPoint: NSMakePoint((badgeRect.size.width - stringSize.width) * 0.5,
(badgeRect.size.height - stringSize.height) * 0.5) withAttributes: attributes];
[tempBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOut];
[badge unlockFocus];
[tempBadge release];
[attributes release];
return [badge autorelease];
}
- (void) setCount: (int) count
- (BOOL) setCount: (int) count
{
if (fCount == count)
return;
return NO;
fCount = count;
if (fButtonNormal)
@ -333,6 +303,8 @@
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
else
[self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim];
return YES;
}
- (void) mouseEntered: (NSEvent *) event
@ -382,3 +354,43 @@
}
@end
@implementation FilterBarButton (Private)
- (NSImage *) badgeCount: (int) count color: (NSColor *) color
{
NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[[NSFontManager sharedFontManager] convertFont: [NSFont fontWithName: @"Lucida Grande" size: 10.0]
toHaveTrait: NSBoldFontMask], NSFontAttributeName, nil];
NSString * string = [NSString stringWithInt: count];
NSSize stringSize = [string sizeWithAttributes: attributes];
NSRect badgeRect = NSMakeRect(0, 0, stringSize.width + 6.0, stringSize.height);
//create badge part
NSImage * tempBadge = [[NSImage alloc] initWithSize: badgeRect.size];
NSBezierPath * bp = [NSBezierPath bezierPathWithOvalInRect: badgeRect];
[tempBadge lockFocus];
[color set];
[bp fill];
[tempBadge unlockFocus];
//create string part
NSImage * badge = [[NSImage alloc] initWithSize: badgeRect.size];
[badge lockFocus];
[string drawAtPoint: NSMakePoint((badgeRect.size.width - stringSize.width) * 0.5,
(badgeRect.size.height - stringSize.height) * 0.5) withAttributes: attributes];
[tempBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOut];
[badge unlockFocus];
[tempBadge release];
[attributes release];
return [badge autorelease];
}
@end

View File

@ -381,6 +381,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[shortStatusString setString: tempString];
[remainingTimeString setString: tempString];
fChecking = YES;
break;
case TR_STATUS_CHECK: