separate the code for the filter and status bars

This commit is contained in:
Mitchell Livingston 2011-01-02 17:11:41 +00:00
parent ae2a3ab268
commit 4b190aa0c2
8 changed files with 179 additions and 94 deletions

View File

@ -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 = "<group>"; };
A265A3C00D25AE7800198AC8 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = macosx/es.lproj/MainMenu.xib; sourceTree = "<group>"; };
A265A3C20D25AE7800198AC8 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = macosx/es.lproj/PrefsWindow.xib; sourceTree = "<group>"; };
A2661D3A12D0E51A004F69D5 /* FilterBarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FilterBarView.h; path = macosx/FilterBarView.h; sourceTree = "<group>"; };
A2661D3B12D0E51B004F69D5 /* FilterBarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FilterBarView.m; path = macosx/FilterBarView.m; sourceTree = "<group>"; };
A26AF1040D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ru; path = macosx/ru.lproj/Creator.xib; sourceTree = "<group>"; };
A26AF1050D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ru; path = macosx/ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A26AF1070D2855FC00FF7140 /* ru */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ru; path = macosx/ru.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -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;
};

View File

@ -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];

32
macosx/FilterBarView.h Normal file
View File

@ -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 <Cocoa/Cocoa.h>
@interface FilterBarView : NSView
{
NSGradient * fGradient;
}
@end

86
macosx/FilterBarView.m Normal file
View File

@ -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

View File

@ -71,6 +71,8 @@ EXTRA_DIST = \
FileOutlineView.m \
FilePriorityCell.h \
FilePriorityCell.m \
FilterBarView.h \
FilterBarView.m \
FilterButton.h \
FilterButton.m \
GroupsController.h \

View File

@ -26,11 +26,7 @@
@interface StatusBarView : NSView
{
BOOL fIsFilter;
NSGradient * fStatusGradient, * fFilterGradient;
NSColor * fGrayBorderColor;
NSGradient * fGradient;
}
- (void) setIsFilter: (BOOL) isFilter;
@end

View File

@ -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

View File

@ -13,7 +13,7 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="2"/>
<integer value="1480"/>
<integer value="1603"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -2168,6 +2168,7 @@ AAAAAAAAAAAAAAAAA</bytes>
<int key="NSvFlags">257</int>
<string key="NSFrame">{{258, 4}, {64, 14}}</string>
<reference key="NSSuperview" ref="492482618"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="7712611">
<int key="NSCellFlags">67239424</int>
@ -2184,6 +2185,7 @@ AAAAAAAAAAAAAAAAA</bytes>
<int key="NSvFlags">257</int>
<string key="NSFrame">{{336, 4}, {64, 14}}</string>
<reference key="NSSuperview" ref="492482618"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="551795479">
<int key="NSCellFlags">67239424</int>
@ -2212,6 +2214,7 @@ AAAAAAAAAAAAAAAAA</bytes>
</object>
<string key="NSFrame">{{325, 5}, {8, 12}}</string>
<reference key="NSSuperview" ref="492482618"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="507285438">
<int key="NSCellFlags">130560</int>
@ -2244,6 +2247,7 @@ AAAAAAAAAAAAAAAAA</bytes>
</object>
<string key="NSFrame">{{247, 5}, {8, 12}}</string>
<reference key="NSSuperview" ref="492482618"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSImageCell" key="NSCell" id="268918248">
<int key="NSCellFlags">130560</int>
@ -2264,6 +2268,7 @@ AAAAAAAAAAAAAAAAA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{5, 2}, {103, 17}}</string>
<reference key="NSSuperview" ref="492482618"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="9693266">
<int key="NSCellFlags">-2076049856</int>
@ -2328,11 +2333,12 @@ AAAAAAAAAAAAAAAAA</bytes>
</object>
<string key="NSFrameSize">{400, 21}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<string key="NSClassName">StatusBarView</string>
<string key="NSExtension">NSView</string>
</object>
<object class="NSCustomView" id="793806362">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">266</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -2603,7 +2609,8 @@ AAAAAAAAAAAAAAAAA</bytes>
</object>
</object>
<string key="NSFrameSize">{457, 23}</string>
<string key="NSClassName">StatusBarView</string>
<reference key="NSSuperview"/>
<string key="NSClassName">FilterBarView</string>
<string key="NSExtension">NSView</string>
</object>
<object class="NSCustomObject" id="456998591">
@ -7401,6 +7408,7 @@ AAAAAAAAAAAAAAAAA</bytes>
<string>2029.ImportedFromIB2</string>
<string>2031.IBPluginDependency</string>
<string>2031.ImportedFromIB2</string>
<string>2043.IBEditorWindowLastContentRect</string>
<string>2043.IBPluginDependency</string>
<string>2043.ImportedFromIB2</string>
<string>2044.IBPluginDependency</string>
@ -8013,6 +8021,7 @@ AAAAAAAAAAAAAAAAA</bytes>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{0, 952}, {118, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -9291,6 +9300,14 @@ AAAAAAAAAAAAAAAAA</bytes>
<string key="minorKey">macosx/FileOutlineView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">FilterBarView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">macosx/FilterBarView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">FilterButton</string>
<string key="superclassName">NSButton</string>