some rewriting of the filter bar so it can dynamically place the buttons, and some extra, yet-to-be-used code

This commit is contained in:
Mitchell Livingston 2007-05-29 02:00:23 +00:00
parent 73c6c3324e
commit 3852bbb6e6
11 changed files with 191 additions and 86 deletions

View File

@ -62,6 +62,7 @@
A246004D0A6DCE4600D19088 /* SpeedLimitButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A246004C0A6DCE4600D19088 /* SpeedLimitButtonPressed.png */; };
A24600510A6DCE6600D19088 /* SpeedLimitButtonBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A246004F0A6DCE6600D19088 /* SpeedLimitButtonBlue.png */; };
A24600520A6DCE6600D19088 /* SpeedLimitButtonGraphite.png in Resources */ = {isa = PBXBuildFile; fileRef = A24600500A6DCE6600D19088 /* SpeedLimitButtonGraphite.png */; };
A24838820C0BA608005CC3FE /* FilterBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = A24838800C0BA608005CC3FE /* FilterBarView.m */; };
A24999230B49F1B5001EADA3 /* ActionPopUpButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A24999210B49F1B5001EADA3 /* ActionPopUpButton.m */; };
A24D2A640C0A624600A0ED9F /* IPCController.m in Sources */ = {isa = PBXBuildFile; fileRef = A24D2A620C0A624600A0ED9F /* IPCController.m */; };
A24F19080A3A790800C9C145 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; };
@ -328,6 +329,8 @@
A246004C0A6DCE4600D19088 /* SpeedLimitButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SpeedLimitButtonPressed.png; path = macosx/Images/SpeedLimitButtonPressed.png; sourceTree = "<group>"; };
A246004F0A6DCE6600D19088 /* SpeedLimitButtonBlue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SpeedLimitButtonBlue.png; path = macosx/Images/SpeedLimitButtonBlue.png; sourceTree = "<group>"; };
A24600500A6DCE6600D19088 /* SpeedLimitButtonGraphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SpeedLimitButtonGraphite.png; path = macosx/Images/SpeedLimitButtonGraphite.png; sourceTree = "<group>"; };
A248387F0C0BA608005CC3FE /* FilterBarView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FilterBarView.h; path = macosx/FilterBarView.h; sourceTree = "<group>"; };
A24838800C0BA608005CC3FE /* FilterBarView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = FilterBarView.m; path = macosx/FilterBarView.m; sourceTree = "<group>"; };
A24999200B49F1B5001EADA3 /* ActionPopUpButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionPopUpButton.h; path = macosx/ActionPopUpButton.h; sourceTree = "<group>"; };
A24999210B49F1B5001EADA3 /* ActionPopUpButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionPopUpButton.m; path = macosx/ActionPopUpButton.m; sourceTree = "<group>"; };
A24D2A610C0A624600A0ED9F /* IPCController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = IPCController.h; path = macosx/IPCController.h; sourceTree = "<group>"; };
@ -616,6 +619,8 @@
A2A1CB770BF29D5500AE959F /* PeerProgressIndicatorCell.h */,
A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */,
E138A9720C04D88F00C5426C /* CTGradient */,
A248387F0C0BA608005CC3FE /* FilterBarView.h */,
A24838800C0BA608005CC3FE /* FilterBarView.m */,
);
name = Sources;
sourceTree = "<group>";
@ -1208,6 +1213,7 @@
E138A9770C04D88F00C5426C /* CTGradient.m in Sources */,
E138A9780C04D88F00C5426C /* CTGradientAdditions.m in Sources */,
A24D2A640C0A624600A0ED9F /* IPCController.m in Sources */,
A24838820C0BA608005CC3FE /* FilterBarView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -242,7 +242,9 @@ void tr_ioSync( tr_io_t * io )
closeFiles( io );
if( io->checkFilesPassed )
{
fastResumeSave( io );
}
}
/***********************************************************************
@ -335,7 +337,7 @@ static int checkFiles( tr_io_t * io )
{
if ( io->pieceSlot[j] > 0 && j == i)
{
// only remove double piece when we found one sitting in the right slot
/* Only remove double piece when we found one sitting in the right slot */
tr_inf( "found piece %d (slot: %d) already on slot %d",j,i,io->pieceSlot[j] );
io->slotPiece[io->pieceSlot[j]] = -1;
@ -343,7 +345,7 @@ static int checkFiles( tr_io_t * io )
io->pieceSlot[j] = i;
io->slotPiece[i] = j;
}
else // we found no double
else /* We found no double */
{
io->pieceSlot[j] = i;
io->slotPiece[i] = j;

View File

@ -33,7 +33,7 @@
#import "DragOverlayWindow.h"
#import "Badger.h"
#import "ImageBackgroundView.h"
#import "FilterBarButton.h"
#import "FilterBarView.h"
#import "IPCController.h"
#import <Growl/Growl.h>
@ -72,9 +72,9 @@
* fNameSortActionItem, * fStateSortActionItem, * fProgressSortActionItem,
* fDateSortActionItem, * fOrderSortActionItem;
IBOutlet ImageBackgroundView * fFilterBar;
IBOutlet FilterBarButton * fNoFilterButton, * fPauseFilterButton,
* fSeedFilterButton, * fDownloadFilterButton;
IBOutlet FilterBarView * fFilterBar;
IBOutlet FilterBarButton * fNoFilterButton, * fDownloadFilterButton,
* fSeedFilterButton, * fPauseFilterButton;
IBOutlet NSSearchField * fSearchFilterField;
IBOutlet NSMenuItem * fNextFilterItem, * fPrevFilterItem;
@ -100,7 +100,7 @@
NSMutableDictionary * fPendingTorrentDownloads;
NSTimer * fAutoImportTimer;
BOOL fRemoteQuit;
BOOL fRemoteQuit;
}
- (void) openFiles: (NSArray *) filenames;

View File

@ -360,6 +360,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[currentFilterButton setEnabled: YES];
[fFilterBar replaceButtons];
//observe notifications
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];

View File

@ -93,6 +93,17 @@
SUPERCLASS = NSObject;
},
{CLASS = FilterBarButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
{
CLASS = FilterBarView;
LANGUAGE = ObjC;
OUTLETS = {
fDownloadFilterButton = FilterBarButton;
fNoFilterButton = FilterBarButton;
fPauseFilterButton = FilterBarButton;
fSeedFilterButton = FilterBarButton;
};
SUPERCLASS = ImageBackgroundView;
},
{
ACTIONS = {deselectAll = id; revealFile = id; setNextTab = id; setPreviousTab = id; };
CLASS = FirstResponder;

View File

@ -11,7 +11,7 @@
<key>1480</key>
<string>366 546 420 63 0 0 1152 842 </string>
<key>1603</key>
<string>275 437 477 67 0 0 1152 842 </string>
<string>337 544 477 67 0 0 1152 842 </string>
<key>29</key>
<string>145 689 451 44 0 0 1152 842 </string>
<key>456</key>
@ -32,6 +32,7 @@
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>1603</integer>
</array>
<key>IBSystem Version</key>
<string>8P135</string>

Binary file not shown.

View File

@ -28,11 +28,13 @@
{
NSImage * fButtonNormal, * fButtonNormalDim, * fButtonOver,
* fButtonPressed, * fButtonSelected, * fButtonSelectedDim;
int fCount;
BOOL fEnabled;
NSTrackingRectTag fTrackingTag;
}
- (void) createButtonsWithCount: (int) count;
- (void) setEnabled: (BOOL) enable;
- (void) resetBounds: (NSNotification *) notification;

View File

@ -24,15 +24,8 @@
#import "FilterBarButton.h"
@interface FilterBarButton (Private)
- (void) createButtons;
@end
@implementation FilterBarButton
//height of button should be 17.0
- (id) initWithCoder: (NSCoder *) coder
{
if ((self = [super initWithCoder: coder]))
@ -40,7 +33,8 @@
fEnabled = NO;
fTrackingTag = 0;
[self createButtons];
fCount = -1;
[self createButtonsWithCount: 0];
[self setImage: fButtonNormal];
[self setAlternateImage: fButtonPressed];
@ -73,9 +67,83 @@
}
//call only once
- (void) createButtons
- (void) createButtonsWithCount: (int) count
{
NSSize buttonSize = [self frame].size;
if (fCount == count)
return;
fCount = count;
//create attributes
NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
[NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
NSSize shadowOffset = NSMakeSize(0.0, -1.0);
NSShadow * shadow = [NSShadow alloc];
[shadow setShadowOffset: shadowOffset];
[shadow setShadowBlurRadius: 1.0];
[shadow 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]];
NSDictionary * normalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor colorWithCalibratedRed: 0.259 green: 0.259 blue: 0.259 alpha: 1.0],
NSForegroundColorAttributeName,
boldFont, NSFontAttributeName,
shadow, NSShadowAttributeName, nil],
* normalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor disabledControlTextColor], NSForegroundColorAttributeName,
boldFont, NSFontAttributeName,
shadowDim, NSShadowAttributeName, nil],
* highlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor whiteColor], NSForegroundColorAttributeName,
boldFont, NSFontAttributeName,
shadow, NSShadowAttributeName, nil],
* highlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0], NSForegroundColorAttributeName,
boldFont, NSFontAttributeName,
shadow, NSShadowAttributeName, nil];
[shadow release];
[shadowDim release];
//create button text
NSString * text = [self title];
if (fCount > 0)
text = [text stringByAppendingString: [NSString stringWithFormat: @" (%d)", fCount]];
//get images
NSImage * leftOver = [NSImage imageNamed: @"FilterButtonOverLeft.png"],
* rightOver = [NSImage imageNamed: @"FilterButtonOverRight.png"],
* mainOver = [NSImage imageNamed: @"FilterButtonOverMain.png"];
NSImage * leftPressed = [NSImage imageNamed: @"FilterButtonPressedLeft.png"],
* rightPressed = [NSImage imageNamed: @"FilterButtonPressedRight.png"],
* mainPressed = [NSImage imageNamed: @"FilterButtonPressedMain.png"];
NSImage * leftSelected = [NSImage imageNamed: @"FilterButtonSelectedLeft.png"],
* rightSelected = [NSImage imageNamed: @"FilterButtonSelectedRight.png"],
* mainSelected = [NSImage imageNamed: @"FilterButtonSelectedMain.png"];
//get button sizes and placement
NSLog(text);
NSSize textSize = [text sizeWithAttributes: normalAttributes];NSLog(NSStringFromSize(textSize));
textSize.width = ceilf(textSize.width);NSLog(NSStringFromSize(textSize));
float overlap = 4.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];
@ -84,16 +152,6 @@
fButtonSelectedDim = [[NSImage alloc] initWithSize: buttonSize];
//rolled over button
NSImage * leftOver = [NSImage imageNamed: @"FilterButtonOverLeft.png"],
* rightOver = [NSImage imageNamed: @"FilterButtonOverRight.png"],
* mainOver = [NSImage imageNamed: @"FilterButtonOverMain.png"];
NSSize endSize = [leftOver size],
mainSize = NSMakeSize(buttonSize.width - endSize.width * 2.0, endSize.height);
NSPoint leftPoint = NSMakePoint(0, 0),
rightPoint = NSMakePoint(buttonSize.width - endSize.width, 0),
mainPoint = NSMakePoint(endSize.width, 0);
[mainOver setScalesWhenResized: YES];
[mainOver setSize: mainSize];
@ -104,10 +162,6 @@
[fButtonOver unlockFocus];
//pressed button
NSImage * leftPressed = [NSImage imageNamed: @"FilterButtonPressedLeft.png"],
* rightPressed = [NSImage imageNamed: @"FilterButtonPressedRight.png"],
* mainPressed = [NSImage imageNamed: @"FilterButtonPressedMain.png"];
[mainPressed setScalesWhenResized: YES];
[mainPressed setSize: mainSize];
@ -118,10 +172,6 @@
[fButtonPressed unlockFocus];
//selected button
NSImage * leftSelected = [NSImage imageNamed: @"FilterButtonSelectedLeft.png"],
* rightSelected = [NSImage imageNamed: @"FilterButtonSelectedRight.png"],
* mainSelected = [NSImage imageNamed: @"FilterButtonSelectedMain.png"];
[mainSelected setScalesWhenResized: YES];
[mainSelected setSize: mainSize];
@ -133,55 +183,6 @@
//selected and dimmed button
fButtonSelectedDim = [fButtonSelected copy];
//create button text
NSString * text = [self title];
NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
[NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
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 * shadowNormalDim = [NSShadow alloc];
[shadowNormalDim setShadowOffset: shadowOffset];
[shadowNormalDim setShadowBlurRadius: 1.0];
[shadowNormalDim setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.2]];
NSShadow * shadowHighlighted = [NSShadow alloc];
[shadowHighlighted setShadowOffset: shadowOffset];
[shadowHighlighted setShadowBlurRadius: 1.0];
[shadowHighlighted setShadowColor: [NSColor colorWithDeviceWhite: 0.0 alpha: 0.4]];
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,
shadowNormalDim, 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];
NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes];
NSRect textRect = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5,
(buttonSize.height - textSizeNormal.height) * 0.5 + 1.5, textSizeNormal.width, textSizeNormal.height);
[shadowNormal release];
[shadowNormalDim release];
[shadowHighlighted release];
//normal button
[fButtonNormal lockFocus];
@ -217,6 +218,11 @@
[normalDimAttributes release];
[highlightedAttributes release];
[highlightedDimAttributes release];
//resize button
NSPoint point = [self frame].origin;
[self setFrame: NSMakeRect(point.x, point.y, buttonSize.width, buttonSize.height)];
[self setNeedsDisplay: YES];
}
- (void) mouseEntered: (NSEvent *) event

37
macosx/FilterBarView.h Normal file
View File

@ -0,0 +1,37 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2007 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>
#import "ImageBackgroundView.h"
#import "FilterBarButton.h"
@interface FilterBarView : ImageBackgroundView
{
IBOutlet FilterBarButton * fNoFilterButton, * fDownloadFilterButton,
* fSeedFilterButton, * fPauseFilterButton;
}
- (void) replaceButtons;
@end

38
macosx/FilterBarView.m Normal file
View File

@ -0,0 +1,38 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2007 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
- (void) replaceButtons
{
float padding = 2.0, base = 3.0;
[fNoFilterButton setFrameOrigin: NSMakePoint(padding + 2.0, base)];
[fDownloadFilterButton setFrameOrigin: NSMakePoint(NSMaxX([fNoFilterButton frame]) + padding, base)];
[fSeedFilterButton setFrameOrigin: NSMakePoint(NSMaxX([fDownloadFilterButton frame]) + padding, base)];
[fPauseFilterButton setFrameOrigin: NSMakePoint(NSMaxX([fSeedFilterButton frame]) + padding, base)];
}
@end