mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
get rid of the numbers next to the filter...have them in tooltips instead
This commit is contained in:
parent
892d9bf156
commit
1152c69bcf
6 changed files with 64 additions and 196 deletions
|
@ -208,8 +208,6 @@
|
|||
- (void) setWindowSizeToFit;
|
||||
- (NSRect) sizedWindowFrame;
|
||||
|
||||
- (void) checkSearchFilter: (NSNotification *) notification;
|
||||
|
||||
- (void) showMainWindow: (id) sender;
|
||||
- (void) linkHomepage: (id) sender;
|
||||
- (void) linkForums: (id) sender;
|
||||
|
|
|
@ -210,7 +210,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[fBottomBar setBackgroundImage: [NSImage imageNamed: @"BottomBorder.png"]];
|
||||
[fStatusBar setBackgroundImage: [NSImage imageNamed: @"StatusBarBackground.png"]];
|
||||
[fFilterBar setBackgroundImage: [NSImage imageNamed: @"FilterBarBackground.png"]];
|
||||
[fFilterBar replaceButtons];
|
||||
|
||||
[fWindow setAcceptsMouseMovedEvents: YES]; //ensure filter buttons display correctly
|
||||
[fWindow addChildWindow: fOverlayWindow ordered: NSWindowAbove];
|
||||
|
@ -415,10 +414,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
//change that just impacts the dock badge
|
||||
[nc addObserver: self selector: @selector(updateDockBadge:)
|
||||
name: @"DockBadgeChange" object: nil];
|
||||
|
||||
//show and hide the search bar in the filter bar
|
||||
[nc addObserver: self selector: @selector(checkSearchFilter:)
|
||||
name: @"CheckSearchFilter" object: nil];
|
||||
|
||||
//timer to update the interface every second
|
||||
[self updateUI];
|
||||
|
@ -1677,17 +1672,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[tempTorrents setArray: fTorrents];
|
||||
|
||||
//set buttons with counts
|
||||
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];
|
||||
[fNoFilterButton setCount: [fTorrents count]];
|
||||
[fDownloadFilterButton setCount: downloading];
|
||||
[fSeedFilterButton setCount: seeding];
|
||||
[fPauseFilterButton setCount: paused];
|
||||
|
||||
NSString * searchString = [fSearchFilterField stringValue];
|
||||
if ([searchString length] > 0)
|
||||
|
@ -2977,11 +2965,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
|
||||
- (void) windowDidResize: (NSNotification *) notification
|
||||
{
|
||||
[self checkSearchFilter: nil];
|
||||
}
|
||||
|
||||
- (void) checkSearchFilter: (NSNotification *) notification
|
||||
{
|
||||
//size search filter to not overlap buttons
|
||||
float pointX = NSMaxX([fPauseFilterButton frame]) + 5.0;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
NSTrackingRectTag fTrackingTag;
|
||||
}
|
||||
|
||||
- (BOOL) setCount: (int) count;
|
||||
- (void) setCount: (int) count;
|
||||
- (void) setEnabled: (BOOL) enable;
|
||||
|
||||
- (void) resetBounds: (NSNotification *) notification;
|
||||
|
|
|
@ -23,11 +23,10 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import "FilterBarButton.h"
|
||||
#import "StringAdditions.h"
|
||||
|
||||
@interface FilterBarButton (Private)
|
||||
|
||||
- (NSImage *) badgeCount: (int) count color: (NSColor *) color;
|
||||
- (void) createButtons;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -40,8 +39,10 @@
|
|||
fEnabled = NO;
|
||||
fTrackingTag = 0;
|
||||
|
||||
fCount = -1;
|
||||
[self createButtons];
|
||||
[self setCount: 0];
|
||||
[self setAlternateImage: fButtonPressed];
|
||||
[self setImage: fButtonNormal];
|
||||
|
||||
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
|
@ -70,21 +71,64 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) setCount: (int) count
|
||||
- (void) setCount: (int) count
|
||||
{
|
||||
if (fCount == count)
|
||||
return NO;
|
||||
fCount = count;
|
||||
[self setToolTip: count == 1 ? NSLocalizedString(@"1 Transfer", "Filter Bar Button -> tool tip")
|
||||
: [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), count]];
|
||||
}
|
||||
|
||||
- (void) mouseEntered: (NSEvent *) event
|
||||
{
|
||||
if (!fEnabled)
|
||||
[self setImage: fButtonOver];
|
||||
|
||||
if (fButtonNormal)
|
||||
[super mouseEntered: event];
|
||||
}
|
||||
|
||||
- (void) mouseExited: (NSEvent *) event
|
||||
{
|
||||
if (!fEnabled)
|
||||
[self setImage: fButtonNormal];
|
||||
|
||||
[super mouseExited: event];
|
||||
}
|
||||
|
||||
- (void) setEnabled: (BOOL) enable
|
||||
{
|
||||
fEnabled = enable;
|
||||
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
||||
}
|
||||
|
||||
- (void) resetBounds: (NSNotification *) notification
|
||||
{
|
||||
if (fTrackingTag)
|
||||
[self removeTrackingRect: fTrackingTag];
|
||||
fTrackingTag = [self addTrackingRect: [self bounds] owner: self userData: nil assumeInside: NO];
|
||||
}
|
||||
|
||||
- (void) setForActive: (NSNotification *) notification
|
||||
{
|
||||
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
||||
[self resetBounds: nil];
|
||||
}
|
||||
|
||||
- (void) setForInactive: (NSNotification *) notification
|
||||
{
|
||||
[self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim];
|
||||
|
||||
if (fTrackingTag)
|
||||
{
|
||||
[fButtonNormal release];
|
||||
[fButtonOver release];
|
||||
[fButtonPressed release];
|
||||
[fButtonSelected release];
|
||||
[fButtonSelectedDim release];
|
||||
[self removeTrackingRect: fTrackingTag];
|
||||
fTrackingTag = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FilterBarButton (Private)
|
||||
|
||||
- (void) createButtons
|
||||
{
|
||||
//create attributes
|
||||
NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
|
||||
[NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
|
||||
|
@ -156,28 +200,6 @@
|
|||
NSRect textRect = NSMakeRect(endSize.width - overlap, (buttonSize.height - textSize.height) * 0.5 + 1.5,
|
||||
textSize.width, textSize.height);
|
||||
|
||||
//create badge images and adjust size
|
||||
NSImage * badgeNormal, * badgeNormalDim, * badgeHighlighted, * badgeHighlightedDim;
|
||||
NSSize badgeSize;
|
||||
float badgePadding;
|
||||
if (fCount > 0)
|
||||
{
|
||||
badgeNormal = [self badgeCount: fCount color: [normalAttributes objectForKey: NSForegroundColorAttributeName]];
|
||||
badgeNormalDim = [self badgeCount: fCount color: [normalDimAttributes objectForKey: NSForegroundColorAttributeName]];
|
||||
badgeHighlighted = [self badgeCount: fCount
|
||||
color: [highlightedAttributes objectForKey: NSForegroundColorAttributeName]];
|
||||
badgeHighlightedDim = [self badgeCount: fCount
|
||||
color: [highlightedDimAttributes objectForKey: NSForegroundColorAttributeName]];
|
||||
|
||||
badgeSize = [badgeNormal size];
|
||||
badgeSize.width = ceilf(badgeSize.width);
|
||||
|
||||
badgePadding = 2.0;
|
||||
float increase = badgeSize.width + badgePadding;
|
||||
mainSize.width += increase;
|
||||
buttonSize.width += increase;
|
||||
}
|
||||
|
||||
NSPoint leftPoint = NSZeroPoint,
|
||||
mainPoint = NSMakePoint(endSize.width, 0),
|
||||
rightPoint = NSMakePoint(mainPoint.x + mainSize.width, 0);
|
||||
|
@ -252,41 +274,6 @@
|
|||
[text drawInRect: textRect withAttributes: highlightedDimAttributes];
|
||||
[fButtonSelectedDim unlockFocus];
|
||||
|
||||
//append count
|
||||
if (fCount > 0)
|
||||
{
|
||||
NSPoint badgePoint = NSMakePoint(NSMaxX(textRect) + badgePadding * 2.0, (mainSize.height - badgeSize.height) * 0.5 + 1.0);
|
||||
|
||||
//normal button
|
||||
[fButtonNormal lockFocus];
|
||||
[badgeNormal compositeToPoint: badgePoint operation: NSCompositeSourceOver];
|
||||
[fButtonNormal unlockFocus];
|
||||
|
||||
//dim button
|
||||
[fButtonNormalDim lockFocus];
|
||||
[badgeNormalDim compositeToPoint: badgePoint operation: NSCompositeSourceOver];
|
||||
[fButtonNormalDim unlockFocus];
|
||||
|
||||
//rolled over button
|
||||
[fButtonOver lockFocus];
|
||||
[badgeHighlighted compositeToPoint: badgePoint operation: NSCompositeSourceOver];
|
||||
[fButtonOver unlockFocus];
|
||||
|
||||
[fButtonPressed lockFocus];
|
||||
[badgeHighlighted compositeToPoint: badgePoint operation: NSCompositeSourceOver];
|
||||
[fButtonPressed unlockFocus];
|
||||
|
||||
//selected button
|
||||
[fButtonSelected lockFocus];
|
||||
[badgeHighlighted compositeToPoint: badgePoint operation: NSCompositeSourceOver];
|
||||
[fButtonSelected unlockFocus];
|
||||
|
||||
//selected and dim button
|
||||
[fButtonSelectedDim lockFocus];
|
||||
[badgeHighlightedDim compositeToPoint: badgePoint operation: NSCompositeSourceOver];
|
||||
[fButtonSelectedDim unlockFocus];
|
||||
}
|
||||
|
||||
[normalAttributes release];
|
||||
[normalDimAttributes release];
|
||||
[highlightedAttributes release];
|
||||
|
@ -295,102 +282,6 @@
|
|||
//resize button
|
||||
NSPoint point = [self frame].origin;
|
||||
[self setFrame: NSMakeRect(point.x, point.y, buttonSize.width, buttonSize.height)];
|
||||
|
||||
//set image
|
||||
[self setAlternateImage: fButtonPressed];
|
||||
|
||||
if ([[self window] isKeyWindow])
|
||||
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
||||
else
|
||||
[self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) mouseEntered: (NSEvent *) event
|
||||
{
|
||||
if (!fEnabled)
|
||||
[self setImage: fButtonOver];
|
||||
|
||||
[super mouseEntered: event];
|
||||
}
|
||||
|
||||
- (void) mouseExited: (NSEvent *) event
|
||||
{
|
||||
if (!fEnabled)
|
||||
[self setImage: fButtonNormal];
|
||||
|
||||
[super mouseExited: event];
|
||||
}
|
||||
|
||||
- (void) setEnabled: (BOOL) enable
|
||||
{
|
||||
fEnabled = enable;
|
||||
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
||||
}
|
||||
|
||||
- (void) resetBounds: (NSNotification *) notification
|
||||
{
|
||||
if (fTrackingTag)
|
||||
[self removeTrackingRect: fTrackingTag];
|
||||
fTrackingTag = [self addTrackingRect: [self bounds] owner: self userData: nil assumeInside: NO];
|
||||
}
|
||||
|
||||
- (void) setForActive: (NSNotification *) notification
|
||||
{
|
||||
[self setImage: fEnabled ? fButtonSelected : fButtonNormal];
|
||||
[self resetBounds: nil];
|
||||
}
|
||||
|
||||
- (void) setForInactive: (NSNotification *) notification
|
||||
{
|
||||
[self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim];
|
||||
|
||||
if (fTrackingTag)
|
||||
{
|
||||
[self removeTrackingRect: fTrackingTag];
|
||||
fTrackingTag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
|
|
|
@ -32,6 +32,4 @@
|
|||
* fSeedFilterButton, * fPauseFilterButton;
|
||||
}
|
||||
|
||||
- (void) replaceButtons;
|
||||
|
||||
@end
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
@implementation FilterBarView
|
||||
|
||||
- (void) replaceButtons
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
float padding = 2.0, base = 3.0;
|
||||
[fNoFilterButton setFrameOrigin: NSMakePoint(padding + 2.0, base)];
|
||||
|
@ -35,8 +35,6 @@
|
|||
[fPauseFilterButton setFrameOrigin: NSMakePoint(NSMaxX([fSeedFilterButton frame]) + padding, base)];
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"CheckSearchFilter" object: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue