From fa5e3cf8695da1e5ca0b866c79ee9e8e4ddd7b7c Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 30 Oct 2018 21:22:13 +0700 Subject: [PATCH] =?UTF-8?q?Remove=20custom=20NSCell=20subclass=20used=20fo?= =?UTF-8?q?r=20file=20browser=E2=80=99s=20folder=20pop-up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose was to render text with a shadow and fade the text when the window is inactive, but the former has not been used since 10.10 and the latter doesn’t actually seem to work. --- .../FileBrowser/src/OFB/OFBHeaderView.mm | 73 +------------------ 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/Frameworks/FileBrowser/src/OFB/OFBHeaderView.mm b/Frameworks/FileBrowser/src/OFB/OFBHeaderView.mm index 59630068..71e23923 100644 --- a/Frameworks/FileBrowser/src/OFB/OFBHeaderView.mm +++ b/Frameworks/FileBrowser/src/OFB/OFBHeaderView.mm @@ -15,17 +15,10 @@ static NSButton* OakCreateImageButton (NSString* imageName) return res; } -@interface OFBHeaderViewPopupButtonCell : NSPopUpButtonCell -@property (nonatomic) NSDictionary* activeAttributes; -@property (nonatomic) NSDictionary* inactiveAttributes; -@end - static NSPopUpButton* OakCreateFolderPopUpButton () { NSPopUpButton* res = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:YES]; - OFBHeaderViewPopupButtonCell* cell = [[OFBHeaderViewPopupButtonCell alloc] initTextCell:@"" pullsDown:YES]; - [res setCell:cell]; - [cell setArrowPosition:NSPopUpArrowAtBottom]; + [[res cell] setBackgroundStyle:NSBackgroundStyleRaised]; [res setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal]; [res setContentHuggingPriority:NSLayoutPriorityFittingSizeCompression forOrientation:NSLayoutConstraintOrientationHorizontal]; [res setContentHuggingPriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationVertical]; @@ -38,70 +31,6 @@ static NSPopUpButton* OakCreateFolderPopUpButton () @property (nonatomic) NSView* bottomDivider; @end -@implementation OFBHeaderViewPopupButtonCell -- (id)initTextCell:(NSString*)title pullsDown:(BOOL)pullsDown -{ - if(self = [super initTextCell:title pullsDown:pullsDown]) - { - NSMutableParagraphStyle* parStyle = [NSMutableParagraphStyle new]; - [parStyle setLineBreakMode:NSLineBreakByTruncatingMiddle]; - - // MAC_OS_X_VERSION_10_10 - if(OAK_AVAILABLE(10, 10)) - { - NSFont* font = [NSFont systemFontOfSize:12]; - - _activeAttributes = @{ - NSParagraphStyleAttributeName: parStyle, - NSFontAttributeName: font, - NSForegroundColorAttributeName: [NSColor colorWithCalibratedWhite:0.2 alpha:1] - }; - _inactiveAttributes = @{ - NSParagraphStyleAttributeName: parStyle, - NSFontAttributeName: font, - NSForegroundColorAttributeName: [NSColor colorWithCalibratedWhite:0.5 alpha:1] - }; - } - else - { - NSShadow* shadow = [NSShadow new]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1 alpha:0.5]]; - [shadow setShadowOffset:NSMakeSize(0, -1)]; - [shadow setShadowBlurRadius:1]; - - NSFont* font = [NSFont boldSystemFontOfSize:12]; - - _activeAttributes = @{ - NSParagraphStyleAttributeName: parStyle, - NSFontAttributeName: font, - NSForegroundColorAttributeName: [NSColor colorWithCalibratedWhite:0.2 alpha:1], - NSShadowAttributeName: shadow, - }; - _inactiveAttributes = @{ - NSParagraphStyleAttributeName: parStyle, - NSFontAttributeName: font, - NSForegroundColorAttributeName: [NSColor colorWithCalibratedWhite:0.5 alpha:1], - NSShadowAttributeName: shadow, - }; - } - } - return self; -} - -- (NSRect)drawTitle:(NSAttributedString*)title withFrame:(NSRect)frame inView:(NSView*)controlView -{ - OFBHeaderView* headerView = (OFBHeaderView*)controlView.superview; - if(headerView.inTabBar) - { - NSDictionary* attrs = headerView.active ? _activeAttributes : _inactiveAttributes; - frame.origin.y += 1; - frame.size.height -= 1; - return [super drawTitle:[[NSAttributedString alloc] initWithString:title.string attributes:attrs] withFrame:frame inView:controlView]; - } - return [super drawTitle:title withFrame:frame inView:controlView]; -} -@end - @implementation OFBHeaderView - (id)initWithFrame:(NSRect)aRect {