mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 09:59:43 +00:00
NSOutlineView change to use no Autolayout since it fucked up resizing
This commit is contained in:
@@ -13,6 +13,7 @@ NSString *const MPToolbarItemAddGroup = @"AddGroup";
|
||||
NSString *const MPToolbarItemAddEntry = @"AddEntry";
|
||||
NSString *const MPToolbarItemEdit = @"Edit";
|
||||
NSString *const MPToolbarItemDelete =@"Delete";
|
||||
NSString *const MPToolbarItemAction = @"Action";
|
||||
|
||||
@interface MPToolbarDelegate()
|
||||
|
||||
@@ -29,7 +30,7 @@ NSString *const MPToolbarItemDelete =@"Delete";
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup ];
|
||||
self.toolbarIdentifiers = @[ MPToolbarItemAddEntry, MPToolbarItemDelete, MPToolbarItemEdit, MPToolbarItemAddGroup, MPToolbarItemAction ];
|
||||
self.toolbarItems = [NSMutableDictionary dictionaryWithCapacity:[self.toolbarItems count]];
|
||||
self.toolbarImages = [self createToolbarImages];
|
||||
}
|
||||
@@ -40,15 +41,54 @@ NSString *const MPToolbarItemDelete =@"Delete";
|
||||
NSToolbarItem *item = self.toolbarItems[ itemIdentifier ];
|
||||
if( !item ) {
|
||||
item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
|
||||
[item setImage:self.toolbarImages[itemIdentifier]];
|
||||
NSButton *button;
|
||||
if([itemIdentifier isEqualToString:MPToolbarItemAction]) {
|
||||
NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES];
|
||||
[[popupButton cell] setBezelStyle:NSTexturedRoundedBezelStyle];
|
||||
[[popupButton cell] setImageScaling:NSImageScaleProportionallyDown];
|
||||
[popupButton setTitle:@""];
|
||||
/*
|
||||
Built menu
|
||||
*/
|
||||
NSMenu *menu = [NSMenu allocWithZone:[NSMenu menuZone]];
|
||||
NSMenuItem *item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""];
|
||||
[item setImage:self.toolbarImages[itemIdentifier]];
|
||||
[menu addItem:item];
|
||||
[menu addItemWithTitle:@"Foo" action:NULL keyEquivalent:@""];
|
||||
[menu addItemWithTitle:@"Bar" action:NULL keyEquivalent:@""];
|
||||
[popupButton setMenu:menu];
|
||||
|
||||
/*
|
||||
Cleanup
|
||||
*/
|
||||
[item release];
|
||||
[menu release];
|
||||
button = popupButton;
|
||||
}
|
||||
else {
|
||||
button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
|
||||
[[button cell] setBezelStyle:NSTexturedRoundedBezelStyle];
|
||||
[[button cell] setImageScaling:NSImageScaleProportionallyDown];
|
||||
[button setTitle:@""];
|
||||
[button setButtonType:NSMomentaryPushInButton];
|
||||
NSImage *image = self.toolbarImages[itemIdentifier];
|
||||
[button setImage:image];
|
||||
[button setImagePosition:NSImageOnly];
|
||||
}
|
||||
[button sizeToFit];
|
||||
|
||||
NSString *label = NSLocalizedString(itemIdentifier, @"");
|
||||
[item setLabel:label];
|
||||
|
||||
[item setView:button];
|
||||
|
||||
[item setAction:@selector(toolbarItemPressed:)];
|
||||
|
||||
self.toolbarItems[itemIdentifier] = item;
|
||||
[item release];
|
||||
[button release];
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
return item;
|
||||
@@ -64,12 +104,14 @@ NSString *const MPToolbarItemDelete =@"Delete";
|
||||
}
|
||||
|
||||
- (NSDictionary *)createToolbarImages{
|
||||
NSDictionary *imageDict = @{ MPToolbarItemAddEntry: [MPIconHelper icon:MPIconCamera],
|
||||
NSDictionary *imageDict = @{ MPToolbarItemAddEntry: [MPIconHelper icon:MPIconPassword],
|
||||
MPToolbarItemAddGroup: [MPIconHelper icon:MPIconPassword],
|
||||
MPToolbarItemDelete: [MPIconHelper icon:MPIconServer],
|
||||
MPToolbarItemEdit: [MPIconHelper icon:MPIconNotepad]
|
||||
MPToolbarItemDelete: [NSImage imageNamed:NSImageNameRemoveTemplate],
|
||||
MPToolbarItemEdit: [MPIconHelper icon:MPIconNotepad],
|
||||
MPToolbarItemAction: [NSImage imageNamed:NSImageNameActionTemplate]
|
||||
};
|
||||
return imageDict;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user