Skip to content

Commit

Permalink
Remove some magic numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
xhacker committed Feb 3, 2015
1 parent 3be76bd commit d300bdb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions quark-shell/QSHStatusItemView.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@interface QSHStatusItemView : NSButton

#define MENUBAR_FONT [NSFont menuBarFontOfSize:14.0]

@property (nonatomic, weak) NSStatusItem *statusItem;
@property (nonatomic) BOOL itemHighlighted; // differentiate from NSControl’s highlighted
@property (nonatomic) NSImage *icon;
Expand Down
2 changes: 1 addition & 1 deletion quark-shell/QSHStatusItemView.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (void)drawRect:(NSRect)dirtyRect
iconFrame = NSMakeRect(3, yOffset, 20, 20);
NSColor *color = self.itemHighlighted ? [NSColor whiteColor] : [NSColor blackColor];
NSDictionary *barTextAttributes = @{
NSFontAttributeName: [NSFont systemFontOfSize:14.0],
NSFontAttributeName: MENUBAR_FONT,
NSForegroundColorAttributeName: color
};
[self.label drawInRect:NSMakeRect(25, 2, NSWidth(self.bounds) - 30, 20) withAttributes:barTextAttributes];
Expand Down
4 changes: 3 additions & 1 deletion quark-shell/QSHWebViewDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,15 @@ - (void)resetMenubarIcon

- (void)changeLabel:(NSString *)label
{
NSDictionary *barTextAttributes;
if (IS_PERIOR_TO_10_9) {
self.statusItemView.label = label;
barTextAttributes = @{NSFontAttributeName: MENUBAR_FONT};
}
else {
self.statusItem.title = label;
barTextAttributes = @{NSFontAttributeName: self.statusItem.button.font};
}
NSDictionary *barTextAttributes = @{NSFontAttributeName: [NSFont systemFontOfSize:14.0]};
// 20 is image width, 10 is extra margin
self.statusItem.length = 20 + [label sizeWithAttributes:barTextAttributes].width + 10;
}
Expand Down

0 comments on commit d300bdb

Please sign in to comment.