Action menu's behavior should now mimic Mail.app's

This commit is contained in:
Mitchell Livingston 2007-01-02 03:10:11 +00:00
parent 6e812353f1
commit b9edcfb62b
10 changed files with 79 additions and 98 deletions

View File

@ -89,7 +89,6 @@
A200B9B60A22893D007BBB1E /* InfoWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = A200B9620A227FD0007BBB1E /* InfoWindow.nib */; };
A20AB97B0A5C622A004F81FA /* SmallTurtle.png in Resources */ = {isa = PBXBuildFile; fileRef = A20AB97A0A5C622A004F81FA /* SmallTurtle.png */; };
A21567ED0A9A5034004DECD6 /* MessageWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = A21567EB0A9A5034004DECD6 /* MessageWindow.nib */; };
A21610FC0A050B1700E8E4C1 /* MenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A21610FB0A050B1700E8E4C1 /* MenuButton.m */; };
A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */; };
A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */; };
@ -111,6 +110,8 @@
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 */; };
A24999230B49F1B5001EADA3 /* ActionPopUpButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A24999210B49F1B5001EADA3 /* ActionPopUpButton.m */; };
A24999440B49F5AD001EADA3 /* ActionPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A24999420B49F5AD001EADA3 /* ActionPopUpButtonCell.m */; };
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 */; };
@ -289,8 +290,6 @@
A200B9630A227FD0007BBB1E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = macosx/English.lproj/InfoWindow.nib; sourceTree = "<group>"; };
A20AB97A0A5C622A004F81FA /* SmallTurtle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SmallTurtle.png; path = macosx/Images/SmallTurtle.png; sourceTree = "<group>"; };
A21567EC0A9A5034004DECD6 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = macosx/English.lproj/MessageWindow.nib; sourceTree = "<group>"; };
A21610FA0A050B1700E8E4C1 /* MenuButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MenuButton.h; path = macosx/MenuButton.h; sourceTree = "<group>"; };
A21610FB0A050B1700E8E4C1 /* MenuButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MenuButton.m; path = macosx/MenuButton.m; sourceTree = "<group>"; };
A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButtonPressed.png; path = macosx/Images/ActionButtonPressed.png; sourceTree = "<group>"; };
A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuRatioToDisplayRatioTransformer.h; path = macosx/ActionMenuRatioToDisplayRatioTransformer.h; sourceTree = "<group>"; };
@ -312,6 +311,10 @@
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>"; };
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>"; };
A24999420B49F5AD001EADA3 /* ActionPopUpButtonCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ActionPopUpButtonCell.m; path = macosx/ActionPopUpButtonCell.m; sourceTree = "<group>"; };
A24999430B49F5AD001EADA3 /* ActionPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionPopUpButtonCell.h; path = macosx/ActionPopUpButtonCell.h; sourceTree = "<group>"; };
A24F19070A3A790800C9C145 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = macosx/Sparkle.framework; sourceTree = "<group>"; };
A253F6F20A698970008EE24F /* FilterBarBackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterBarBackground.png; path = macosx/Images/FilterBarBackground.png; sourceTree = "<group>"; };
A253F7080A6990EB008EE24F /* FilterButtonOverMain.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FilterButtonOverMain.png; path = macosx/Images/FilterButtonOverMain.png; sourceTree = "<group>"; };
@ -452,8 +455,6 @@
4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */,
29B97316FDCFA39411CA2CEA /* main.m */,
32CA4F630368D1EE00C91783 /* Transmission_Prefix.pch */,
A21610FA0A050B1700E8E4C1 /* MenuButton.h */,
A21610FB0A050B1700E8E4C1 /* MenuButton.m */,
A2AF1C360A3D0F6200F1575D /* FileTableView.h */,
A2AF1C370A3D0F6200F1575D /* FileTableView.m */,
A27431D80A68538400FA780A /* BarButton.h */,
@ -464,6 +465,10 @@
A2710E750A86796000CE4F7D /* PrefsWindow.m */,
A2AA579A0ADFCAB400CA59F6 /* PiecesImageView.h */,
A2AA579B0ADFCAB400CA59F6 /* PiecesImageView.m */,
A24999200B49F1B5001EADA3 /* ActionPopUpButton.h */,
A24999210B49F1B5001EADA3 /* ActionPopUpButton.m */,
A24999420B49F5AD001EADA3 /* ActionPopUpButtonCell.m */,
A24999430B49F5AD001EADA3 /* ActionPopUpButtonCell.h */,
);
name = Sources;
sourceTree = "<group>";
@ -910,7 +915,6 @@
4DE5CCA70980735700BE280E /* Badger.m in Sources */,
4DFBC2DF09C0970D00D5C571 /* Torrent.m in Sources */,
4DCCBB3E09C3D71100D3CABF /* TorrentCell.m in Sources */,
A21610FC0A050B1700E8E4C1 /* MenuButton.m in Sources */,
A200B9200A22798F007BBB1E /* InfoWindowController.m in Sources */,
A2AF1C390A3D0F6200F1575D /* FileTableView.m in Sources */,
A27ABC240A6ADE410020EC71 /* ImageBackgroundView.m in Sources */,
@ -929,6 +933,8 @@
A25E74650AF5097C006F11AE /* ExpandedPathToPathTransformer.m in Sources */,
A25E74660AF5097D006F11AE /* ExpandedPathToIconTransformer.m in Sources */,
A2BF07910B066E0800757C92 /* SpeedLimitToTurtleIconTransformer.m in Sources */,
A24999230B49F1B5001EADA3 /* ActionPopUpButton.m in Sources */,
A24999440B49F5AD001EADA3 /* ActionPopUpButtonCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -0,0 +1,8 @@
/* ActionPopUpButton */
#import <Cocoa/Cocoa.h>
@interface ActionPopUpButton : NSPopUpButton
{
}
@end

View File

@ -0,0 +1,20 @@
#import "ActionPopUpButton.h"
#import "ActionPopUpButtonCell.h"
@implementation ActionPopUpButton
+ (Class) cellClass
{
return [ActionPopUpButtonCell class];
}
- (id) initWithCoder: (NSCoder *) coder
{
if (self = [super initWithCoder: coder])
{
[self setCell: [[ActionPopUpButtonCell alloc] initTextCell: @"" pullsDown: YES]];
}
return self;
}
@end

View File

@ -0,0 +1,9 @@
/* ActionPopUpButton */
#import <Cocoa/Cocoa.h>
@interface ActionPopUpButtonCell : NSPopUpButtonCell
{
NSImage * fImage, * fImagePressed;
}
@end

View File

@ -0,0 +1,24 @@
#import "ActionPopUpButtonCell.h"
@implementation ActionPopUpButtonCell
- (id) initTextCell: (NSString *) string pullsDown: (BOOL) pullDown
{
if (self = [super initTextCell: string pullsDown: YES])
{
fImage = [NSImage imageNamed: @"ActionButton.png"];
[fImage setFlipped: YES];
fImagePressed = [NSImage imageNamed: @"ActionButtonPressed.png"];
[fImage setFlipped: YES];
}
return self;
}
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
{
NSImage * image = [self isHighlighted] ? fImagePressed : fImage;
[image drawInRect: cellFrame fromRect: NSMakeRect(0.0, 0.0, [image size].width, [image size].height)
operation: NSCompositeSourceOver fraction: 1.0];
}
@end

View File

@ -1,5 +1,11 @@
{
IBClasses = (
{CLASS = ActionPopUpButton; LANGUAGE = ObjC; SUPERCLASS = NSPopUpButton; },
{
CLASS = ActionPopUpButtonCell;
LANGUAGE = ObjC;
SUPERCLASS = NSPopUpButtonCell;
},
{CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
{
ACTIONS = {
@ -94,7 +100,6 @@
SUPERCLASS = NSObject;
},
{CLASS = ImageBackgroundView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
{CLASS = MenuButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
{CLASS = NSSegmentedControl; LANGUAGE = ObjC; SUPERCLASS = NSControl; },
{CLASS = NameCell; LANGUAGE = ObjC; SUPERCLASS = NSCell; },
{

View File

@ -31,7 +31,6 @@
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>1041</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>

Binary file not shown.

View File

@ -1,30 +0,0 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2006 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 MenuButton : NSButton
{
}
@end

View File

@ -1,60 +0,0 @@
/******************************************************************************
* $Id$
*
* Copyright (c) 2006 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 "MenuButton.h"
@implementation MenuButton
- (void) mouseDown: (NSEvent *) event
{
NSImage * image = [self image];
[self setImage: [self alternateImage]];
//approximate height of menu...alright for now
/*float menuHeight = ((float)[[self menu] numberOfItems] + 2.0) * [NSMenuView menuBarHeight];
BOOL moveToTop = menuHeight > [[self window] frame].origin.y;*/
NSPoint point = NSMakePoint(3.0, /*moveToTop ? [self frame].size.height + menuHeight :*/ -2.0);
NSEvent * newEvent= [NSEvent mouseEventWithType: [event type]
location: point
modifierFlags: [event modifierFlags]
timestamp: [event timestamp]
windowNumber: [event windowNumber]
context: [event context]
eventNumber: [event eventNumber]
clickCount: [event clickCount]
pressure: [event pressure]];
[NSMenu popUpContextMenu: [self menu] withEvent: newEvent forView: self];
[self setImage: image];
}
- (NSMenu *) menuForEvent: (NSEvent *) event
{
return nil;
}
@end