From 4b190aa0c20947bf27f3eac2e88eb50822c22429 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 2 Jan 2011 17:11:41 +0000 Subject: [PATCH] separate the code for the filter and status bars --- Transmission.xcodeproj/project.pbxproj | 6 ++ macosx/Controller.m | 2 - macosx/FilterBarView.h | 32 +++++++ macosx/FilterBarView.m | 86 ++++++++++++++++++ macosx/Makefile.am | 2 + macosx/StatusBarView.h | 6 +- macosx/StatusBarView.m | 116 +++++++------------------ macosx/en.lproj/MainMenu.xib | 23 ++++- 8 files changed, 179 insertions(+), 94 deletions(-) create mode 100644 macosx/FilterBarView.h create mode 100644 macosx/FilterBarView.m diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index b8fa58152..eb678c084 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -193,6 +193,7 @@ A2623B4E0D3DC6DF0045D19A /* ActionHover.png in Resources */ = {isa = PBXBuildFile; fileRef = A2623B4D0D3DC6DF0045D19A /* ActionHover.png */; }; A263CFC010DD67670038DE27 /* InfoTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = A263CFBF10DD67670038DE27 /* InfoTextField.m */; }; A263D03E10DE6F010038DE27 /* Magnet.png in Resources */ = {isa = PBXBuildFile; fileRef = A263D03D10DE6F010038DE27 /* Magnet.png */; }; + A2661D6112D0E8D9004F69D5 /* FilterBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = A2661D3B12D0E51B004F69D5 /* FilterBarView.m */; }; A26AF21A0D2DA35A00FF7140 /* FileOutlineController.m in Sources */ = {isa = PBXBuildFile; fileRef = A26AF2190D2DA35A00FF7140 /* FileOutlineController.m */; }; A26AF27E0D2DBDDF00FF7140 /* AddWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A26AF27C0D2DBDDF00FF7140 /* AddWindow.xib */; }; A26AF2840D2DC27C00FF7140 /* AddWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A26AF2830D2DC27C00FF7140 /* AddWindowController.m */; }; @@ -697,6 +698,8 @@ A265A3BE0D25AE7800198AC8 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = macosx/es.lproj/Creator.xib; sourceTree = ""; }; A265A3C00D25AE7800198AC8 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = macosx/es.lproj/MainMenu.xib; sourceTree = ""; }; A265A3C20D25AE7800198AC8 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = macosx/es.lproj/PrefsWindow.xib; sourceTree = ""; }; + A2661D3A12D0E51A004F69D5 /* FilterBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilterBarView.h; path = macosx/FilterBarView.h; sourceTree = ""; }; + A2661D3B12D0E51B004F69D5 /* FilterBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FilterBarView.m; path = macosx/FilterBarView.m; sourceTree = ""; }; A26AF1040D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ru; path = macosx/ru.lproj/Creator.xib; sourceTree = ""; }; A26AF1050D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ru; path = macosx/ru.lproj/InfoPlist.strings; sourceTree = ""; }; A26AF1070D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ru; path = macosx/ru.lproj/Localizable.strings; sourceTree = ""; }; @@ -1061,6 +1064,8 @@ E138A9760C04D88F00C5426C /* ProgressGradients.m */, A21282A50CA6C66800EAEE0F /* StatusBarView.h */, A21282A60CA6C66800EAEE0F /* StatusBarView.m */, + A2661D3A12D0E51A004F69D5 /* FilterBarView.h */, + A2661D3B12D0E51B004F69D5 /* FilterBarView.m */, A2ED7D8D0CEF431B00970975 /* FilterButton.h */, A2ED7D8E0CEF431B00970975 /* FilterButton.m */, A2C89D5F0CFCBF57004CC2BC /* ButtonToolbarItem.m */, @@ -2166,6 +2171,7 @@ A209EBCE1142F2B4002B02D1 /* InfoFileViewController.m in Sources */, A209EBF91142FEEE002B02D1 /* InfoOptionsViewController.m in Sources */, A21F15AC11729A8B00CF5A9C /* AddMagnetWindowController.m in Sources */, + A2661D6112D0E8D9004F69D5 /* FilterBarView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macosx/Controller.m b/macosx/Controller.m index f2a6baed8..897d84265 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -391,8 +391,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy - (void) awakeFromNib { - [fFilterBar setIsFilter: YES]; - NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"TRMainToolbar"]; [toolbar setDelegate: self]; [toolbar setAllowsUserCustomization: YES]; diff --git a/macosx/FilterBarView.h b/macosx/FilterBarView.h new file mode 100644 index 000000000..bced50d4f --- /dev/null +++ b/macosx/FilterBarView.h @@ -0,0 +1,32 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2011 Transmission authors and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#import + +@interface FilterBarView : NSView +{ + NSGradient * fGradient; +} + +@end diff --git a/macosx/FilterBarView.m b/macosx/FilterBarView.m new file mode 100644 index 000000000..a634cf4c2 --- /dev/null +++ b/macosx/FilterBarView.m @@ -0,0 +1,86 @@ +/****************************************************************************** + * $Id$ + * + * Copyright (c) 2011 Transmission authors and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#import "FilterBarView.h" + +@implementation FilterBarView + +- (id) initWithFrame: (NSRect) rect +{ + if ((self = [super initWithFrame: rect])) + { + NSColor * lightColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 235.0/255.0 blue: 235.0/255.0 alpha: 1.0]; + NSColor * darkColor = [NSColor colorWithCalibratedRed: 205.0/255.0 green: 205.0/255.0 blue: 205.0/255.0 alpha: 1.0]; + fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; + } + return self; +} + +- (void) dealloc +{ + [fGradient release]; + [super dealloc]; +} + +- (BOOL) mouseDownCanMoveWindow +{ + return NO; +} + +- (void) drawRect: (NSRect) rect +{ + NSInteger count = 0; + NSRect gridRects[2]; + NSColor * colorRects[2]; + + NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0); + if ([[self window] isMainWindow]) + { + if (NSIntersectsRect(lineBorderRect, rect)) + { + gridRects[count] = lineBorderRect; + colorRects[count] = [NSColor whiteColor]; + ++count; + + rect.size.height -= 1.0; + } + } + + lineBorderRect.origin.y = 0.0; + if (NSIntersectsRect(lineBorderRect, rect)) + { + gridRects[count] = lineBorderRect; + colorRects[count] = [NSColor colorWithCalibratedWhite: 0.65 alpha: 1.0]; + ++count; + + rect.origin.y += 1.0; + rect.size.height -= 1.0; + } + + NSRectFillListWithColors(gridRects, colorRects, count); + + [fGradient drawInRect: rect angle: 270.0]; +} + +@end diff --git a/macosx/Makefile.am b/macosx/Makefile.am index 23628efcc..e32ae90fe 100644 --- a/macosx/Makefile.am +++ b/macosx/Makefile.am @@ -71,6 +71,8 @@ EXTRA_DIST = \ FileOutlineView.m \ FilePriorityCell.h \ FilePriorityCell.m \ + FilterBarView.h \ + FilterBarView.m \ FilterButton.h \ FilterButton.m \ GroupsController.h \ diff --git a/macosx/StatusBarView.h b/macosx/StatusBarView.h index 594353ec8..a7587f1c9 100644 --- a/macosx/StatusBarView.h +++ b/macosx/StatusBarView.h @@ -26,11 +26,7 @@ @interface StatusBarView : NSView { - BOOL fIsFilter; - NSGradient * fStatusGradient, * fFilterGradient; - NSColor * fGrayBorderColor; + NSGradient * fGradient; } -- (void) setIsFilter: (BOOL) isFilter; - @end diff --git a/macosx/StatusBarView.m b/macosx/StatusBarView.m index bea046bd8..339f645be 100644 --- a/macosx/StatusBarView.m +++ b/macosx/StatusBarView.m @@ -36,16 +36,9 @@ { if ((self = [super initWithFrame: rect])) { - fIsFilter = NO; - fGrayBorderColor = [[NSColor colorWithCalibratedRed: 171.0/255.0 green: 171.0/255.0 blue: 171.0/255.0 alpha: 1.0] retain]; - NSColor * lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0]; NSColor * darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0]; - fStatusGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; - - lightColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 235.0/255.0 blue: 235.0/255.0 alpha: 1.0]; - darkColor = [NSColor colorWithCalibratedRed: 205.0/255.0 green: 205.0/255.0 blue: 205.0/255.0 alpha: 1.0]; - fFilterGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; + fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reload) name: NSWindowDidBecomeMainNotification object: [self window]]; @@ -57,103 +50,58 @@ - (void) dealloc { - [fGrayBorderColor release]; - [fStatusGradient release]; - [fFilterGradient release]; + [fGradient release]; [super dealloc]; } - (BOOL) mouseDownCanMoveWindow { - return !fIsFilter; -} - -#warning get rid of asap -- (void) setIsFilter: (BOOL) isFilter -{ - fIsFilter = isFilter; + return YES; } - (void) drawRect: (NSRect) rect { - if (fIsFilter) + const BOOL active = [[self window] isMainWindow]; + + NSInteger count = 0; + NSRect gridRects[active ? 2 : 3]; + NSColor * colorRects[active ? 2 : 3]; + + NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0); + if (active) { - NSInteger count = 0; - NSRect gridRects[2]; - NSColor * colorRects[2]; - - NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0); - if ([[self window] isMainWindow]) - { - if (NSIntersectsRect(lineBorderRect, rect)) - { - gridRects[count] = lineBorderRect; - colorRects[count] = [NSColor whiteColor]; - ++count; - - rect.size.height -= 1.0; - } - } - - lineBorderRect.origin.y = 0.0; if (NSIntersectsRect(lineBorderRect, rect)) { gridRects[count] = lineBorderRect; - colorRects[count] = [NSColor colorWithCalibratedWhite: 0.65 alpha: 1.0]; + colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0]; ++count; - rect.origin.y += 1.0; rect.size.height -= 1.0; } - - NSRectFillListWithColors(gridRects, colorRects, count); - - [fFilterGradient drawInRect: rect angle: 270.0]; } + + lineBorderRect.origin.y = 0.0; + if (NSIntersectsRect(lineBorderRect, rect)) + { + gridRects[count] = lineBorderRect; + colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0] + : [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0]; + ++count; + + rect.origin.y += 1.0; + rect.size.height -= 1.0; + } + + if (active) + [fGradient drawInRect: rect angle: 270.0]; else { - const BOOL active = [[self window] isMainWindow]; - - NSInteger count = 0; - NSRect gridRects[active ? 2 : 3]; - NSColor * colorRects[active ? 2 : 3]; - - NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0); - if (active) - { - if (NSIntersectsRect(lineBorderRect, rect)) - { - gridRects[count] = lineBorderRect; - colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0]; - ++count; - - rect.size.height -= 1.0; - } - } - - lineBorderRect.origin.y = 0.0; - if (NSIntersectsRect(lineBorderRect, rect)) - { - gridRects[count] = lineBorderRect; - colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0] - : [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0]; - ++count; - - rect.origin.y += 1.0; - rect.size.height -= 1.0; - } - - if (active) - [fStatusGradient drawInRect: rect angle: 270.0]; - else - { - gridRects[count] = rect; - colorRects[count] = [NSColor colorWithCalibratedWhite: 0.85 alpha: 1.0]; - ++count; - } - - NSRectFillListWithColors(gridRects, colorRects, count); + gridRects[count] = rect; + colorRects[count] = [NSColor colorWithCalibratedWhite: 0.85 alpha: 1.0]; + ++count; } + + NSRectFillListWithColors(gridRects, colorRects, count); } @end diff --git a/macosx/en.lproj/MainMenu.xib b/macosx/en.lproj/MainMenu.xib index 22f2819ff..41effe4da 100644 --- a/macosx/en.lproj/MainMenu.xib +++ b/macosx/en.lproj/MainMenu.xib @@ -13,7 +13,7 @@ YES - + YES @@ -2168,6 +2168,7 @@ AAAAAAAAAAAAAAAAA 257 {{258, 4}, {64, 14}} + YES 67239424 @@ -2184,6 +2185,7 @@ AAAAAAAAAAAAAAAAA 257 {{336, 4}, {64, 14}} + YES 67239424 @@ -2212,6 +2214,7 @@ AAAAAAAAAAAAAAAAA {{325, 5}, {8, 12}} + YES 130560 @@ -2244,6 +2247,7 @@ AAAAAAAAAAAAAAAAA {{247, 5}, {8, 12}} + YES 130560 @@ -2264,6 +2268,7 @@ AAAAAAAAAAAAAAAAA 268 {{5, 2}, {103, 17}} + YES -2076049856 @@ -2328,11 +2333,12 @@ AAAAAAAAAAAAAAAAA {400, 21} + StatusBarView NSView - + 266 YES @@ -2603,7 +2609,8 @@ AAAAAAAAAAAAAAAAA {457, 23} - StatusBarView + + FilterBarView NSView @@ -7401,6 +7408,7 @@ AAAAAAAAAAAAAAAAA 2029.ImportedFromIB2 2031.IBPluginDependency 2031.ImportedFromIB2 + 2043.IBEditorWindowLastContentRect 2043.IBPluginDependency 2043.ImportedFromIB2 2044.IBPluginDependency @@ -8013,6 +8021,7 @@ AAAAAAAAAAAAAAAAA com.apple.InterfaceBuilder.CocoaPlugin + {{0, 952}, {118, 43}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -9291,6 +9300,14 @@ AAAAAAAAAAAAAAAAA macosx/FileOutlineView.h + + FilterBarView + NSView + + IBProjectSource + macosx/FilterBarView.h + + FilterButton NSButton