From: Haojian Wu Date: Thu, 16 Jul 2015 10:36:45 +0000 (+0800) Subject: More code style fixing. X-Git-Tag: v0.30.1~16^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2cd6ad1a9712cdf9cf97564de1d3c382ce2f7c3f;p=electron.git More code style fixing. --- diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index 8d1748e3..4dcb6d27 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -9,9 +9,13 @@ #include "ui/gfx/image/image.h" #include "ui/gfx/screen.h" +namespace { + const CGFloat kStatusItemLength = 26; const CGFloat kMargin = 3; +} // namespace + @interface StatusItemView : NSView { atom::TrayIconCocoa* trayIcon_; // weak AtomMenuController* menuController_; // weak @@ -88,7 +92,7 @@ const CGFloat kMargin = 3; } } -- (CGFloat) titleWidth { +- (CGFloat)titleWidth { if (!title_) return 0; NSAttributedString* attributes = [[NSAttributedString alloc] initWithString:title_ @@ -96,7 +100,7 @@ const CGFloat kMargin = 3; return [attributes size].width; } -- (NSDictionary *)titleAttributes { +- (NSDictionary*)titleAttributes { NSFont* font = [NSFont menuBarFontOfSize:0]; NSColor* foregroundColor = [NSColor blackColor]; @@ -108,6 +112,7 @@ const CGFloat kMargin = 3; - (void)setImage:(NSImage*)image { image_.reset([image copy]); + [self setNeedsDisplay:YES]; } - (void)setAlternateImage:(NSImage*)image { @@ -118,20 +123,21 @@ const CGFloat kMargin = 3; isHighlightEnable_ = highlight; } --(void)setTitle:(NSString*) title { +- (void)setTitle:(NSString*)title { title_.reset([title copy]); + [self setNeedsDisplay:YES]; } - (void)setMenuController:(AtomMenuController*)menu { menuController_ = menu; } --(void)mouseDown:(NSEvent *)event { +- (void)mouseDown:(NSEvent*)event { inMouseEventSequence_ = YES; [self setNeedsDisplay:YES]; } --(void)mouseUp:(NSEvent *)event { +- (void)mouseUp:(NSEvent*)event { if (!inMouseEventSequence_) { // If the menu is showing, when user clicked the tray icon, the `mouseDown` // event will be dissmissed, we need to close the menu at this time. @@ -168,12 +174,12 @@ const CGFloat kMargin = 3; trayIcon_->NotifyRightClicked([self getBoundsFromEvent:event]); } --(BOOL) shouldHighlight { +- (BOOL)shouldHighlight { BOOL is_menu_open = [menuController_ isMenuOpen]; return isHighlightEnable_ && (inMouseEventSequence_ || is_menu_open); } --(gfx::Rect) getBoundsFromEvent:(NSEvent*)event { +- (gfx::Rect)getBoundsFromEvent:(NSEvent*)event { NSRect frame = event.window.frame; gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); NSScreen* screen = [[NSScreen screens] objectAtIndex:0];