More code style fixing.
This commit is contained in:
parent
17628b3e40
commit
2cd6ad1a97
1 changed files with 13 additions and 7 deletions
|
@ -9,9 +9,13 @@
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "ui/gfx/screen.h"
|
#include "ui/gfx/screen.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
const CGFloat kStatusItemLength = 26;
|
const CGFloat kStatusItemLength = 26;
|
||||||
const CGFloat kMargin = 3;
|
const CGFloat kMargin = 3;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
@interface StatusItemView : NSView {
|
@interface StatusItemView : NSView {
|
||||||
atom::TrayIconCocoa* trayIcon_; // weak
|
atom::TrayIconCocoa* trayIcon_; // weak
|
||||||
AtomMenuController* menuController_; // weak
|
AtomMenuController* menuController_; // weak
|
||||||
|
@ -88,7 +92,7 @@ const CGFloat kMargin = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat) titleWidth {
|
- (CGFloat)titleWidth {
|
||||||
if (!title_) return 0;
|
if (!title_) return 0;
|
||||||
NSAttributedString* attributes =
|
NSAttributedString* attributes =
|
||||||
[[NSAttributedString alloc] initWithString:title_
|
[[NSAttributedString alloc] initWithString:title_
|
||||||
|
@ -96,7 +100,7 @@ const CGFloat kMargin = 3;
|
||||||
return [attributes size].width;
|
return [attributes size].width;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)titleAttributes {
|
- (NSDictionary*)titleAttributes {
|
||||||
NSFont* font = [NSFont menuBarFontOfSize:0];
|
NSFont* font = [NSFont menuBarFontOfSize:0];
|
||||||
NSColor* foregroundColor = [NSColor blackColor];
|
NSColor* foregroundColor = [NSColor blackColor];
|
||||||
|
|
||||||
|
@ -108,6 +112,7 @@ const CGFloat kMargin = 3;
|
||||||
|
|
||||||
- (void)setImage:(NSImage*)image {
|
- (void)setImage:(NSImage*)image {
|
||||||
image_.reset([image copy]);
|
image_.reset([image copy]);
|
||||||
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAlternateImage:(NSImage*)image {
|
- (void)setAlternateImage:(NSImage*)image {
|
||||||
|
@ -118,20 +123,21 @@ const CGFloat kMargin = 3;
|
||||||
isHighlightEnable_ = highlight;
|
isHighlightEnable_ = highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setTitle:(NSString*) title {
|
- (void)setTitle:(NSString*)title {
|
||||||
title_.reset([title copy]);
|
title_.reset([title copy]);
|
||||||
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMenuController:(AtomMenuController*)menu {
|
- (void)setMenuController:(AtomMenuController*)menu {
|
||||||
menuController_ = menu;
|
menuController_ = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)mouseDown:(NSEvent *)event {
|
- (void)mouseDown:(NSEvent*)event {
|
||||||
inMouseEventSequence_ = YES;
|
inMouseEventSequence_ = YES;
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)mouseUp:(NSEvent *)event {
|
- (void)mouseUp:(NSEvent*)event {
|
||||||
if (!inMouseEventSequence_) {
|
if (!inMouseEventSequence_) {
|
||||||
// If the menu is showing, when user clicked the tray icon, the `mouseDown`
|
// 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.
|
// 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]);
|
trayIcon_->NotifyRightClicked([self getBoundsFromEvent:event]);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) shouldHighlight {
|
- (BOOL)shouldHighlight {
|
||||||
BOOL is_menu_open = [menuController_ isMenuOpen];
|
BOOL is_menu_open = [menuController_ isMenuOpen];
|
||||||
return isHighlightEnable_ && (inMouseEventSequence_ || is_menu_open);
|
return isHighlightEnable_ && (inMouseEventSequence_ || is_menu_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(gfx::Rect) getBoundsFromEvent:(NSEvent*)event {
|
- (gfx::Rect)getBoundsFromEvent:(NSEvent*)event {
|
||||||
NSRect frame = event.window.frame;
|
NSRect frame = event.window.frame;
|
||||||
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
|
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
|
||||||
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
|
||||||
|
|
Loading…
Reference in a new issue