From ea8a9f39fe669a42b64781b59d9982297e2f1550 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 9 Aug 2007 18:55:22 +0000 Subject: [PATCH] patch from Nick Shanks to improve the filter bar --- AUTHORS | 1 + Transmission.xcodeproj/project.pbxproj | 38 +-- macosx/Controller.m | 6 +- macosx/Credits.rtf | 41 +-- macosx/FilterBarButton.h | 7 +- macosx/FilterBarButton.m | 354 ++++++++++---------- macosx/FilterBarView.m | 10 + macosx/Images/FilterButtonOverLeft.png | Bin 317 -> 0 bytes macosx/Images/FilterButtonOverMain.png | Bin 132 -> 0 bytes macosx/Images/FilterButtonOverRight.png | Bin 304 -> 0 bytes macosx/Images/FilterButtonPressedLeft.png | Bin 378 -> 0 bytes macosx/Images/FilterButtonPressedMain.png | Bin 129 -> 0 bytes macosx/Images/FilterButtonPressedRight.png | Bin 365 -> 0 bytes macosx/Images/FilterButtonSelectedLeft.png | Bin 367 -> 0 bytes macosx/Images/FilterButtonSelectedMain.png | Bin 131 -> 0 bytes macosx/Images/FilterButtonSelectedRight.png | Bin 359 -> 0 bytes 16 files changed, 204 insertions(+), 253 deletions(-) delete mode 100644 macosx/Images/FilterButtonOverLeft.png delete mode 100644 macosx/Images/FilterButtonOverMain.png delete mode 100644 macosx/Images/FilterButtonOverRight.png delete mode 100644 macosx/Images/FilterButtonPressedLeft.png delete mode 100644 macosx/Images/FilterButtonPressedMain.png delete mode 100644 macosx/Images/FilterButtonPressedRight.png delete mode 100644 macosx/Images/FilterButtonSelectedLeft.png delete mode 100644 macosx/Images/FilterButtonSelectedMain.png delete mode 100644 macosx/Images/FilterButtonSelectedRight.png diff --git a/AUTHORS b/AUTHORS index ed7e6064a..a87ae2716 100644 --- a/AUTHORS +++ b/AUTHORS @@ -57,6 +57,7 @@ Other Contributors Michael Demars (Mac OS X patches) Fredrik Modéen (BeOS patches) Deanna Phillips (transmissioncli manpage) + Nicholas Shanks (Mac OS X patches) Third-Party Resources Thanks to: diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 12fdb9938..448e6cf8d 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -70,7 +70,6 @@ A232D29E0A70903E00973B12 /* Filter.png in Resources */ = {isa = PBXBuildFile; fileRef = A232D29D0A70903E00973B12 /* Filter.png */; }; A2385DD40BFE06C800B24EF6 /* DragOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */; }; A23BBEB70A9BBE77003F7274 /* FilterBarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A27431D90A68538400FA780A /* FilterBarButton.m */; }; - A24103070AF80E390001C8D0 /* FilterButtonPressedLeft.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7140A699178008EE24F /* FilterButtonPressedLeft.png */; }; A241528B0C0261B8007DD3B4 /* Globe.png in Resources */ = {isa = PBXBuildFile; fileRef = A2FB06950BFF484A0095564D /* Globe.png */; }; A246004D0A6DCE4600D19088 /* SpeedLimitButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A246004C0A6DCE4600D19088 /* SpeedLimitButtonPressed.png */; }; A24600510A6DCE6600D19088 /* SpeedLimitButtonBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A246004F0A6DCE6600D19088 /* SpeedLimitButtonBlue.png */; }; @@ -81,14 +80,6 @@ A24F19080A3A790800C9C145 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; }; A24F19210A3A796800C9C145 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; }; A253F6F30A698970008EE24F /* FilterBarBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F6F20A698970008EE24F /* FilterBarBackground.png */; }; - A253F70B0A6990EB008EE24F /* FilterButtonOverMain.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7080A6990EB008EE24F /* FilterButtonOverMain.png */; }; - A253F70C0A6990EB008EE24F /* FilterButtonOverLeft.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7090A6990EB008EE24F /* FilterButtonOverLeft.png */; }; - A253F70D0A6990EB008EE24F /* FilterButtonOverRight.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F70A0A6990EB008EE24F /* FilterButtonOverRight.png */; }; - A253F7150A699178008EE24F /* FilterButtonPressedRight.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7120A699178008EE24F /* FilterButtonPressedRight.png */; }; - A253F7160A699178008EE24F /* FilterButtonPressedMain.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7130A699178008EE24F /* FilterButtonPressedMain.png */; }; - A253F72A0A699373008EE24F /* FilterButtonSelectedLeft.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7270A699373008EE24F /* FilterButtonSelectedLeft.png */; }; - A253F72B0A699373008EE24F /* FilterButtonSelectedMain.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7280A699373008EE24F /* FilterButtonSelectedMain.png */; }; - A253F72C0A699373008EE24F /* FilterButtonSelectedRight.png in Resources */ = {isa = PBXBuildFile; fileRef = A253F7290A699373008EE24F /* FilterButtonSelectedRight.png */; }; A256588D0A9A695400E8A03B /* MessageWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A256588B0A9A695400E8A03B /* MessageWindowController.m */; }; A259317E0A73B2CC002F4FE7 /* TransmissionHelp in Resources */ = {isa = PBXBuildFile; fileRef = A259316A0A73B2CC002F4FE7 /* TransmissionHelp */; }; A25E74650AF5097C006F11AE /* ExpandedPathToPathTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A25E74440AF5089E006F11AE /* ExpandedPathToPathTransformer.m */; }; @@ -322,7 +313,7 @@ 4DFBC2DD09C0970D00D5C571 /* Torrent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Torrent.h; path = macosx/Torrent.h; sourceTree = ""; }; 4DFBC2DE09C0970D00D5C571 /* Torrent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Torrent.m; path = macosx/Torrent.m; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = Info.plist; path = macosx/Info.plist; sourceTree = ""; }; - 8D1107320486CEB800E47090 /* Transmission.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Transmission.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D1107320486CEB800E47090 /* Transmission.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = Transmission.app; sourceTree = BUILT_PRODUCTS_DIR; }; A200B8390A2263BA007BBB1E /* InfoWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InfoWindowController.h; path = macosx/InfoWindowController.h; sourceTree = ""; }; A200B83A0A2263BA007BBB1E /* InfoWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InfoWindowController.m; path = macosx/InfoWindowController.m; sourceTree = ""; }; A200B9630A227FD0007BBB1E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = macosx/English.lproj/InfoWindow.nib; sourceTree = ""; }; @@ -393,15 +384,6 @@ A24D2A780C0A65C400A0ED9F /* ipcparse.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ipcparse.h; path = libtransmission/ipcparse.h; sourceTree = ""; }; A24F19070A3A790800C9C145 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = macosx/Sparkle.framework; sourceTree = ""; }; A253F6F20A698970008EE24F /* FilterBarBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterBarBackground.png; path = macosx/Images/FilterBarBackground.png; sourceTree = ""; }; - A253F7080A6990EB008EE24F /* FilterButtonOverMain.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonOverMain.png; path = macosx/Images/FilterButtonOverMain.png; sourceTree = ""; }; - A253F7090A6990EB008EE24F /* FilterButtonOverLeft.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonOverLeft.png; path = macosx/Images/FilterButtonOverLeft.png; sourceTree = ""; }; - A253F70A0A6990EB008EE24F /* FilterButtonOverRight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonOverRight.png; path = macosx/Images/FilterButtonOverRight.png; sourceTree = ""; }; - A253F7120A699178008EE24F /* FilterButtonPressedRight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonPressedRight.png; path = macosx/Images/FilterButtonPressedRight.png; sourceTree = ""; }; - A253F7130A699178008EE24F /* FilterButtonPressedMain.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonPressedMain.png; path = macosx/Images/FilterButtonPressedMain.png; sourceTree = ""; }; - A253F7140A699178008EE24F /* FilterButtonPressedLeft.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonPressedLeft.png; path = macosx/Images/FilterButtonPressedLeft.png; sourceTree = ""; }; - A253F7270A699373008EE24F /* FilterButtonSelectedLeft.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonSelectedLeft.png; path = macosx/Images/FilterButtonSelectedLeft.png; sourceTree = ""; }; - A253F7280A699373008EE24F /* FilterButtonSelectedMain.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonSelectedMain.png; path = macosx/Images/FilterButtonSelectedMain.png; sourceTree = ""; }; - A253F7290A699373008EE24F /* FilterButtonSelectedRight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonSelectedRight.png; path = macosx/Images/FilterButtonSelectedRight.png; sourceTree = ""; }; A256588A0A9A695400E8A03B /* MessageWindowController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MessageWindowController.h; path = macosx/MessageWindowController.h; sourceTree = ""; }; A256588B0A9A695400E8A03B /* MessageWindowController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MessageWindowController.m; path = macosx/MessageWindowController.m; sourceTree = ""; }; A259316A0A73B2CC002F4FE7 /* TransmissionHelp */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TransmissionHelp; path = macosx/TransmissionHelp; sourceTree = ""; }; @@ -767,15 +749,6 @@ A27A53560A06A76400E1F16F /* StatusSep.png */, A232D29D0A70903E00973B12 /* Filter.png */, A253F6F20A698970008EE24F /* FilterBarBackground.png */, - A253F7080A6990EB008EE24F /* FilterButtonOverMain.png */, - A253F7090A6990EB008EE24F /* FilterButtonOverLeft.png */, - A253F70A0A6990EB008EE24F /* FilterButtonOverRight.png */, - A253F7120A699178008EE24F /* FilterButtonPressedRight.png */, - A253F7130A699178008EE24F /* FilterButtonPressedMain.png */, - A253F7140A699178008EE24F /* FilterButtonPressedLeft.png */, - A253F7270A699373008EE24F /* FilterButtonSelectedLeft.png */, - A253F7280A699373008EE24F /* FilterButtonSelectedMain.png */, - A253F7290A699373008EE24F /* FilterButtonSelectedRight.png */, ); name = Resources; sourceTree = ""; @@ -1211,14 +1184,6 @@ A2F6DB090A55F31C0058D1E5 /* SpeedLimitButton.png in Resources */, A20AB97B0A5C622A004F81FA /* SmallTurtle.png in Resources */, A253F6F30A698970008EE24F /* FilterBarBackground.png in Resources */, - A253F70B0A6990EB008EE24F /* FilterButtonOverMain.png in Resources */, - A253F70C0A6990EB008EE24F /* FilterButtonOverLeft.png in Resources */, - A253F70D0A6990EB008EE24F /* FilterButtonOverRight.png in Resources */, - A253F7150A699178008EE24F /* FilterButtonPressedRight.png in Resources */, - A253F7160A699178008EE24F /* FilterButtonPressedMain.png in Resources */, - A253F72A0A699373008EE24F /* FilterButtonSelectedLeft.png in Resources */, - A253F72B0A699373008EE24F /* FilterButtonSelectedMain.png in Resources */, - A253F72C0A699373008EE24F /* FilterButtonSelectedRight.png in Resources */, A246004D0A6DCE4600D19088 /* SpeedLimitButtonPressed.png in Resources */, A24600510A6DCE6600D19088 /* SpeedLimitButtonBlue.png in Resources */, A24600520A6DCE6600D19088 /* SpeedLimitButtonGraphite.png in Resources */, @@ -1232,7 +1197,6 @@ 35B038140AC5B6EC00A10FDF /* ResumeNoWaitOff.png in Resources */, A29C8B330ACC6E93000ED9F9 /* YellowDot.tiff in Resources */, A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */, - A24103070AF80E390001C8D0 /* FilterButtonPressedLeft.png in Resources */, A241528B0C0261B8007DD3B4 /* Globe.png in Resources */, A2E9AA760C249AF400085DCF /* Create.png in Resources */, A2F011990C27418800576FC0 /* CreateLarge.png in Resources */, diff --git a/macosx/Controller.m b/macosx/Controller.m index cb2505a7c..e37def329 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -374,7 +374,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy currentFilterButton = fNoFilterButton; } - [currentFilterButton setEnabled: YES]; + [currentFilterButton setState: NSOnState]; //observe notifications NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; @@ -1836,8 +1836,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy if (sender != prevFilterButton) { - [prevFilterButton setEnabled: NO]; - [sender setEnabled: YES]; + [prevFilterButton setState: NSOffState]; + [sender setState: NSOnState]; NSString * filterType; if (sender == fDownloadFilterButton) diff --git a/macosx/Credits.rtf b/macosx/Credits.rtf index 8f979304e..eaa775407 100644 --- a/macosx/Credits.rtf +++ b/macosx/Credits.rtf @@ -64,45 +64,7 @@ Lead Developers \fs20 \cf2 (Korean)\ \fs24 \cf0 Anton Sotkov -\fs20 \cf2 (Russian)\ - -\fs24 \cf0 \ -GTK+:\ - Calor\'93 Alessandro -\fs20 \cf2 (Italian) -\fs24 \cf0 \ - Pierre-Henri Quelen -\fs20 \cf2 (French) -\fs24 \cf0 \ - Robert-Andr\'8e Mauchin -\fs20 \cf2 (French)\ - -\fs24 \cf0 Jan Geboers -\fs20 \cf2 (Dutch) -\fs24 \cf0 \ - Vicente Carro Fernandez -\fs20 \cf2 (Spanish) -\fs24 \cf0 \ - Tomasz Dominikowski -\fs20 \cf2 (Polish) -\fs24 \cf0 \ - Nickolay V. Shmyrev \fs20 \cf2 (Russian) -\fs24 \cf0 \ - Pavel Shevchuk -\fs20 \cf2 (Russian) -\fs24 \cf0 \ - Lubomir Marinov -\fs20 \cf2 (Bulgarian) -\fs24 \cf0 \ - Mircea Suciu -\fs20 \cf2 (Romanian) -\fs24 \cf0 \ - Daniel Nylander -\fs20 \cf2 (Swedish) -\fs24 \cf0 \ - Jaakko Huhtala -\fs20 \cf2 (Finnish) \fs24 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural \cf0 \ @@ -159,6 +121,9 @@ Image Contributors\ \fs24 \cf0 \ Deanna Phillips \fs20 \cf2 (transmissioncli manpage) +\fs24 \cf0 \ + Nicholas Shanks +\fs20 \cf2 (Mac OS X patches) \fs24 \cf0 \ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural \cf0 \ diff --git a/macosx/FilterBarButton.h b/macosx/FilterBarButton.h index b92049db0..0cf7e3bee 100644 --- a/macosx/FilterBarButton.h +++ b/macosx/FilterBarButton.h @@ -26,12 +26,13 @@ @interface FilterBarButton : NSButton { - NSImage * fButtonNormal, * fButtonNormalDim, * fButtonOver, - * fButtonPressed, * fButtonSelected, * fButtonSelectedDim; int fCount; - + int fState; BOOL fEnabled; NSTrackingRectTag fTrackingTag; + NSBezierPath * fPath, * fEdgePath, * fStepPath; + NSDictionary * fNormalAttributes, * fNormalDimAttributes, + * fHighlightedAttributes, * fHighlightedDimAttributes; } - (void) setCount: (int) count; diff --git a/macosx/FilterBarButton.m b/macosx/FilterBarButton.m index a71f33ed6..d7054b535 100644 --- a/macosx/FilterBarButton.m +++ b/macosx/FilterBarButton.m @@ -23,10 +23,14 @@ *****************************************************************************/ #import "FilterBarButton.h" +#import "CTGradient.h" +#import "CTGradientAdditions.h" +#import "BezierPathAdditions.h" @interface FilterBarButton (Private) -- (void) createButtons; +- (void) createPaths; +- (void) createFontAttributes; @end @@ -38,24 +42,15 @@ { fEnabled = NO; fTrackingTag = 0; - - [self createButtons]; - [self setAlternateImage: fButtonPressed]; - [self setImage: fButtonNormal]; - fCount = -1; [self setCount: 0]; + [self createPaths]; + [self createFontAttributes]; NSNotificationCenter * nc = [NSNotificationCenter defaultCenter]; - - [nc addObserver: self selector: @selector(setForActive:) - name: NSWindowDidBecomeKeyNotification object: [self window]]; - - [nc addObserver: self selector: @selector(setForInactive:) - name: NSWindowDidResignKeyNotification object: [self window]]; - - [nc addObserver: self selector: @selector(resetBounds:) - name: NSViewFrameDidChangeNotification object: nil]; + [nc addObserver: self selector: @selector(setForActive:) name: NSWindowDidBecomeKeyNotification object: [self window]]; + [nc addObserver: self selector: @selector(setForInactive:) name: NSWindowDidResignKeyNotification object: [self window]]; + [nc addObserver: self selector: @selector(resetBounds:) name: NSViewFrameDidChangeNotification object: nil]; } return self; } @@ -64,15 +59,97 @@ { [[NSNotificationCenter defaultCenter] removeObserver: self]; - [fButtonNormal release]; - [fButtonOver release]; - [fButtonPressed release]; - [fButtonSelected release]; - [fButtonSelectedDim release]; + [fPath release]; + [fEdgePath release]; + [fStepPath release]; + [fNormalAttributes release]; + [fNormalDimAttributes release]; + [fHighlightedAttributes release]; + [fHighlightedDimAttributes release]; [super dealloc]; } +- (void)sizeToFit +{ + NSSize size = [[self title] sizeWithAttributes: fNormalAttributes]; + size.width = floorf(size.width + 18.5); + size.height += 1; + [self setFrameSize: size]; + [self setBoundsSize: size]; + [self createPaths]; +} + +- (BOOL)isFlipped +{ + return NO; +} + +- (void)drawRect:(NSRect)rect +{ + // draw background + if ([[self cell] isHighlighted]) + { + [[CTGradient gradientWithBeginningColor: [NSColor colorWithCalibratedRed: 134.0/255 green: 151.0/255 + blue: 176.0/255 alpha: 1.0] + endingColor: [NSColor colorWithCalibratedRed: 104.0/255 green: 125.0/255 + blue: 157.0/255 alpha: 1.0]] + fillBezierPath: fPath angle: -90.0]; + [[CTGradient gradientWithBeginningColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.25] +// middleColor: [NSColor colorWithCalibratedWhite: 0.5 alpha: 0.00] + middleColor1: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.25] + middleColor2: [NSColor colorWithCalibratedWhite: 1.0 alpha: 0.50] + endingColor: [NSColor colorWithCalibratedWhite: 1.0 alpha: 0.50]] + fillBezierPath: fStepPath angle: -90.0]; + } + else switch (fState) + { + case 1: // active + [[CTGradient gradientWithBeginningColor: [NSColor colorWithCalibratedRed: 151.0/255 green: 166.0/255 + blue: 188.0/255 alpha: 1.0] + endingColor: [NSColor colorWithCalibratedRed: 126.0/255 green: 144.0/255 + blue: 171.0/255 alpha: 1.0]] + fillBezierPath: fPath angle: -90.0]; + [[CTGradient gradientWithBeginningColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.25] +// middleColor: [NSColor colorWithCalibratedWhite: 0.5 alpha: 0.00] + middleColor1: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.25] + middleColor2: [NSColor colorWithCalibratedWhite: 1.0 alpha: 0.50] + endingColor: [NSColor colorWithCalibratedWhite: 1.0 alpha: 0.50]] + fillBezierPath: fStepPath angle: -90.0]; + break; + case 2: // hovering + [[CTGradient gradientWithBeginningColor: [NSColor colorWithCalibratedRed: 164.0/255 green: 177.0/255 + blue: 196.0/255 alpha: 1.0] + endingColor: [NSColor colorWithCalibratedRed: 141.0/255 green: 158.0/255 + blue: 182.0/255 alpha: 1.0]] + fillBezierPath: fPath angle: -90.0]; + [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.075] set]; + [fEdgePath stroke]; + break; + case 3: // clicked but cell is not highlighted + break; + } + + // draw title + NSSize titleSize = [[self title] sizeWithAttributes: fNormalAttributes]; + NSPoint titlePos = NSMakePoint(([self bounds].size.width - titleSize.width) * 0.5, + ([self bounds].size.height - titleSize.height) * 0.5 + 1.5); + if (fEnabled) + { + if (fState && !(fState == 3 && ![[self cell] isHighlighted])) + [[self title] drawAtPoint: titlePos withAttributes: fHighlightedAttributes]; + else + [[self title] drawAtPoint: titlePos withAttributes: fNormalAttributes]; + } + else + { + if (fState) + [[self title] drawAtPoint: titlePos withAttributes: fHighlightedDimAttributes]; + else + [[self title] drawAtPoint: titlePos withAttributes: fNormalDimAttributes]; + } +} + - (void) setCount: (int) count { if (count == fCount) @@ -83,26 +160,49 @@ : [NSString stringWithFormat: NSLocalizedString(@"%d Transfers", "Filter Bar Button -> tool tip"), fCount]]; } +- (void) mouseDown: (NSEvent *) event +{ + if ([self state] != 1) + [self setState: 3]; + [super mouseDown: event]; +} + +- (void) mouseUp: (NSEvent *) event +{ + [super mouseUp: event]; + if ([self state] != 1) + [self setState: 1]; +} + - (void) mouseEntered: (NSEvent *) event { - if (!fEnabled) - [self setImage: fButtonOver]; - [super mouseEntered: event]; + if ([self state] == 0) + [self setState: 2]; } - (void) mouseExited: (NSEvent *) event { - if (!fEnabled) - [self setImage: fButtonNormal]; - [super mouseExited: event]; + if ([self state] >= 2) + [self setState: 0]; } - (void) setEnabled: (BOOL) enable { fEnabled = enable; - [self setImage: fEnabled ? fButtonSelected : fButtonNormal]; + [self setNeedsDisplay: YES]; +} + +- (int) state +{ + return fState; +} + +- (void) setState: (int) state +{ + fState = state; + [self setNeedsDisplay: YES]; } - (void) resetBounds: (NSNotification *) notification @@ -114,177 +214,87 @@ - (void) setForActive: (NSNotification *) notification { - [self setImage: fEnabled ? fButtonSelected : fButtonNormal]; + [self setEnabled: YES]; [self resetBounds: nil]; + [self setNeedsDisplay: YES]; } - (void) setForInactive: (NSNotification *) notification { - [self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim]; - if (fTrackingTag) { [self removeTrackingRect: fTrackingTag]; fTrackingTag = 0; } + [self setEnabled: NO]; + [self setNeedsDisplay: YES]; } @end @implementation FilterBarButton (Private) -- (void) createButtons +- (void) createPaths { - //create attributes - NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont: - [NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask]; + NSSize buttonSize = [self frame].size; + // the main button path + [fPath release]; + fPath = [[NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0.0, 1.0, buttonSize.width, buttonSize.height - 1.0) + radius: (buttonSize.height - 1.0) / 2.0] retain]; + + // the path used to draw the hover edging + [fEdgePath release]; + fEdgePath = [[NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0.5, 1.5, buttonSize.width - 1.0, buttonSize.height - 2.0) + radius: (buttonSize.height - 2.0) / 2.0] retain]; + + // the path used to draw the depressed shading/highlights of the active button + [fStepPath release]; + fStepPath = [[NSBezierPath bezierPathWithRoundedRect: NSMakeRect(0.0, 0.0, buttonSize.width, buttonSize.height - 1.0) + radius: (buttonSize.height - 1.0) / 2.0] retain]; + [fStepPath appendBezierPath: fPath]; + [fStepPath setWindingRule: NSEvenOddWindingRule]; +} + +- (void) createFontAttributes +{ + NSFont * boldSystemFont = [NSFont boldSystemFontOfSize: 12.0]; NSSize shadowOffset = NSMakeSize(0.0, -1.0); - NSShadow * shadowNormal = [NSShadow alloc]; - [shadowNormal setShadowOffset: shadowOffset]; - [shadowNormal setShadowBlurRadius: 1.0]; - [shadowNormal setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.4]]; - - NSShadow * shadowDim = [NSShadow alloc]; - [shadowDim setShadowOffset: shadowOffset]; - [shadowDim setShadowBlurRadius: 1.0]; - [shadowDim setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.2]]; + NSShadow * shadowNormal = [[[NSShadow alloc] init] autorelease]; + [shadowNormal setShadowOffset: shadowOffset]; + [shadowNormal setShadowBlurRadius: 1.0]; + [shadowNormal setShadowColor: [NSColor colorWithCalibratedWhite: 1.0 alpha: 0.4]]; - NSShadow * shadowHighlighted = [NSShadow alloc]; - [shadowHighlighted setShadowOffset: shadowOffset]; - [shadowHighlighted setShadowBlurRadius: 1.0]; - [shadowHighlighted setShadowColor: [NSColor colorWithDeviceWhite: 0.0 alpha: 0.4]]; + NSShadow * shadowNormalDim = [[[NSShadow alloc] init] autorelease]; + [shadowNormalDim setShadowOffset: shadowOffset]; + [shadowNormalDim setShadowBlurRadius: 1.0]; + [shadowNormalDim setShadowColor: [NSColor colorWithCalibratedWhite: 1.0 alpha: 0.2]]; - NSDictionary * normalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSColor colorWithCalibratedRed: 0.259 green: 0.259 blue: 0.259 alpha: 1.0], - NSForegroundColorAttributeName, - boldFont, NSFontAttributeName, - shadowNormal, NSShadowAttributeName, nil], - * normalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSColor disabledControlTextColor], NSForegroundColorAttributeName, - boldFont, NSFontAttributeName, - shadowDim, NSShadowAttributeName, nil], - * highlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSColor whiteColor], NSForegroundColorAttributeName, - boldFont, NSFontAttributeName, - shadowHighlighted, NSShadowAttributeName, nil], - * highlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0], NSForegroundColorAttributeName, - boldFont, NSFontAttributeName, - shadowHighlighted, NSShadowAttributeName, nil]; + NSShadow * shadowHighlighted = [[[NSShadow alloc] init] autorelease]; + [shadowHighlighted setShadowOffset: shadowOffset]; + [shadowHighlighted setShadowBlurRadius: 1.0]; + [shadowHighlighted setShadowColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.4]]; - [shadowNormal release]; - [shadowDim release]; - [shadowHighlighted release]; + fNormalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSColor colorWithCalibratedWhite: 0.259 alpha: 1.0], NSForegroundColorAttributeName, + boldSystemFont, NSFontAttributeName, + shadowNormal, NSShadowAttributeName, nil]; - //get images - NSImage * leftOver = [NSImage imageNamed: @"FilterButtonOverLeft.png"], - * rightOver = [NSImage imageNamed: @"FilterButtonOverRight.png"], - * mainOver = [NSImage imageNamed: @"FilterButtonOverMain.png"]; + fNormalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSColor disabledControlTextColor], NSForegroundColorAttributeName, + boldSystemFont, NSFontAttributeName, + shadowNormalDim, NSShadowAttributeName, nil]; - NSImage * leftPressed = [NSImage imageNamed: @"FilterButtonPressedLeft.png"], - * rightPressed = [NSImage imageNamed: @"FilterButtonPressedRight.png"], - * mainPressed = [NSImage imageNamed: @"FilterButtonPressedMain.png"]; + fHighlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSColor whiteColor], NSForegroundColorAttributeName, + boldSystemFont, NSFontAttributeName, + shadowHighlighted, NSShadowAttributeName, nil]; - NSImage * leftSelected = [NSImage imageNamed: @"FilterButtonSelectedLeft.png"], - * rightSelected = [NSImage imageNamed: @"FilterButtonSelectedRight.png"], - * mainSelected = [NSImage imageNamed: @"FilterButtonSelectedMain.png"]; - - //get button sizes and placement - NSString * text = [self title]; - NSSize textSize = [text sizeWithAttributes: normalAttributes]; - textSize.width = ceilf(textSize.width); - - float overlap = 7.0; - NSSize endSize = [leftOver size], - mainSize = NSMakeSize(textSize.width - overlap * 2.0, endSize.height), - buttonSize = NSMakeSize(mainSize.width + 2.0 * endSize.width, endSize.height); - NSRect textRect = NSMakeRect(endSize.width - overlap, (buttonSize.height - textSize.height) * 0.5 + 1.5, - textSize.width, textSize.height); - - NSPoint leftPoint = NSZeroPoint, - mainPoint = NSMakePoint(endSize.width, 0), - rightPoint = NSMakePoint(mainPoint.x + mainSize.width, 0); - - fButtonNormal = [[NSImage alloc] initWithSize: buttonSize]; - fButtonNormalDim = [[NSImage alloc] initWithSize: buttonSize]; - fButtonOver = [[NSImage alloc] initWithSize: buttonSize]; - fButtonPressed = [[NSImage alloc] initWithSize: buttonSize]; - fButtonSelected = [[NSImage alloc] initWithSize: buttonSize]; - fButtonSelectedDim = [[NSImage alloc] initWithSize: buttonSize]; - - //rolled over button - [mainOver setScalesWhenResized: YES]; - [mainOver setSize: mainSize]; - - [fButtonOver lockFocus]; - [leftOver compositeToPoint: leftPoint operation: NSCompositeSourceOver]; - [mainOver compositeToPoint: mainPoint operation: NSCompositeSourceOver]; - [rightOver compositeToPoint: rightPoint operation: NSCompositeSourceOver]; - [fButtonOver unlockFocus]; - - //pressed button - [mainPressed setScalesWhenResized: YES]; - [mainPressed setSize: mainSize]; - - [fButtonPressed lockFocus]; - [leftPressed compositeToPoint: leftPoint operation: NSCompositeSourceOver]; - [mainPressed compositeToPoint: mainPoint operation: NSCompositeSourceOver]; - [rightPressed compositeToPoint: rightPoint operation: NSCompositeSourceOver]; - [fButtonPressed unlockFocus]; - - //selected button - [mainSelected setScalesWhenResized: YES]; - [mainSelected setSize: mainSize]; - - [fButtonSelected lockFocus]; - [leftSelected compositeToPoint: leftPoint operation: NSCompositeSourceOver]; - [mainSelected compositeToPoint: mainPoint operation: NSCompositeSourceOver]; - [rightSelected compositeToPoint: rightPoint operation: NSCompositeSourceOver]; - [fButtonSelected unlockFocus]; - - //selected and dimmed button - fButtonSelectedDim = [fButtonSelected copy]; - - //normal button - [fButtonNormal lockFocus]; - [text drawInRect: textRect withAttributes: normalAttributes]; - [fButtonNormal unlockFocus]; - - //normal and dim button - [fButtonNormalDim lockFocus]; - [text drawInRect: textRect withAttributes: normalDimAttributes]; - [fButtonNormalDim unlockFocus]; - - //rolled over button - [fButtonOver lockFocus]; - [text drawInRect: textRect withAttributes: highlightedAttributes]; - [fButtonOver unlockFocus]; - - //pressed button - [fButtonPressed lockFocus]; - [text drawInRect: textRect withAttributes: highlightedAttributes]; - [fButtonPressed unlockFocus]; - - //selected button - [fButtonSelected lockFocus]; - [text drawInRect: textRect withAttributes: highlightedAttributes]; - [fButtonSelected unlockFocus]; - - //selected and dim button - [fButtonSelectedDim lockFocus]; - [text drawInRect: textRect withAttributes: highlightedDimAttributes]; - [fButtonSelectedDim unlockFocus]; - - [normalAttributes release]; - [normalDimAttributes release]; - [highlightedAttributes release]; - [highlightedDimAttributes release]; - - //resize button - NSPoint point = [self frame].origin; - [self setFrame: NSMakeRect(point.x, point.y, buttonSize.width, buttonSize.height)]; + fHighlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSColor colorWithCalibratedWhite: 0.9 alpha: 1.0], NSForegroundColorAttributeName, + boldSystemFont, NSFontAttributeName, + shadowHighlighted, NSShadowAttributeName, nil]; } @end diff --git a/macosx/FilterBarView.m b/macosx/FilterBarView.m index 16b441022..396e908d9 100644 --- a/macosx/FilterBarView.m +++ b/macosx/FilterBarView.m @@ -28,6 +28,16 @@ - (void) awakeFromNib { + [fNoFilterButton setTitle: NSLocalizedString(@"All", @"Filter Bar Button -> title")]; + [fDownloadFilterButton setTitle: NSLocalizedString(@"Downloading", @"Filter Bar Button -> title")]; + [fSeedFilterButton setTitle: NSLocalizedString(@"Seeding", @"Filter Bar Button -> title")]; + [fPauseFilterButton setTitle: NSLocalizedString(@"Paused", @"Filter Bar Button -> title")]; + + [fNoFilterButton sizeToFit]; + [fDownloadFilterButton sizeToFit]; + [fSeedFilterButton sizeToFit]; + [fPauseFilterButton sizeToFit]; + float padding = 2.0, base = 3.0; [fNoFilterButton setFrameOrigin: NSMakePoint(padding + 2.0, base)]; [fDownloadFilterButton setFrameOrigin: NSMakePoint(NSMaxX([fNoFilterButton frame]) + padding, base)]; diff --git a/macosx/Images/FilterButtonOverLeft.png b/macosx/Images/FilterButtonOverLeft.png deleted file mode 100644 index 6dd4e78041c69463e1583117e4e871e3d25589a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 317 zcmV-D0mA-?P)t!FA_donusAQcJ$ zd6ccpZt^T@jUm!aT{j!;hF&U_MP<3$C4yT@-j&%FDKl4u>0lSXBuaB3j cIp>NpIPO!=o`0}o9?%2^Pgg&ebxsLQ06)SgX#fBK diff --git a/macosx/Images/FilterButtonOverRight.png b/macosx/Images/FilterButtonOverRight.png deleted file mode 100644 index b80f77a384d719aafe173800470ad75b53439d6d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 304 zcmV-00nh%4P)k7R2UhJ!97yKU>JqboA7>;gz%3uF2K&p72CT87i1$U5&tSgTY`h7z_r3^E_)dyNAaW5VlUsvRFPfRapd}e^{-Xu&pjgO|uJIoj}|D zKEUe22ZxQi04YVZwz{}&>p>MpoecG05Xd^IZ4dLwa99^%qrcg0UH0db5fDbl_+(GV z)x~0#Qh?%ZyU~$|7?l0RY&;rPk^o6@eRZi5(6@Irpppr43N$1D0000Eh4=uKUq7lPpXzknA)FRBz3 zENK&LnrPC*rDl>DV~U_%Qa=vN&Bs4y!B@Qp^n*1TkH*f_^TSyrgun=+Uw|r}D2nP6ms?eGU>aDd{Qs>*+NN>ZF@;Prl$95JCgQAfI8VgTc`5HWKP&>! zF1p8@RqlpvCRK^5(ln!#T%MmCwVU=Nm_A2g{2|h8SzX*ROJ)2zZ`5_uXlfb&C9BPR Y0qzvE9r&wNbpQYW07*qoM6N<$f;Ekv$N&HU diff --git a/macosx/Images/FilterButtonPressedMain.png b/macosx/Images/FilterButtonPressedMain.png deleted file mode 100644 index e259651e652915a5bd68853818533d776de8432c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmeAS@N?(olHy`uVBq!ia0vp^j6f{N!2~2HFAQ`AQk(@Ik;M!Q+`=Ht$S`Y;1W?e} z)5S4_<9f2knRTg?rUa)wdMKRm>-&3o0b_%|e}D6zYrF7&#=iqkB>p)a`PcMR;#_LP{t@%hbKU6J2EG@swej41nT@ zNY2S{1W+8UqiRrKfZ_oq-(yXh))L@gHwb)>0nln9QuTB7ovra?%FwimQql0O4{QsZfn-9i#A@M<> zkU)#+LL+p$R@S0HD=|j8VKQ>gQHNswtiWKXoh**5 zM$Bw&iRcaby-uq!OR_Y}SNYnOyYmq+06=M-S$@>C9`pk#iO}1B<`bQww+JMnT!sJu N002ovPDHLkV1mkZpdbJM diff --git a/macosx/Images/FilterButtonSelectedMain.png b/macosx/Images/FilterButtonSelectedMain.png deleted file mode 100644 index 5e909459f81f6faa36532df409e9bb1c6eed0f98..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131 zcmeAS@N?(olHy`uVBq!ia0vp^j6f{N!2~2HFAQ`AQk(@Ik;M!Q+`=Ht$S`Y;1W?e_ z)5S4_<9hN5-R#s!fg!1n9*Zaa`u<-2^8b3C1gW0?$~Wr&|7E}AV8`t7M}Ed%d5<~! ae=#uh3aG_6irfboz~JfX=d#Wzp$PyhwLiPDf@WaTYBm|Ne#hjXD4 z6IaAULkx)*VuIYt%zt#l0txi{)YbJ3ZSXv=UQ4>&<1A~@3TK@z{Uc(nna^jpcfHra z;Oz87YfVI4jcT+`{s6|9pfVkOkM4Vqmlx++R~&2*5mJg>Hwbl-?*Gh|{r`UT6a#OJk<lnZY0ZV9)>n002ovPDHLk FV1gqym`(ry