mirror of
https://github.com/HackPlan/quark-shell-mac.git
synced 2026-01-12 15:04:57 +08:00
Remove some magic numbers.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
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];
|
||||
|
||||
@@ -216,13 +216,15 @@ static const NSInteger kPreferencesDefaultHeight = 192;
|
||||
|
||||
- (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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user