Use NSString+ANSI on the Menu title
This commit is contained in:
parent
1d807c552e
commit
d722d20974
1 changed files with 19 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) 2014 GitHub, Inc.
|
// Copyright (c) 2014 GitHub, Inc.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
#import "atom/browser/mac/NSString+ANSI.h"
|
||||||
|
|
||||||
#include "atom/browser/ui/tray_icon_cocoa.h"
|
#include "atom/browser/ui/tray_icon_cocoa.h"
|
||||||
|
|
||||||
|
@ -121,8 +122,12 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
// Draw title.
|
// Draw title.
|
||||||
NSRect titleDrawRect = NSMakeRect(
|
NSRect titleDrawRect = NSMakeRect(
|
||||||
[self iconWidth], -kVerticalTitleMargin, [self titleWidth], thickness);
|
[self iconWidth], -kVerticalTitleMargin, [self titleWidth], thickness);
|
||||||
[title_ drawInRect:titleDrawRect
|
|
||||||
withAttributes:[self titleAttributesWithHighlight:highlightContent]];
|
NSAttributedString *titleu = [self attributedTitleWithParams:title_];
|
||||||
|
|
||||||
|
[titleu drawInRect:titleDrawRect];
|
||||||
|
//[title_ drawInRect:titleDrawRect
|
||||||
|
// withAttributes:[self titleAttributesWithHighlight:highlightContent]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +209,11 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- (void)setTitle:(NSAttributedString*)title {
|
||||||
- (void)setTitle:(NSString*)title {
|
- (void)setTitle:(NSString*)title {
|
||||||
if (title.length > 0) {
|
if (title.length > 0) {
|
||||||
|
// title = [self attributedTitleWithParams:title];
|
||||||
|
|
||||||
title_.reset([title copy]);
|
title_.reset([title copy]);
|
||||||
} else {
|
} else {
|
||||||
title_.reset();
|
title_.reset();
|
||||||
|
@ -213,6 +221,15 @@ const CGFloat kVerticalTitleMargin = 2;
|
||||||
[self updateDimensions];
|
[self updateDimensions];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (NSAttributedString*) attributedTitleWithParams:(NSString *)fullTitle {
|
||||||
|
NSDictionary* attributes = @{NSBaselineOffsetAttributeName : @1};
|
||||||
|
NSMutableAttributedString * attributedTitle = [fullTitle attributedStringParsingANSICodes];
|
||||||
|
[attributedTitle addAttributes:attributes range:NSMakeRange(0, attributedTitle.length)];
|
||||||
|
|
||||||
|
return attributedTitle;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setMenuController:(AtomMenuController*)menu {
|
- (void)setMenuController:(AtomMenuController*)menu {
|
||||||
menuController_ = menu;
|
menuController_ = menu;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue